diff --git a/.classpath b/.classpath deleted file mode 100644 index e40b897..0000000 --- a/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.gitignore b/.gitignore index 8448160..6c31948 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,14 @@ -bin/* -gen/* -*.log +# Specifies intentionally untracked files to ignore when using Git. +# http://git-scm.com/docs/gitignore + +# IntelliJ +.idea/ +*.iml + +# Gradle +.gradle/ +build/ local.properties + +# macOS +.DS_Store diff --git a/.project b/.project deleted file mode 100644 index 5c9dda7..0000000 --- a/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - funf - - - - - - 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 - - diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4761780 --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +BSD 3-Clause License + +Copyright (c) 2010-2012, MIT +Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index e5263f7..7699fcc 100644 --- a/README.md +++ b/README.md @@ -38,20 +38,14 @@ to your server. Easily decrypt and merge many data files into [one convenient database](https://github.com/funf-org/funf-core-android/wiki/ProcessingData). - # How to Build -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 Android documentation for integrating a -library project for -[Eclipse projects](http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject) -or via the -[command line](http://developer.android.com/guide/developing/projects/projects-cmdline.html#ReferencingLibraryProject). +The Funf project can be used as an Android library module, or can be packaged as a compiled ARR/JAR +file. The typical method of using Funf is by using an ARR/JAR file. See the [Android +documentation](https://developer.android.com/studio/projects/android-library.html) for building the +ARR/JAR file. + +If you think that you will be making frequent changes to the Funf library, you may want to integrate +Funf as a library module. To use it as an Android library, add this project as a library dependency +of your Android application project. See the [Android +documentation](https://developer.android.com/studio/projects/android-library.html) for integrating a +library project. 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..305dc05 --- /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:2.2.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/build.gradle b/funf/build.gradle new file mode 100644 index 0000000..cb592e2 --- /dev/null +++ b/funf/build.gradle @@ -0,0 +1,22 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 17 + buildToolsVersion "25.0.2" + + defaultConfig { + minSdkVersion 8 + targetSdkVersion 14 + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} + +dependencies { + compile 'com.google.code.gson:gson:2.1' +} diff --git a/funf/lint.xml b/funf/lint.xml new file mode 100644 index 0000000..8423c0e --- /dev/null +++ b/funf/lint.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/funf/src/main/AndroidManifest.xml b/funf/src/main/AndroidManifest.xml new file mode 100644 index 0000000..965e8b9 --- /dev/null +++ b/funf/src/main/AndroidManifest.xml @@ -0,0 +1,41 @@ + + + + + + + diff --git a/src/com/google/gson/internal/bind/JsonTreeReader.java b/funf/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/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java diff --git a/src/com/google/gson/internal/bind/JsonTreeWriter.java b/funf/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/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java diff --git a/src/edu/mit/media/funf/FunfManager.java b/funf/src/main/java/edu/mit/media/funf/FunfManager.java similarity index 91% rename from src/edu/mit/media/funf/FunfManager.java rename to funf/src/main/java/edu/mit/media/funf/FunfManager.java index 6f257ca..c5724fa 100644 --- a/src/edu/mit/media/funf/FunfManager.java +++ b/funf/src/main/java/edu/mit/media/funf/FunfManager.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf; diff --git a/funf/src/main/java/edu/mit/media/funf/Launcher.java b/funf/src/main/java/edu/mit/media/funf/Launcher.java new file mode 100644 index 0000000..6c02eb7 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/Launcher.java @@ -0,0 +1,61 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf; + +import static edu.mit.media.funf.util.LogUtil.TAG; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +public class Launcher extends BroadcastReceiver { + + private static boolean launched = false; + + public static void launch(Context context) { + Log.v(TAG, "Launched!"); + Intent i = new Intent(context.getApplicationContext(), FunfManager.class); + context.getApplicationContext().startService(i); + launched = true; + } + + public static boolean isLaunched() { + return launched; + } + + @Override + public void onReceive(Context context, Intent intent) { + launch(context); + } + +} diff --git a/src/edu/mit/media/funf/Schedule.java b/funf/src/main/java/edu/mit/media/funf/Schedule.java similarity index 64% rename from src/edu/mit/media/funf/Schedule.java rename to funf/src/main/java/edu/mit/media/funf/Schedule.java index 1862433..b6082a6 100644 --- a/src/edu/mit/media/funf/Schedule.java +++ b/funf/src/main/java/edu/mit/media/funf/Schedule.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf; diff --git a/src/edu/mit/media/funf/action/Action.java b/funf/src/main/java/edu/mit/media/funf/action/Action.java similarity index 52% rename from src/edu/mit/media/funf/action/Action.java rename to funf/src/main/java/edu/mit/media/funf/action/Action.java index 6f9b246..0053ef3 100644 --- a/src/edu/mit/media/funf/action/Action.java +++ b/funf/src/main/java/edu/mit/media/funf/action/Action.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.action; diff --git a/funf/src/main/java/edu/mit/media/funf/action/ActionAdapter.java b/funf/src/main/java/edu/mit/media/funf/action/ActionAdapter.java new file mode 100644 index 0000000..101d33f --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/action/ActionAdapter.java @@ -0,0 +1,69 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.action; + +import com.google.gson.JsonElement; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.datasource.Startable.TriggerAction; +import edu.mit.media.funf.json.IJsonObject; +import edu.mit.media.funf.probe.Probe.DataListener; + +public class ActionAdapter implements DataListener { + + @Configurable + private Action target = null; + + ActionAdapter() { + } + + public ActionAdapter(Action action) { + this.target = action; + } + + public ActionAdapter(TriggerAction action) { + this.target = (Action)action; + } + + @Override + public void onDataReceived(IJsonObject dataSourceConfig, IJsonObject data) { + if (target != null) { + target.run(); + } + } + + @Override + public void onDataCompleted(IJsonObject dataSourceConfig, JsonElement checkpoint) { + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/action/RunArchiveAction.java b/funf/src/main/java/edu/mit/media/funf/action/RunArchiveAction.java new file mode 100644 index 0000000..b1e396c --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/action/RunArchiveAction.java @@ -0,0 +1,78 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.action; + +import java.io.File; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.storage.FileArchive; +import edu.mit.media.funf.util.LogUtil; + +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; +import android.util.Log; + +public class RunArchiveAction extends Action { + + @Configurable + private FileArchive archive = null; + + @Configurable + private SQLiteOpenHelper dbHelper = null; + + RunArchiveAction() { + } + + public RunArchiveAction(FileArchive archive, SQLiteOpenHelper dbHelper) { + this.archive = archive; + this.dbHelper = dbHelper; + } + + protected void execute() { + Log.d(LogUtil.TAG, "running archive"); + SQLiteDatabase db = dbHelper.getWritableDatabase(); + // TODO: add check to make sure this is not empty + File dbFile = new File(db.getPath()); + db.close(); + if (archive.add(dbFile)) { + dbFile.delete(); + } + dbHelper.getWritableDatabase(); // Build new database + Log.d(LogUtil.TAG, "archived!"); + setHandler(null); // free system resources + } + + protected boolean isLongRunningAction() { + return true; + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/action/RunUpdateAction.java b/funf/src/main/java/edu/mit/media/funf/action/RunUpdateAction.java new file mode 100644 index 0000000..119bfce --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/action/RunUpdateAction.java @@ -0,0 +1,75 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.action; + +import edu.mit.media.funf.FunfManager; +import edu.mit.media.funf.config.ConfigUpdater; +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.util.LogUtil; + +import android.util.Log; + +public class RunUpdateAction extends Action { + + @Configurable + private String name = null; + + @Configurable + private FunfManager manager = null; + + @Configurable + protected ConfigUpdater update = null; + + RunUpdateAction() { + } + + public RunUpdateAction(String name, FunfManager manager, ConfigUpdater update) { + this.name = name; + this.manager = manager; + this.update = update; + } + + protected void execute() { + if (name != null && manager != null && update != null) { + Log.d(LogUtil.TAG, "running update"); + update.run(name, manager); + } else { + Log.d(LogUtil.TAG, "update failed"); + } + setHandler(null); // free system resources + } + + protected boolean isLongRunningAction() { + return true; + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/action/RunUploadAction.java b/funf/src/main/java/edu/mit/media/funf/action/RunUploadAction.java new file mode 100644 index 0000000..8677c12 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/action/RunUploadAction.java @@ -0,0 +1,75 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.action; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.storage.FileArchive; +import edu.mit.media.funf.storage.RemoteFileArchive; +import edu.mit.media.funf.storage.UploadService; +import edu.mit.media.funf.util.LogUtil; + +import android.util.Log; + +public class RunUploadAction extends Action { + + @Configurable + private FileArchive archive = null; + + @Configurable + private RemoteFileArchive upload = null; + + private UploadService uploader; + + RunUploadAction() { + } + + public RunUploadAction(FileArchive archive, RemoteFileArchive upload, UploadService uploader) { + this.archive = archive; + this.upload = upload; + this.uploader = uploader; + } + + protected void execute() { + if (archive != null && upload != null && uploader != null) { + Log.d(LogUtil.TAG, "running upload"); + uploader.run(archive, upload); + } else { + Log.d(LogUtil.TAG, "upload failed"); + } + setHandler(null); // free system resources + } + + protected boolean isLongRunningAction() { + return true; + } +} \ No newline at end of file diff --git a/funf/src/main/java/edu/mit/media/funf/action/StartDataSourceAction.java b/funf/src/main/java/edu/mit/media/funf/action/StartDataSourceAction.java new file mode 100644 index 0000000..4c360a7 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/action/StartDataSourceAction.java @@ -0,0 +1,59 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.action; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.datasource.Startable; +import edu.mit.media.funf.datasource.Startable.TriggerAction; +import edu.mit.media.funf.util.LogUtil; +import android.util.Log; + +public class StartDataSourceAction extends Action implements TriggerAction { + + @Configurable + private Startable target = null; + + StartDataSourceAction() { + } + + public void setTarget(Startable target) { + this.target = target; + } + + protected void execute() { + if (target == null) + return; + Log.d(LogUtil.TAG, "running probe action start"); + target.start(); + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/action/StartableAction.java b/funf/src/main/java/edu/mit/media/funf/action/StartableAction.java new file mode 100644 index 0000000..05d32b0 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/action/StartableAction.java @@ -0,0 +1,77 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.action; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.datasource.Startable; +import edu.mit.media.funf.datasource.Startable.TriggerAction; +import edu.mit.media.funf.time.TimeUtil; +import edu.mit.media.funf.util.LogUtil; +import android.util.Log; + +public class StartableAction extends Action implements TriggerAction { + + @Configurable + private Double duration = null; + + @Configurable + private Startable target = null; + + StartableAction() { + } + + public void setTarget(Startable target) { + this.target = target; + } + + protected void execute() { + if (target == null) + return; + Log.d(LogUtil.TAG, "running action start"); + Log.d(LogUtil.TAG, target.getClass().getName()); + target.start(); + if (duration != null && duration > 0.0) { + getHandler().postDelayed(new Runnable() { + @Override + public void run() { + Log.d(LogUtil.TAG, "running action stop"); + target.stop(); + } + }, TimeUtil.secondsToMillis(duration)); + } + } + + protected boolean isLongRunningAction() { + return true; + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/action/StopDataSourceAction.java b/funf/src/main/java/edu/mit/media/funf/action/StopDataSourceAction.java new file mode 100644 index 0000000..00349f1 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/action/StopDataSourceAction.java @@ -0,0 +1,59 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.action; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.datasource.Startable; +import edu.mit.media.funf.datasource.Startable.TriggerAction; +import edu.mit.media.funf.util.LogUtil; +import android.util.Log; + +public class StopDataSourceAction extends Action implements TriggerAction { + + @Configurable + private Startable target = null; + + StopDataSourceAction() { + } + + public void setTarget(Startable target) { + this.target = target; + } + + protected void execute() { + if (target == null) + return; + Log.d(LogUtil.TAG, "running probe action stop"); + target.stop(); + } +} diff --git a/src/edu/mit/media/funf/action/WriteDataAction.java b/funf/src/main/java/edu/mit/media/funf/action/WriteDataAction.java similarity index 61% rename from src/edu/mit/media/funf/action/WriteDataAction.java rename to funf/src/main/java/edu/mit/media/funf/action/WriteDataAction.java index 982480a..0f5a401 100644 --- a/src/edu/mit/media/funf/action/WriteDataAction.java +++ b/funf/src/main/java/edu/mit/media/funf/action/WriteDataAction.java @@ -1,3 +1,35 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package edu.mit.media.funf.action; import android.content.ContentValues; diff --git a/src/edu/mit/media/funf/config/ConfigRewriteUtil.java b/funf/src/main/java/edu/mit/media/funf/config/ConfigRewriteUtil.java similarity index 93% rename from src/edu/mit/media/funf/config/ConfigRewriteUtil.java rename to funf/src/main/java/edu/mit/media/funf/config/ConfigRewriteUtil.java index 7bc28bf..901c729 100644 --- a/src/edu/mit/media/funf/config/ConfigRewriteUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/config/ConfigRewriteUtil.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.config; diff --git a/funf/src/main/java/edu/mit/media/funf/config/ConfigUpdater.java b/funf/src/main/java/edu/mit/media/funf/config/ConfigUpdater.java new file mode 100644 index 0000000..5b46dc4 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/config/ConfigUpdater.java @@ -0,0 +1,85 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.config; + +import android.util.Log; + +import com.google.gson.JsonObject; + +import edu.mit.media.funf.FunfManager; +import edu.mit.media.funf.util.EqualsUtil; +import edu.mit.media.funf.util.LogUtil; + +public abstract class ConfigUpdater { + + + public void run(String name, FunfManager mgr) { + JsonObject oldConfig = mgr.getPipelineConfig(name); + try { + JsonObject newConfig = getConfig(); + if (!EqualsUtil.areEqual(oldConfig, newConfig)) { + mgr.saveAndReload(name, newConfig); + } + } catch (ConfigUpdateException e) { + Log.w(LogUtil.TAG, "Unable to get config", e); + } + } + + abstract protected JsonObject getConfig() throws ConfigUpdateException; + + + + + + public class ConfigUpdateException extends Exception { + + private static final long serialVersionUID = 7595505577357891121L; + + public ConfigUpdateException() { + super(); + } + + public ConfigUpdateException(String detailMessage, Throwable throwable) { + super(detailMessage, throwable); + } + + public ConfigUpdateException(String detailMessage) { + super(detailMessage); + } + + public ConfigUpdateException(Throwable throwable) { + super(throwable); + } + + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/config/Configurable.java b/funf/src/main/java/edu/mit/media/funf/config/Configurable.java new file mode 100644 index 0000000..f93668c --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/config/Configurable.java @@ -0,0 +1,59 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.config; + +import static java.lang.annotation.ElementType.FIELD; +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; + +/** + * Used to indicate that a particular field is configurable. The name of the + * field will be used as the configuration name, and the default value will be + * calculated by creating an instance with no config and inspecting what value + * gets created. + * + */ +@Documented +@Retention(RUNTIME) +@Target(FIELD) +@Inherited +public @interface Configurable { + /** + * @return Overrides the field name, if specified. + */ + String name() default ""; +} \ No newline at end of file diff --git a/src/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java b/funf/src/main/java/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java similarity index 81% rename from src/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java rename to funf/src/main/java/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java index 2a03710..599bed6 100644 --- a/src/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java +++ b/funf/src/main/java/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.config; diff --git a/src/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java b/funf/src/main/java/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java similarity index 56% rename from src/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java rename to funf/src/main/java/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java index a364050..33df1fc 100644 --- a/src/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java +++ b/funf/src/main/java/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.config; diff --git a/src/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java b/funf/src/main/java/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java similarity index 80% rename from src/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java rename to funf/src/main/java/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java index fb3fe77..81d9135 100644 --- a/src/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java +++ b/funf/src/main/java/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.config; diff --git a/funf/src/main/java/edu/mit/media/funf/config/DefaultScheduleSerializer.java b/funf/src/main/java/edu/mit/media/funf/config/DefaultScheduleSerializer.java new file mode 100644 index 0000000..30a1a56 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/config/DefaultScheduleSerializer.java @@ -0,0 +1,82 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.config; + +import java.lang.reflect.Type; +import java.util.Arrays; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import edu.mit.media.funf.Schedule.DefaultSchedule; + +public class DefaultScheduleSerializer implements JsonSerializer { + + private static final String + VALUE = "value", + INTERVAL = "interval", + DURATION = "duration", + OPPORTUNISTIC = "opportunistic", + STRICT = "strict"; + + static { + // Ensure expected methods exist + for (String methodName : Arrays.asList(VALUE, INTERVAL, DURATION, OPPORTUNISTIC, STRICT)) { + try { + DefaultSchedule.class.getMethod(methodName); + } catch (SecurityException e) { + throw new RuntimeException("Default schedule does not have expected accessible method."); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Default schedule does not have expected accessible method.", e); + } + } + } + + @Override + public JsonElement serialize(DefaultSchedule src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject jsonObject = new JsonObject(); + // TODO: figure out what to do with value + if (!"".equals(src.value())) { + jsonObject.addProperty(VALUE, src.value()); + } + jsonObject.addProperty(RuntimeTypeAdapterFactory.TYPE, src.type().getName()); + jsonObject.addProperty(INTERVAL, src.interval()); + jsonObject.addProperty(DURATION, src.duration()); + jsonObject.addProperty(OPPORTUNISTIC, src.opportunistic()); + jsonObject.addProperty(STRICT, src.strict()); + return jsonObject; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/config/HttpConfigUpdater.java b/funf/src/main/java/edu/mit/media/funf/config/HttpConfigUpdater.java new file mode 100644 index 0000000..a61dfb4 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/config/HttpConfigUpdater.java @@ -0,0 +1,77 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.config; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; + +import edu.mit.media.funf.util.IOUtil; + +/** + * ConfigUpdater which does an Http get to the given url. + * + */ +public class HttpConfigUpdater extends ConfigUpdater { + + @Configurable + private String url; + + @Override + public JsonObject getConfig() throws ConfigUpdateException { + try { + String content = null; + if (IOUtil.isValidUrl(url)) { + content = IOUtil.httpGet(url, null); + } + if (content == null) { + throw new ConfigUpdateException("Unable to download configuration."); + } + return new JsonParser().parse(content).getAsJsonObject(); + } catch (JsonSyntaxException e) { + throw new ConfigUpdateException("Bad json in configuration.", e); + } catch (IllegalStateException e) { + throw new ConfigUpdateException("Bad json in configuration.", e); + } + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + +} diff --git a/src/edu/mit/media/funf/config/ListenerInjectorTypeAdapterFactory.java b/funf/src/main/java/edu/mit/media/funf/config/ListenerInjectorTypeAdapterFactory.java similarity index 78% rename from src/edu/mit/media/funf/config/ListenerInjectorTypeAdapterFactory.java rename to funf/src/main/java/edu/mit/media/funf/config/ListenerInjectorTypeAdapterFactory.java index 6793354..c420700 100644 --- a/src/edu/mit/media/funf/config/ListenerInjectorTypeAdapterFactory.java +++ b/funf/src/main/java/edu/mit/media/funf/config/ListenerInjectorTypeAdapterFactory.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.config; diff --git a/funf/src/main/java/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java b/funf/src/main/java/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java new file mode 100644 index 0000000..b1e7f0d --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java @@ -0,0 +1,44 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.config; + +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +public interface RuntimeTypeAdapterFactory extends TypeAdapterFactory { + + public static final String TYPE = "@type"; + + public Class getRuntimeType(final JsonElement el, final TypeToken type); +} diff --git a/src/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java b/funf/src/main/java/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java similarity index 63% rename from src/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java rename to funf/src/main/java/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java index 0dff165..c344beb 100644 --- a/src/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java +++ b/funf/src/main/java/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.config; diff --git a/funf/src/main/java/edu/mit/media/funf/data/DataNormalizer.java b/funf/src/main/java/edu/mit/media/funf/data/DataNormalizer.java new file mode 100644 index 0000000..101ccf0 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/data/DataNormalizer.java @@ -0,0 +1,61 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.data; + +public interface DataNormalizer { + + public T normalize(T data); + + public class EmailNormalizer implements DataNormalizer { + + @Override + public String normalize(String data) { + return data == null ? null : data.trim().toLowerCase(); + } + + } + + public class PhoneNumberNormalizer implements DataNormalizer { + + @Override + public String normalize(String numberString) { + numberString = numberString.replaceAll("[^0-9]",""); + int i = numberString.length(); + if (i <= 10) + return numberString; + else + return numberString.substring(i - 10); + } + + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/datasource/CompositeDataSource.java b/funf/src/main/java/edu/mit/media/funf/datasource/CompositeDataSource.java new file mode 100644 index 0000000..d59ebcf --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/datasource/CompositeDataSource.java @@ -0,0 +1,72 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.datasource; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.probe.Probe.DataListener; + +public class CompositeDataSource extends StartableDataSource { + + @Configurable + protected StartableDataSource source = null; + + @Configurable + protected DataListener filter = null; + + @Configurable + private boolean isEnabled = false; + + CompositeDataSource() { + } + + protected void ensureIsEnabled() { + if (!isEnabled) { + if (filter == null) { + filter = delegator; + } + source.setListener(filter); + isEnabled = true; + } + } + + @Override + protected void onStart() { + ensureIsEnabled(); + source.start(); + } + + @Override + protected void onStop() { + source.stop(); + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/datasource/DataSource.java b/funf/src/main/java/edu/mit/media/funf/datasource/DataSource.java new file mode 100644 index 0000000..bb5154c --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/datasource/DataSource.java @@ -0,0 +1,40 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.datasource; + +import edu.mit.media.funf.probe.Probe.DataListener; + +public interface DataSource { + + public void setListener(DataListener listener); +} diff --git a/funf/src/main/java/edu/mit/media/funf/datasource/ProbeDataSource.java b/funf/src/main/java/edu/mit/media/funf/datasource/ProbeDataSource.java new file mode 100644 index 0000000..04d4b60 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/datasource/ProbeDataSource.java @@ -0,0 +1,58 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.datasource; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.probe.Probe; +import edu.mit.media.funf.probe.Probe.ContinuousProbe; + +public class ProbeDataSource extends StartableDataSource { + + @Configurable + protected Probe source; + + ProbeDataSource() { + } + + @Override + protected void onStart() { + source.registerListener(delegator); + } + + @Override + protected void onStop() { + if (source instanceof ContinuousProbe) { + ((ContinuousProbe) source).unregisterListener(delegator); + } + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/datasource/Startable.java b/funf/src/main/java/edu/mit/media/funf/datasource/Startable.java new file mode 100644 index 0000000..6bdd9bb --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/datasource/Startable.java @@ -0,0 +1,45 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.datasource; + +public interface Startable { + + public void start(); + + public void stop(); + + public interface TriggerAction { + + public void setTarget(Startable target); + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/datasource/StartableDataSource.java b/funf/src/main/java/edu/mit/media/funf/datasource/StartableDataSource.java new file mode 100644 index 0000000..0ecc75a --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/datasource/StartableDataSource.java @@ -0,0 +1,101 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.datasource; + +import com.google.gson.JsonElement; + +import edu.mit.media.funf.json.IJsonObject; +import edu.mit.media.funf.probe.Probe.DataListener; + +public class StartableDataSource implements Startable, DataSource { + + public static enum State { + OFF, + ON + }; + + protected State currentState = State.OFF; + + protected DataListener outputListener; + + protected DataListener delegator = new DataListener() { + + @Override + public void onDataReceived(IJsonObject probeConfig, IJsonObject data) { + if (outputListener != null) { + outputListener.onDataReceived(probeConfig, data); + } + } + + @Override + public void onDataCompleted(IJsonObject probeConfig, + JsonElement checkpoint) { + if (outputListener != null) { + outputListener.onDataCompleted(probeConfig, checkpoint); + } + } + }; + + public DataListener getDelegator() { + return delegator; + } + + @Override + public final void start() { + if (currentState == State.ON) + return; + currentState = State.ON; + onStart(); + } + + @Override + public final void stop() { + if (currentState == State.OFF) + return; + currentState = State.OFF; + onStop(); + } + + @Override + public void setListener(DataListener listener) { + this.outputListener = listener; + } + + protected void onStart() { + + } + + protected void onStop() { + + } +} diff --git a/src/edu/mit/media/funf/filter/CompositeFilter.java b/funf/src/main/java/edu/mit/media/funf/filter/CompositeFilter.java similarity index 57% rename from src/edu/mit/media/funf/filter/CompositeFilter.java rename to funf/src/main/java/edu/mit/media/funf/filter/CompositeFilter.java index 16624c5..f0b480b 100644 --- a/src/edu/mit/media/funf/filter/CompositeFilter.java +++ b/funf/src/main/java/edu/mit/media/funf/filter/CompositeFilter.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.filter; diff --git a/funf/src/main/java/edu/mit/media/funf/filter/KeyValueFilter.java b/funf/src/main/java/edu/mit/media/funf/filter/KeyValueFilter.java new file mode 100644 index 0000000..ad9c3a3 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/filter/KeyValueFilter.java @@ -0,0 +1,87 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.filter; + +import java.util.Map; + +import com.google.gson.JsonElement; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.datasource.DataSource; +import edu.mit.media.funf.json.IJsonObject; +import edu.mit.media.funf.probe.Probe.DataListener; + +public class KeyValueFilter implements DataListener, DataSource { + + @Configurable + private DataListener listener; + + @Configurable + private Map matches = null; + + KeyValueFilter() { + } + + public KeyValueFilter(DataListener listener) { + this.listener = listener; + } + + @Override + public void onDataReceived(IJsonObject probeConfig, IJsonObject data) { + if (listener == null) + return; + + if (matches != null) { + for (String key: matches.keySet()) { + if (data.has(key)) { + String dataValue = data.get(key).getAsString(); + if (dataValue.equals(matches.get(key))) { + listener.onDataReceived(probeConfig, data); + return; + } + } + } + } + } + + @Override + public void onDataCompleted(IJsonObject probeConfig, JsonElement checkpoint) { + listener.onDataCompleted(probeConfig, checkpoint); + } + + @Override + public void setListener(DataListener listener) { + this.listener = listener; + } + +} diff --git a/src/edu/mit/media/funf/filter/LocalTimeOfDayFilter.java b/funf/src/main/java/edu/mit/media/funf/filter/LocalTimeOfDayFilter.java similarity index 72% rename from src/edu/mit/media/funf/filter/LocalTimeOfDayFilter.java rename to funf/src/main/java/edu/mit/media/funf/filter/LocalTimeOfDayFilter.java index 1001e64..d477812 100644 --- a/src/edu/mit/media/funf/filter/LocalTimeOfDayFilter.java +++ b/funf/src/main/java/edu/mit/media/funf/filter/LocalTimeOfDayFilter.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.filter; diff --git a/src/edu/mit/media/funf/filter/ProbabilisticFilter.java b/funf/src/main/java/edu/mit/media/funf/filter/ProbabilisticFilter.java similarity index 57% rename from src/edu/mit/media/funf/filter/ProbabilisticFilter.java rename to funf/src/main/java/edu/mit/media/funf/filter/ProbabilisticFilter.java index e4312cc..c845c69 100644 --- a/src/edu/mit/media/funf/filter/ProbabilisticFilter.java +++ b/funf/src/main/java/edu/mit/media/funf/filter/ProbabilisticFilter.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.filter; diff --git a/src/edu/mit/media/funf/json/BundleTypeAdapter.java b/funf/src/main/java/edu/mit/media/funf/json/BundleTypeAdapter.java similarity index 51% rename from src/edu/mit/media/funf/json/BundleTypeAdapter.java rename to funf/src/main/java/edu/mit/media/funf/json/BundleTypeAdapter.java index 5f54d62..cfe5771 100644 --- a/src/edu/mit/media/funf/json/BundleTypeAdapter.java +++ b/funf/src/main/java/edu/mit/media/funf/json/BundleTypeAdapter.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.json; diff --git a/src/edu/mit/media/funf/json/IJsonArray.java b/funf/src/main/java/edu/mit/media/funf/json/IJsonArray.java similarity index 84% rename from src/edu/mit/media/funf/json/IJsonArray.java rename to funf/src/main/java/edu/mit/media/funf/json/IJsonArray.java index c873521..f55d039 100644 --- a/src/edu/mit/media/funf/json/IJsonArray.java +++ b/funf/src/main/java/edu/mit/media/funf/json/IJsonArray.java @@ -1,3 +1,35 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package edu.mit.media.funf.json; import java.math.BigDecimal; diff --git a/src/edu/mit/media/funf/json/IJsonObject.java b/funf/src/main/java/edu/mit/media/funf/json/IJsonObject.java similarity index 71% rename from src/edu/mit/media/funf/json/IJsonObject.java rename to funf/src/main/java/edu/mit/media/funf/json/IJsonObject.java index db0bbc4..58a99a8 100644 --- a/src/edu/mit/media/funf/json/IJsonObject.java +++ b/funf/src/main/java/edu/mit/media/funf/json/IJsonObject.java @@ -1,3 +1,35 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package edu.mit.media.funf.json; import java.util.Collections; diff --git a/src/edu/mit/media/funf/json/JsonUtils.java b/funf/src/main/java/edu/mit/media/funf/json/JsonUtils.java similarity index 74% rename from src/edu/mit/media/funf/json/JsonUtils.java rename to funf/src/main/java/edu/mit/media/funf/json/JsonUtils.java index 774c805..c94e93b 100644 --- a/src/edu/mit/media/funf/json/JsonUtils.java +++ b/funf/src/main/java/edu/mit/media/funf/json/JsonUtils.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.json; diff --git a/src/edu/mit/media/funf/math/FFT.java b/funf/src/main/java/edu/mit/media/funf/math/FFT.java similarity index 55% rename from src/edu/mit/media/funf/math/FFT.java rename to funf/src/main/java/edu/mit/media/funf/math/FFT.java index 2fa1629..56d3fd0 100644 --- a/src/edu/mit/media/funf/math/FFT.java +++ b/funf/src/main/java/edu/mit/media/funf/math/FFT.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.math; diff --git a/src/edu/mit/media/funf/math/MFCC.java b/funf/src/main/java/edu/mit/media/funf/math/MFCC.java similarity index 67% rename from src/edu/mit/media/funf/math/MFCC.java rename to funf/src/main/java/edu/mit/media/funf/math/MFCC.java index 6bb746f..8c14ed8 100644 --- a/src/edu/mit/media/funf/math/MFCC.java +++ b/funf/src/main/java/edu/mit/media/funf/math/MFCC.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.math; diff --git a/src/edu/mit/media/funf/math/Matrix.java b/funf/src/main/java/edu/mit/media/funf/math/Matrix.java similarity index 94% rename from src/edu/mit/media/funf/math/Matrix.java rename to funf/src/main/java/edu/mit/media/funf/math/Matrix.java index 21cbd9c..99b784e 100644 --- a/src/edu/mit/media/funf/math/Matrix.java +++ b/funf/src/main/java/edu/mit/media/funf/math/Matrix.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.math; diff --git a/funf/src/main/java/edu/mit/media/funf/math/Window.java b/funf/src/main/java/edu/mit/media/funf/math/Window.java new file mode 100644 index 0000000..eee7fc7 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/math/Window.java @@ -0,0 +1,60 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.math; + +public class Window +{ + public double[] window; + public int n; + + public Window(int windowSize) + { + n = windowSize; + + // Make a Hamming window + window = new double[n]; + for(int i = 0; i < n; i++) + { + window[i] = 0.54 - 0.46*Math.cos(2*Math.PI*(double)i/((double)n-1)); + } + } + + public void applyWindow(double[] buffer) + { + for (int i = 0; i < n; i ++) + { + buffer[i] *= window[i]; + } + } + +} diff --git a/src/edu/mit/media/funf/pipeline/BasicPipeline.java b/funf/src/main/java/edu/mit/media/funf/pipeline/BasicPipeline.java similarity index 83% rename from src/edu/mit/media/funf/pipeline/BasicPipeline.java rename to funf/src/main/java/edu/mit/media/funf/pipeline/BasicPipeline.java index 3e15cc4..6a82eb5 100644 --- a/src/edu/mit/media/funf/pipeline/BasicPipeline.java +++ b/funf/src/main/java/edu/mit/media/funf/pipeline/BasicPipeline.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.pipeline; diff --git a/funf/src/main/java/edu/mit/media/funf/pipeline/Pipeline.java b/funf/src/main/java/edu/mit/media/funf/pipeline/Pipeline.java new file mode 100644 index 0000000..f66e5e7 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/pipeline/Pipeline.java @@ -0,0 +1,69 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.pipeline; + +import com.google.gson.JsonElement; + +import edu.mit.media.funf.FunfManager; + + + +public interface Pipeline { + + /** + * Called once when the pipeline is created. This method can be used + * to register any scheduled operations. + * + * @param manager + */ + public void onCreate(FunfManager manager); + + /** + * Instructs pipeline to perform an operation. + * @param action The action to perform. + * @param config The object to perform the action on. + */ + public void onRun(String action, JsonElement config); // maybe intent, IJsonObject? + + /** + * The teardown method called once when the pipeline should shut down. + */ + public void onDestroy(); + + /** + * Returns true if this pipeline is enabled, meaning onCreate has been called + * and onDestroy has not yet been called. + */ + public boolean isEnabled(); + +} diff --git a/src/edu/mit/media/funf/pipeline/PipelineFactory.java b/funf/src/main/java/edu/mit/media/funf/pipeline/PipelineFactory.java similarity index 74% rename from src/edu/mit/media/funf/pipeline/PipelineFactory.java rename to funf/src/main/java/edu/mit/media/funf/pipeline/PipelineFactory.java index a7a5c60..5672793 100644 --- a/src/edu/mit/media/funf/pipeline/PipelineFactory.java +++ b/funf/src/main/java/edu/mit/media/funf/pipeline/PipelineFactory.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.pipeline; diff --git a/src/edu/mit/media/funf/probe/Probe.java b/funf/src/main/java/edu/mit/media/funf/probe/Probe.java similarity index 91% rename from src/edu/mit/media/funf/probe/Probe.java rename to funf/src/main/java/edu/mit/media/funf/probe/Probe.java index fb6f273..9cd9fb8 100644 --- a/src/edu/mit/media/funf/probe/Probe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/Probe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe; @@ -735,10 +744,8 @@ public void removeStateListener(StateListener listener) { ********************************/ /** - * Sensitive data is hidden by default - * This can not be changed by configuration alone - * If you uncomment this line please submit the change - * to funf@media.mit.edu in accordance with the LGPL license. * + * Sensitive data is hidden by default. + * This can not be changed by configuration alone. */ //@Configurable private boolean hideSensitiveData = true; diff --git a/src/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java similarity index 82% rename from src/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java index 6f71136..cfbddb4 100644 --- a/src/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java new file mode 100644 index 0000000..d5c771b --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java @@ -0,0 +1,55 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.probe.Probe.PassiveProbe; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.AccelerometerSensorKeys; + +@RequiredFeatures("android.hardware.sensor.accelerometer") +public class AccelerometerSensorProbe extends SensorProbe implements PassiveProbe, AccelerometerSensorKeys { + + @Override + public int getSensorType() { + return Sensor.TYPE_ACCELEROMETER; + } + + @Override + public String[] getValueNames() { + return new String[] { + X, Y, Z + }; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccountsProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccountsProbe.java new file mode 100644 index 0000000..915fbd5 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AccountsProbe.java @@ -0,0 +1,78 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import java.lang.reflect.Type; + +import android.accounts.Account; +import android.accounts.AccountManager; +import android.content.Context; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import edu.mit.media.funf.probe.Probe.RequiredPermissions; +import edu.mit.media.funf.probe.builtin.ProbeKeys.AccountsKeys; + +@RequiredPermissions(android.Manifest.permission.GET_ACCOUNTS) +public class AccountsProbe extends ImpulseProbe implements AccountsKeys { + + @Override + protected GsonBuilder getGsonBuilder() { + GsonBuilder builder = super.getGsonBuilder(); + builder.registerTypeAdapter(Account.class, new JsonSerializer() { + @Override + public JsonElement serialize(Account src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject account = new JsonObject(); + account.addProperty(NAME, sensitiveData(src.name)); + account.addProperty(TYPE, src.type); + return account; + } + }); + return builder; + } + + @Override + public void onStart() { + AccountManager am = (AccountManager)getContext().getSystemService(Context.ACCOUNT_SERVICE); + Gson gson = getGson(); + for (Account account : am.getAccounts()) { + sendData(gson.toJsonTree(account).getAsJsonObject()); + } + disable(); + } +} diff --git a/src/edu/mit/media/funf/probe/builtin/ActivityProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ActivityProbe.java similarity index 70% rename from src/edu/mit/media/funf/probe/builtin/ActivityProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ActivityProbe.java index e228eda..aa9d996 100644 --- a/src/edu/mit/media/funf/probe/builtin/ActivityProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ActivityProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/AlarmProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AlarmProbe.java similarity index 71% rename from src/edu/mit/media/funf/probe/builtin/AlarmProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/AlarmProbe.java index b7410ee..7b62b7d 100644 --- a/src/edu/mit/media/funf/probe/builtin/AlarmProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AlarmProbe.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java new file mode 100644 index 0000000..2727e14 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java @@ -0,0 +1,59 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.os.Build; + +import com.google.gson.JsonObject; + +import edu.mit.media.funf.probe.builtin.ProbeKeys.AndroidInfoKeys; + +public class AndroidInfoProbe extends ImpulseProbe implements AndroidInfoKeys { + + @Override + protected void onStart() { + super.onStart(); + JsonObject data = new JsonObject(); + data.addProperty(FIRMWARE_VERSION, Build.VERSION.RELEASE); + data.addProperty(BUILD_NUMBER, + Build.PRODUCT + "-" + Build.TYPE + + " " + Build.VERSION.RELEASE + + " " + Build.ID + + " " + Build.VERSION.INCREMENTAL + + " " + Build.TAGS); + data.addProperty(SDK, Integer.parseInt(Build.VERSION.SDK, 10)); + sendData(data); + stop(); + } + +} diff --git a/src/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java similarity index 69% rename from src/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java index e58d2e4..7b19957 100644 --- a/src/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/AudioCaptureProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioCaptureProbe.java similarity index 72% rename from src/edu/mit/media/funf/probe/builtin/AudioCaptureProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioCaptureProbe.java index dbecf1e..ab435a7 100644 --- a/src/edu/mit/media/funf/probe/builtin/AudioCaptureProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioCaptureProbe.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java similarity index 79% rename from src/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java index bd39df7..d532b62 100644 --- a/src/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java similarity index 59% rename from src/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java index c21182e..cb1e5e4 100644 --- a/src/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/BatteryProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BatteryProbe.java new file mode 100644 index 0000000..e1dd65d --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BatteryProbe.java @@ -0,0 +1,69 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.Base; +import edu.mit.media.funf.probe.Probe.PassiveProbe; +import edu.mit.media.funf.probe.Probe.RequiredPermissions; + +@Schedule.DefaultSchedule(interval=300) +@RequiredPermissions(android.Manifest.permission.BATTERY_STATS) +public class BatteryProbe extends Base implements PassiveProbe { + + private final BroadcastReceiver receiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { + sendData(getGson().toJsonTree(intent.getExtras()).getAsJsonObject()); + stop(); + } + } + }; + + @Override + protected void onStart() { + super.onStart(); + getContext().registerReceiver(receiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); + } + + @Override + protected void onStop() { + super.onStop(); + getContext().unregisterReceiver(receiver); + } +} diff --git a/src/edu/mit/media/funf/probe/builtin/BluetoothProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BluetoothProbe.java similarity index 68% rename from src/edu/mit/media/funf/probe/builtin/BluetoothProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/BluetoothProbe.java index 6f04989..0e02e10 100644 --- a/src/edu/mit/media/funf/probe/builtin/BluetoothProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BluetoothProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java new file mode 100644 index 0000000..d265bb2 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java @@ -0,0 +1,71 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import java.util.HashMap; +import java.util.Map; + +import android.net.Uri; +import android.provider.Browser; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.RequiredPermissions; + +@Schedule.DefaultSchedule(interval=604800) +@RequiredPermissions(android.Manifest.permission.READ_HISTORY_BOOKMARKS) +public class BrowserBookmarksProbe extends DatedContentProviderProbe { + + @Override + protected Uri getContentProviderUri() { + return Browser.BOOKMARKS_URI; + } + + @Override + protected String getDateColumnName() { + return Browser.BookmarkColumns.DATE; + } + + @Override + protected Map> getProjectionMap() { + Map> projectionKeyToType = new HashMap>(); + projectionKeyToType.put(Browser.BookmarkColumns._ID, intCell()); + projectionKeyToType.put(Browser.BookmarkColumns.TITLE, sensitiveStringCell()); + projectionKeyToType.put(Browser.BookmarkColumns.URL, sensitiveStringCell()); + projectionKeyToType.put(Browser.BookmarkColumns.VISITS, intCell()); + projectionKeyToType.put(Browser.BookmarkColumns.DATE, longCell()); + projectionKeyToType.put(Browser.BookmarkColumns.CREATED, longCell()); + projectionKeyToType.put(Browser.BookmarkColumns.BOOKMARK, intCell()); + //projectionKeyToType.put(Browser.BookmarkColumns.DESCRIPTION, hashedStringCell()); // TODO: Description doesn't exist + return projectionKeyToType; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java new file mode 100644 index 0000000..2a5350d --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java @@ -0,0 +1,66 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import java.util.HashMap; +import java.util.Map; + +import android.net.Uri; +import android.provider.Browser; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.RequiredPermissions; + +@Schedule.DefaultSchedule(interval=604800) +@RequiredPermissions(android.Manifest.permission.READ_HISTORY_BOOKMARKS) +public class BrowserSearchesProbe extends DatedContentProviderProbe { + + @Override + protected Uri getContentProviderUri() { + return Browser.SEARCHES_URI; + } + + @Override + protected String getDateColumnName() { + return Browser.SearchColumns.DATE; + } + + @Override + protected Map> getProjectionMap() { + Map> projectionKeyToType = new HashMap>(); + projectionKeyToType.put(Browser.SearchColumns._ID, intCell()); + projectionKeyToType.put(Browser.SearchColumns.SEARCH, sensitiveStringCell()); + projectionKeyToType.put(Browser.SearchColumns.DATE, longCell()); + return projectionKeyToType; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/CallLogProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/CallLogProbe.java new file mode 100644 index 0000000..4e04bb9 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/CallLogProbe.java @@ -0,0 +1,73 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import java.util.HashMap; +import java.util.Map; + +import android.net.Uri; +import android.provider.CallLog; +import android.provider.CallLog.Calls; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.RequiredPermissions; +import edu.mit.media.funf.probe.builtin.ContentProviderProbe.CursorCell.PhoneNumberCell; + +@Schedule.DefaultSchedule(interval=36000) +@RequiredPermissions(android.Manifest.permission.READ_CONTACTS) +public class CallLogProbe extends DatedContentProviderProbe { + + @Override + protected Uri getContentProviderUri() { + return CallLog.Calls.CONTENT_URI; + } + + @Override + protected String getDateColumnName() { + return Calls.DATE; + } + + @Override + protected Map> getProjectionMap() { + Map> projectionKeyToType = new HashMap>(); + projectionKeyToType.put(Calls._ID, intCell()); + projectionKeyToType.put(Calls.NUMBER, new SensitiveCell(new PhoneNumberCell())); + projectionKeyToType.put(Calls.DATE, longCell()); + projectionKeyToType.put(Calls.TYPE, intCell()); + projectionKeyToType.put(Calls.DURATION, longCell()); + projectionKeyToType.put(Calls.CACHED_NAME, sensitiveStringCell()); + projectionKeyToType.put(Calls.CACHED_NUMBER_LABEL, sensitiveStringCell()); + projectionKeyToType.put(Calls.CACHED_NUMBER_TYPE, sensitiveStringCell()); + return projectionKeyToType; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/CellTowerProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/CellTowerProbe.java new file mode 100644 index 0000000..6473c55 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/CellTowerProbe.java @@ -0,0 +1,77 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.content.Context; +import android.os.Bundle; +import android.telephony.CellLocation; +import android.telephony.TelephonyManager; +import android.telephony.cdma.CdmaCellLocation; +import android.telephony.gsm.GsmCellLocation; +import edu.mit.media.funf.probe.Probe.Base; +import edu.mit.media.funf.probe.Probe.DisplayName; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.Probe.RequiredPermissions; +import edu.mit.media.funf.probe.builtin.ProbeKeys.CellKeys; + +@DisplayName("Nearby Cellular Towers Probe") +@RequiredFeatures("android.hardware.telephony") +@RequiredPermissions(android.Manifest.permission.ACCESS_COARSE_LOCATION) +public class CellTowerProbe extends Base implements CellKeys { + + @Override + protected void onStart() { + super.onStart(); + sendData(getGson().toJsonTree(getData()).getAsJsonObject()); + stop(); + } + + private Bundle getData() { + TelephonyManager manager = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE); + CellLocation location = manager.getCellLocation(); + Bundle data = new Bundle(); + if (location instanceof GsmCellLocation) { + GsmCellLocation gsmLocation = (GsmCellLocation) location; + gsmLocation.fillInNotifierBundle(data); + data.putInt(TYPE, TelephonyManager.PHONE_TYPE_GSM); + } else if (location instanceof CdmaCellLocation) { + CdmaCellLocation cdmaLocation = (CdmaCellLocation) location; + cdmaLocation.fillInNotifierBundle(data); + data.putInt(TYPE, TelephonyManager.PHONE_TYPE_CDMA); + } else { + data.putInt(TYPE, TelephonyManager.PHONE_TYPE_NONE); + } + return data; + } + +} diff --git a/src/edu/mit/media/funf/probe/builtin/ContactProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ContactProbe.java similarity index 89% rename from src/edu/mit/media/funf/probe/builtin/ContactProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ContactProbe.java index 1cc0df5..cd03743 100644 --- a/src/edu/mit/media/funf/probe/builtin/ContactProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ContactProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java similarity index 83% rename from src/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java index 644fa9a..1799dab 100644 --- a/src/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java similarity index 60% rename from src/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java index dd096c2..4bebd50 100644 --- a/src/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java similarity index 54% rename from src/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java index db846f1..4de0d6b 100644 --- a/src/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Funf: Open Sensing Framework diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java new file mode 100644 index 0000000..52eb9d8 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java @@ -0,0 +1,66 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.GyroscopeSensorKeys; + +/** + * Measures angular speed around each axis. + * + * All values are in radians/second and measure the rate of rotation around the X, Y and Z axis. + * The coordinate system is the same as is used for the acceleration sensor. + * Rotation is positive in the counter-clockwise direction. That is, an observer looking from some positive location on the x, y. or z axis at a device positioned on the origin would report positive rotation if the device appeared to be rotating counter clockwise. + * Note that this is the standard mathematical definition of positive rotation and does not agree with the definition of roll given earlier. + * + * Android Reference http://developer.android.com/reference/android/hardware/SensorEvent.html + */ +@Description("Measures angular speed around each axis.") +@Schedule.DefaultSchedule(interval=1800, duration = 60) +@RequiredFeatures("android.hardware.sensor.gyroscope") +public class GyroscopeSensorProbe extends SensorProbe implements GyroscopeSensorKeys { + + public int getSensorType() { + return Sensor.TYPE_GYROSCOPE; + } + + public String[] getValueNames() { + return new String[] { + X, Y, Z + }; + } + +} diff --git a/src/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java similarity index 50% rename from src/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java index ec5f1fa..8cfcad2 100644 --- a/src/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/ImageCaptureProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ImageCaptureProbe.java similarity index 80% rename from src/edu/mit/media/funf/probe/builtin/ImageCaptureProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ImageCaptureProbe.java index 7a1e937..646e1ac 100644 --- a/src/edu/mit/media/funf/probe/builtin/ImageCaptureProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ImageCaptureProbe.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java similarity index 53% rename from src/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java index b17069e..d0a0c36 100644 --- a/src/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/ImpulseProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ImpulseProbe.java similarity index 60% rename from src/edu/mit/media/funf/probe/builtin/ImpulseProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ImpulseProbe.java index 469da00..a165b63 100644 --- a/src/edu/mit/media/funf/probe/builtin/ImpulseProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ImpulseProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/LightSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/LightSensorProbe.java new file mode 100644 index 0000000..b087068 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/LightSensorProbe.java @@ -0,0 +1,52 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.LightSensorKeys; + +@Schedule.DefaultSchedule(interval=300, duration=SensorProbe.DEFAULT_DURATION) +@RequiredFeatures("android.hardware.sensor.light") +public class LightSensorProbe extends SensorProbe implements LightSensorKeys { + + public int getSensorType() { + return Sensor.TYPE_LIGHT; + } + public String[] getValueNames() { + return new String[] { + LUX + }; + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java new file mode 100644 index 0000000..b18239a --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java @@ -0,0 +1,60 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.LinearAccelerationSensorKeys; + +/** + * Records a three dimensional vector indicating acceleration along each device axis, not including gravity. All values have units of m/s^2. The coordinate system is the same as is used by the acceleration sensor. + * The output of the accelerometer, gravity and linear-acceleration sensors obey the following relation: + * acceleration = gravity + linear-acceleration + * + * Android Reference http://developer.android.com/reference/android/hardware/SensorEvent.html + * + */ +@Description("Records a three dimensional vector indicating acceleration along each device axis, not including gravity.") +@RequiredFeatures({"android.hardware.sensor.accelerometer","android.hardware.sensor.gyroscope"}) +public class LinearAccelerationSensorProbe extends SensorProbe implements LinearAccelerationSensorKeys { + + public int getSensorType() { + return 10; //SensorKeys.TYPE_LINEAR_ACCELERATION; // API Level 9 + } + + public String[] getValueNames() { + return new String[] { + X, Y, Z + }; + } +} diff --git a/src/edu/mit/media/funf/probe/builtin/LocationProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/LocationProbe.java similarity index 74% rename from src/edu/mit/media/funf/probe/builtin/LocationProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/LocationProbe.java index 8a7b224..23bc815 100644 --- a/src/edu/mit/media/funf/probe/builtin/LocationProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/LocationProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java new file mode 100644 index 0000000..517d1b0 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java @@ -0,0 +1,53 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.MagneticFieldSensorKeys; + +@Description("Records a three dimensional vector of the magnetic field.") +@RequiredFeatures("android.hardware.sensor.compass") +public class MagneticFieldSensorProbe extends SensorProbe implements MagneticFieldSensorKeys { + + public int getSensorType() { + return Sensor.TYPE_MAGNETIC_FIELD; + } + public String[] getValueNames() { + return new String[] { + X, Y, Z + }; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java new file mode 100644 index 0000000..493b5a8 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java @@ -0,0 +1,56 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.OrientationSensorKeys; + +@Description("Records a three dimensional vector of the magnetic field.") +@RequiredFeatures("android.hardware.sensor.gyroscope") +@Schedule.DefaultSchedule(interval=180, duration=15) +public class OrientationSensorProbe extends SensorProbe implements OrientationSensorKeys { + + public int getSensorType() { + return Sensor.TYPE_ORIENTATION; + } + + public String[] getValueNames() { + return new String[] { + AZIMUTH, PITCH, ROLL + }; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java new file mode 100644 index 0000000..446c4fb --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java @@ -0,0 +1,52 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.builtin.ProbeKeys.PressureSensorKeys; + +@Description("Records a three dimensional vector of the magnetic field.") +//@RequiredFeatures("android.hardware.sensor.barometer") // varies +public class PressureSensorProbe extends SensorProbe implements PressureSensorKeys { + + public int getSensorType() { + return Sensor.TYPE_PRESSURE; + } + + public String[] getValueNames() { + return new String[] { + PRESSURE + }; + } +} diff --git a/src/edu/mit/media/funf/probe/builtin/ProbeKeys.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ProbeKeys.java similarity index 88% rename from src/edu/mit/media/funf/probe/builtin/ProbeKeys.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ProbeKeys.java index 153d3ca..4ef2116 100644 --- a/src/edu/mit/media/funf/probe/builtin/ProbeKeys.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ProbeKeys.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java similarity index 85% rename from src/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java index 1dd00e7..37de90f 100644 --- a/src/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java new file mode 100644 index 0000000..d4eee5e --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java @@ -0,0 +1,61 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.ProximitySensorKeys; + + +/** + * Returns sensor distance in centimeters or only a binary near/far measurement + * If binary, will return 0 or max range as defined by Sensor.getMaximumRange(). + * + */ +@Description("Returns sensor distance in centimeters or only a binary near/far measurement.") +@RequiredFeatures("android.hardware.sensor.proximity") +@Schedule.DefaultSchedule(interval=300, duration=15) +public class ProximitySensorProbe extends SensorProbe implements ProximitySensorKeys { + + public int getSensorType() { + return Sensor.TYPE_PROXIMITY; + } + + public String[] getValueNames() { + return new String[] { + DISTANCE + }; + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java new file mode 100644 index 0000000..bc62799 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java @@ -0,0 +1,55 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.Probe.RequiredFeatures; +import edu.mit.media.funf.probe.builtin.ProbeKeys.RotationVectorSensorKeys; + +@Description("Returns sensor distance in centimeters or only a binary near/far measurement.") +@RequiredFeatures("android.hardware.sensor.gyroscope") +@Schedule.DefaultSchedule(interval=300, duration=15) +public class RotationVectorSensorProbe extends SensorProbe implements RotationVectorSensorKeys { + + public int getSensorType() { + return 11; //SensorKeys.TYPE_ROTATION_VECTOR; // API Level 9 + } + + public String[] getValueNames() { + return new String[] { + X_SIN_THETA_OVER_2, Y_SIN_THETA_OVER_2, Z_SIN_THETA_OVER_2, COS_THETA_OVER_2 + }; + } + +} diff --git a/src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java similarity index 75% rename from src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java index a55d1ab..6611255 100644 --- a/src/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/ScreenProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ScreenProbe.java similarity index 51% rename from src/edu/mit/media/funf/probe/builtin/ScreenProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/ScreenProbe.java index 59b91ab..2edd345 100644 --- a/src/edu/mit/media/funf/probe/builtin/ScreenProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ScreenProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/SensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SensorProbe.java similarity index 71% rename from src/edu/mit/media/funf/probe/builtin/SensorProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/SensorProbe.java index 00b45f9..d7bea21 100644 --- a/src/edu/mit/media/funf/probe/builtin/SensorProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SensorProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/ServicesProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ServicesProbe.java new file mode 100644 index 0000000..524bc62 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/ServicesProbe.java @@ -0,0 +1,72 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import java.util.Arrays; +import java.util.List; + +import android.app.ActivityManager; +import android.app.ActivityManager.RunningServiceInfo; +import android.content.Context; + +import com.google.gson.Gson; + +import edu.mit.media.funf.config.Configurable; +import edu.mit.media.funf.probe.Probe.Base; +import edu.mit.media.funf.probe.builtin.ProbeKeys.ServicesKeys; + +public class ServicesProbe extends Base implements ServicesKeys { + + /** + * The array of packages from which service info will be emitted. + * If this parameter is null, will return every service. + */ + @Configurable + private String[] packages = null; + + @Override + protected void onStart() { + super.onStart(); + Gson gson = getGson(); + ActivityManager am = (ActivityManager)getContext().getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE); + List packageList = packages == null ? null : Arrays.asList(packages); + for (RunningServiceInfo info : am.getRunningServices(Integer.MAX_VALUE)) { + String packageName = info.service.getPackageName(); + if (packageList == null || packageList.contains(packageName)) { + sendData(gson.toJsonTree(info).getAsJsonObject()); + } + } + stop(); + } + +} diff --git a/src/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java similarity index 75% rename from src/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java index 971084f..ba098d5 100644 --- a/src/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/SimpleProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SimpleProbe.java new file mode 100644 index 0000000..f3f3039 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SimpleProbe.java @@ -0,0 +1,67 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import com.google.gson.GsonBuilder; +import com.google.gson.JsonSerializer; + +import edu.mit.media.funf.probe.Probe.Base; + +public abstract class SimpleProbe extends Base { + + // TODO: possibly integrate this into base, so that both impulse and continuous probes can make use of it + + @Override + protected GsonBuilder getGsonBuilder() { + GsonBuilder builder = super.getGsonBuilder(); + JsonSerializer serializer = getSerializer(); + if (serializer != null) { + builder.registerTypeAdapter(getClass().getGenericInterfaces()[0], serializer); + } + return builder; + } + + protected void sendData(T data) { + sendData(getGson().toJsonTree(data).getAsJsonObject()); + } + + /** + * Used to override the default serialization technique for the object + * @return + */ + protected JsonSerializer getSerializer() { + return null; + } + + +} diff --git a/src/edu/mit/media/funf/probe/builtin/SmsProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SmsProbe.java similarity index 54% rename from src/edu/mit/media/funf/probe/builtin/SmsProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/SmsProbe.java index b84267c..87ca6dc 100644 --- a/src/edu/mit/media/funf/probe/builtin/SmsProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/SmsProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/TelephonyProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/TelephonyProbe.java similarity index 58% rename from src/edu/mit/media/funf/probe/builtin/TelephonyProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/TelephonyProbe.java index 5205629..0a229c7 100644 --- a/src/edu/mit/media/funf/probe/builtin/TelephonyProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/TelephonyProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/funf/src/main/java/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java new file mode 100644 index 0000000..95e297d --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java @@ -0,0 +1,60 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.probe.builtin; + +import android.hardware.Sensor; +import edu.mit.media.funf.Schedule; +import edu.mit.media.funf.probe.Probe.Description; +import edu.mit.media.funf.probe.builtin.ProbeKeys.TemperatureSensorKeys; + +/** + * Used to record temperature. Implementation depends on the device and does not exist on all devices. + * Some will record temperature of battery, others temperature of CPU or environment. + * + */ +@Description("Returns sensor distance in centimeters or only a binary near/far measurement.") +//@RequiredFeatures("android.hardware.sensor.temperature") // doesn't exist yet +@Schedule.DefaultSchedule(interval=1200, duration=10) +public class TemperatureSensorProbe extends SensorProbe implements TemperatureSensorKeys { + + public int getSensorType() { + return Sensor.TYPE_TEMPERATURE; + } + + public String[] getValueNames() { + return new String[] { + TEMPERATURE + }; + } + +} diff --git a/src/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java similarity index 63% rename from src/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java index 247703b..4225e69 100644 --- a/src/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/VideoCaptureProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/VideoCaptureProbe.java similarity index 87% rename from src/edu/mit/media/funf/probe/builtin/VideoCaptureProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/VideoCaptureProbe.java index dfb63f2..45cc818 100644 --- a/src/edu/mit/media/funf/probe/builtin/VideoCaptureProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/VideoCaptureProbe.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java similarity index 58% rename from src/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java index 0c9f4ab..1a45f89 100644 --- a/src/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/probe/builtin/WifiProbe.java b/funf/src/main/java/edu/mit/media/funf/probe/builtin/WifiProbe.java similarity index 75% rename from src/edu/mit/media/funf/probe/builtin/WifiProbe.java rename to funf/src/main/java/edu/mit/media/funf/probe/builtin/WifiProbe.java index 5007be5..188671a 100644 --- a/src/edu/mit/media/funf/probe/builtin/WifiProbe.java +++ b/funf/src/main/java/edu/mit/media/funf/probe/builtin/WifiProbe.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.probe.builtin; diff --git a/src/edu/mit/media/funf/security/Base64Coder.java b/funf/src/main/java/edu/mit/media/funf/security/Base64Coder.java similarity index 84% rename from src/edu/mit/media/funf/security/Base64Coder.java rename to funf/src/main/java/edu/mit/media/funf/security/Base64Coder.java index 279df30..1262c91 100644 --- a/src/edu/mit/media/funf/security/Base64Coder.java +++ b/funf/src/main/java/edu/mit/media/funf/security/Base64Coder.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.security; // Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland diff --git a/src/edu/mit/media/funf/security/HashUtil.java b/funf/src/main/java/edu/mit/media/funf/security/HashUtil.java similarity index 62% rename from src/edu/mit/media/funf/security/HashUtil.java rename to funf/src/main/java/edu/mit/media/funf/security/HashUtil.java index ef6a48c..51315fe 100644 --- a/src/edu/mit/media/funf/security/HashUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/security/HashUtil.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.security; diff --git a/funf/src/main/java/edu/mit/media/funf/security/MD5.java b/funf/src/main/java/edu/mit/media/funf/security/MD5.java new file mode 100644 index 0000000..e5feac2 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/security/MD5.java @@ -0,0 +1,67 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.security; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class MD5 { + + private static String convertToHex(byte[] data) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < data.length; i++) { + int halfbyte = (data[i] >>> 4) & 0x0F; + int two_halfs = 0; + do { + if ((0 <= halfbyte) && (halfbyte <= 9)) + buf.append((char) ('0' + halfbyte)); + else + buf.append((char) ('a' + (halfbyte - 10))); + halfbyte = data[i] & 0x0F; + } while(two_halfs++ < 1); + } + return buf.toString(); + } + + public static String MD5Digest(String text) + throws NoSuchAlgorithmException, UnsupportedEncodingException { + MessageDigest md; + md = MessageDigest.getInstance("MD5"); + byte[] md5hash = new byte[32]; + md.update(text.getBytes("iso-8859-1"), 0, text.length()); + md5hash = md.digest(); + return convertToHex(md5hash); + } +} + \ No newline at end of file diff --git a/src/edu/mit/media/funf/security/RSAEncode.java b/funf/src/main/java/edu/mit/media/funf/security/RSAEncode.java similarity index 61% rename from src/edu/mit/media/funf/security/RSAEncode.java rename to funf/src/main/java/edu/mit/media/funf/security/RSAEncode.java index 8ee1f79..b4c5009 100644 --- a/src/edu/mit/media/funf/security/RSAEncode.java +++ b/funf/src/main/java/edu/mit/media/funf/security/RSAEncode.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // using /res/raw/pub.enc as the RSA Public Key package edu.mit.media.funf.security; diff --git a/funf/src/main/java/edu/mit/media/funf/storage/BackedUpArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/BackedUpArchive.java new file mode 100644 index 0000000..8acc83a --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/storage/BackedUpArchive.java @@ -0,0 +1,75 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.storage; + +import java.io.File; + +/** + * Delegates all actions to archive. Adds an item to the backup archive before removing from the archive. + * It is up to the backup archive to determine when those items will remove themselves. + * + */ +public class BackedUpArchive implements FileArchive { + + private final FileArchive archive, backupArchive; + + public BackedUpArchive(FileArchive archive, FileArchive backupArchive) { + this.archive = archive; + this.backupArchive = backupArchive; + } + + @Override + public boolean add(File item) { + return archive.add(item); + } + + @Override + public File[] getAll() { + return archive.getAll(); + } + + @Override + public boolean contains(File item) { + return archive.contains(item); + } + + @Override + public boolean remove(File item) { + if (archive.contains(item)) { + backupArchive.add(item); + } + return archive.remove(item); + } + + +} diff --git a/funf/src/main/java/edu/mit/media/funf/storage/CompositeFileArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/CompositeFileArchive.java new file mode 100644 index 0000000..8e886e0 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/storage/CompositeFileArchive.java @@ -0,0 +1,97 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.storage; + +import java.io.File; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * Attempts to use the first archive. If that fails, continues down the list until a successful archive is reached. + * + */ +public class CompositeFileArchive implements FileArchive { + + private final FileArchive[] archives; + + public CompositeFileArchive(FileArchive... archives) { + this.archives = archives; + } + + @Override + public boolean add(File item) { + // Add to archive one by one, until one is successful or archives are exhausted. + for (FileArchive archive : archives) { + if(archive.add(item)) { + return true; + } + } + return false; + } + + @Override + public File[] getAll() { + // Merge files from all archives, ignoring duplicates + Set fileSet = new HashSet(); + for (FileArchive archive : archives) { + fileSet.addAll(Arrays.asList(archive.getAll())); + } + File[] files = new File[fileSet.size()]; + fileSet.toArray(files); + return files; + } + + @Override + public boolean remove(File item) { + // Remove on every archive, returning true if at least one was successful + boolean success = false; + for (FileArchive archive : archives) { + if(archive.remove(item)) { + success = true; + } + } + return success; + } + + @Override + public boolean contains(File item) { + for (FileArchive archive : archives) { + if (archive.contains(item)) { + return true; + } + } + return false; + } + +} diff --git a/src/edu/mit/media/funf/storage/DefaultArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/DefaultArchive.java similarity index 76% rename from src/edu/mit/media/funf/storage/DefaultArchive.java rename to funf/src/main/java/edu/mit/media/funf/storage/DefaultArchive.java index afad56d..7c308f0 100644 --- a/src/edu/mit/media/funf/storage/DefaultArchive.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/DefaultArchive.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/src/edu/mit/media/funf/storage/DirectoryCleaner.java b/funf/src/main/java/edu/mit/media/funf/storage/DirectoryCleaner.java similarity index 72% rename from src/edu/mit/media/funf/storage/DirectoryCleaner.java rename to funf/src/main/java/edu/mit/media/funf/storage/DirectoryCleaner.java index 51bd3b5..48d6b73 100644 --- a/src/edu/mit/media/funf/storage/DirectoryCleaner.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/DirectoryCleaner.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/funf/src/main/java/edu/mit/media/funf/storage/FileArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/FileArchive.java new file mode 100644 index 0000000..c6a57d6 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/storage/FileArchive.java @@ -0,0 +1,71 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.storage; + +import java.io.File; + + +/** + * Responsible for storing a representation of the object. + */ +public interface FileArchive { + + /** + * Adds the item to the archive + * @param item + * @return true if archive was successful + */ + public boolean add(File item); + + /** + * Removes the item from the archive if it exists + * @param item + * @return true if item exists in archive and was successfully removed + */ + public boolean remove(File item); + + /** + * @param item + * @return true if item exists in archive + */ + public boolean contains(File item); + + + /** + * @return All items in the archive + */ + public File[] getAll(); + + + +} \ No newline at end of file diff --git a/src/edu/mit/media/funf/storage/FileCopier.java b/funf/src/main/java/edu/mit/media/funf/storage/FileCopier.java similarity index 68% rename from src/edu/mit/media/funf/storage/FileCopier.java rename to funf/src/main/java/edu/mit/media/funf/storage/FileCopier.java index 9f48ae7..7626ab5 100644 --- a/src/edu/mit/media/funf/storage/FileCopier.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/FileCopier.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/src/edu/mit/media/funf/storage/FileDirectoryArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/FileDirectoryArchive.java similarity index 57% rename from src/edu/mit/media/funf/storage/FileDirectoryArchive.java rename to funf/src/main/java/edu/mit/media/funf/storage/FileDirectoryArchive.java index 82474bf..c05f265 100644 --- a/src/edu/mit/media/funf/storage/FileDirectoryArchive.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/FileDirectoryArchive.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/src/edu/mit/media/funf/storage/HttpArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/HttpArchive.java similarity index 78% rename from src/edu/mit/media/funf/storage/HttpArchive.java rename to funf/src/main/java/edu/mit/media/funf/storage/HttpArchive.java index 9a497af..125612e 100644 --- a/src/edu/mit/media/funf/storage/HttpArchive.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/HttpArchive.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/src/edu/mit/media/funf/storage/LargeFileArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/LargeFileArchive.java similarity index 62% rename from src/edu/mit/media/funf/storage/LargeFileArchive.java rename to funf/src/main/java/edu/mit/media/funf/storage/LargeFileArchive.java index 2334a77..aacd367 100644 --- a/src/edu/mit/media/funf/storage/LargeFileArchive.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/LargeFileArchive.java @@ -1,27 +1,34 @@ /** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/src/edu/mit/media/funf/storage/NameValueDatabaseHelper.java b/funf/src/main/java/edu/mit/media/funf/storage/NameValueDatabaseHelper.java similarity index 68% rename from src/edu/mit/media/funf/storage/NameValueDatabaseHelper.java rename to funf/src/main/java/edu/mit/media/funf/storage/NameValueDatabaseHelper.java index d1fd52c..37e134b 100644 --- a/src/edu/mit/media/funf/storage/NameValueDatabaseHelper.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/NameValueDatabaseHelper.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/funf/src/main/java/edu/mit/media/funf/storage/RemoteFileArchive.java b/funf/src/main/java/edu/mit/media/funf/storage/RemoteFileArchive.java new file mode 100644 index 0000000..e8d5b14 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/storage/RemoteFileArchive.java @@ -0,0 +1,61 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.storage; + +import java.io.File; + +/** + * Interface for representing file archives that are not on the device. + * + */ +public interface RemoteFileArchive { + + /** + * Synchronously add the file to the remote archive + * @param file the File to upload + * @return true if successfully added, false otherwise + */ + public boolean add(File file); + + /** + * @return true if this remote archive is available currently + */ + public boolean isAvailable(); + + /** + * A unique string that represents this remote archive. These will mostly be URIs, + * but implementation is dependent on implementation. + * @return + */ + public String getId(); +} diff --git a/src/edu/mit/media/funf/storage/UploadService.java b/funf/src/main/java/edu/mit/media/funf/storage/UploadService.java similarity index 70% rename from src/edu/mit/media/funf/storage/UploadService.java rename to funf/src/main/java/edu/mit/media/funf/storage/UploadService.java index 8e7cb72..11ea170 100644 --- a/src/edu/mit/media/funf/storage/UploadService.java +++ b/funf/src/main/java/edu/mit/media/funf/storage/UploadService.java @@ -1,21 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.storage; diff --git a/src/edu/mit/media/funf/time/DecimalTimeUnit.java b/funf/src/main/java/edu/mit/media/funf/time/DecimalTimeUnit.java similarity index 84% rename from src/edu/mit/media/funf/time/DecimalTimeUnit.java rename to funf/src/main/java/edu/mit/media/funf/time/DecimalTimeUnit.java index bcbcf02..19b4489 100644 --- a/src/edu/mit/media/funf/time/DecimalTimeUnit.java +++ b/funf/src/main/java/edu/mit/media/funf/time/DecimalTimeUnit.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.time; diff --git a/src/edu/mit/media/funf/time/NtpMessage.java b/funf/src/main/java/edu/mit/media/funf/time/NtpMessage.java similarity index 89% rename from src/edu/mit/media/funf/time/NtpMessage.java rename to funf/src/main/java/edu/mit/media/funf/time/NtpMessage.java index 2465e11..256675a 100644 --- a/src/edu/mit/media/funf/time/NtpMessage.java +++ b/funf/src/main/java/edu/mit/media/funf/time/NtpMessage.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.time; diff --git a/src/edu/mit/media/funf/time/TimeUnit.java b/funf/src/main/java/edu/mit/media/funf/time/TimeUnit.java similarity index 91% rename from src/edu/mit/media/funf/time/TimeUnit.java rename to funf/src/main/java/edu/mit/media/funf/time/TimeUnit.java index acb58de..8ec5aba 100644 --- a/src/edu/mit/media/funf/time/TimeUnit.java +++ b/funf/src/main/java/edu/mit/media/funf/time/TimeUnit.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.time; /* diff --git a/src/edu/mit/media/funf/time/TimeUtil.java b/funf/src/main/java/edu/mit/media/funf/time/TimeUtil.java similarity index 64% rename from src/edu/mit/media/funf/time/TimeUtil.java rename to funf/src/main/java/edu/mit/media/funf/time/TimeUtil.java index 1a1b5e1..6cd6432 100644 --- a/src/edu/mit/media/funf/time/TimeUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/time/TimeUtil.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.time; diff --git a/src/edu/mit/media/funf/util/AnnotationUtil.java b/funf/src/main/java/edu/mit/media/funf/util/AnnotationUtil.java similarity index 53% rename from src/edu/mit/media/funf/util/AnnotationUtil.java rename to funf/src/main/java/edu/mit/media/funf/util/AnnotationUtil.java index 18b4e42..ff4f786 100644 --- a/src/edu/mit/media/funf/util/AnnotationUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/util/AnnotationUtil.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/funf/src/main/java/edu/mit/media/funf/util/ArrayUtil.java b/funf/src/main/java/edu/mit/media/funf/util/ArrayUtil.java new file mode 100644 index 0000000..6093026 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/util/ArrayUtil.java @@ -0,0 +1,58 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.util; + +public class ArrayUtil { + + public ArrayUtil() { + + } + + + + /** + * Convenience function for concatenating two arrays + * @param + * @param first + * @param second + * @return + */ + @SuppressWarnings("unchecked") + public static T[] concat(T[] first, T[] second) { + T[] result = (T[])new Object[first.length + second.length]; + System.arraycopy(first, 0, result, 0, first.length); + System.arraycopy(second, 0, result, first.length, second.length); + return result; + } + +} diff --git a/src/edu/mit/media/funf/util/AsyncSharedPrefs.java b/funf/src/main/java/edu/mit/media/funf/util/AsyncSharedPrefs.java similarity index 87% rename from src/edu/mit/media/funf/util/AsyncSharedPrefs.java rename to funf/src/main/java/edu/mit/media/funf/util/AsyncSharedPrefs.java index 1697bbd..f8e4913 100644 --- a/src/edu/mit/media/funf/util/AsyncSharedPrefs.java +++ b/funf/src/main/java/edu/mit/media/funf/util/AsyncSharedPrefs.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/src/edu/mit/media/funf/util/BundleUtil.java b/funf/src/main/java/edu/mit/media/funf/util/BundleUtil.java similarity index 55% rename from src/edu/mit/media/funf/util/BundleUtil.java rename to funf/src/main/java/edu/mit/media/funf/util/BundleUtil.java index 4cb8e2f..9af90d5 100644 --- a/src/edu/mit/media/funf/util/BundleUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/util/BundleUtil.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/src/edu/mit/media/funf/util/CameraUtil.java b/funf/src/main/java/edu/mit/media/funf/util/CameraUtil.java similarity index 72% rename from src/edu/mit/media/funf/util/CameraUtil.java rename to funf/src/main/java/edu/mit/media/funf/util/CameraUtil.java index 8912964..0aec7b5 100644 --- a/src/edu/mit/media/funf/util/CameraUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/util/CameraUtil.java @@ -1,23 +1,34 @@ /** - * - * Funf: Open Sensing Framework Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/src/edu/mit/media/funf/util/EqualsUtil.java b/funf/src/main/java/edu/mit/media/funf/util/EqualsUtil.java similarity index 73% rename from src/edu/mit/media/funf/util/EqualsUtil.java rename to funf/src/main/java/edu/mit/media/funf/util/EqualsUtil.java index b98fb59..b440608 100644 --- a/src/edu/mit/media/funf/util/EqualsUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/util/EqualsUtil.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/src/edu/mit/media/funf/util/FileUtil.java b/funf/src/main/java/edu/mit/media/funf/util/FileUtil.java similarity index 77% rename from src/edu/mit/media/funf/util/FileUtil.java rename to funf/src/main/java/edu/mit/media/funf/util/FileUtil.java index e91184e..3b9b129 100644 --- a/src/edu/mit/media/funf/util/FileUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/util/FileUtil.java @@ -1,21 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/src/edu/mit/media/funf/util/HashCodeUtil.java b/funf/src/main/java/edu/mit/media/funf/util/HashCodeUtil.java similarity index 61% rename from src/edu/mit/media/funf/util/HashCodeUtil.java rename to funf/src/main/java/edu/mit/media/funf/util/HashCodeUtil.java index dfbdd8b..c30f247 100644 --- a/src/edu/mit/media/funf/util/HashCodeUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/util/HashCodeUtil.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/src/edu/mit/media/funf/util/IOUtil.java b/funf/src/main/java/edu/mit/media/funf/util/IOUtil.java similarity index 68% rename from src/edu/mit/media/funf/util/IOUtil.java rename to funf/src/main/java/edu/mit/media/funf/util/IOUtil.java index 6d4ecb3..18d0c37 100644 --- a/src/edu/mit/media/funf/util/IOUtil.java +++ b/funf/src/main/java/edu/mit/media/funf/util/IOUtil.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Funf: Open Sensing Framework diff --git a/funf/src/main/java/edu/mit/media/funf/util/LockUtil.java b/funf/src/main/java/edu/mit/media/funf/util/LockUtil.java new file mode 100644 index 0000000..32b2ba3 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/util/LockUtil.java @@ -0,0 +1,51 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.util; + +import android.content.Context; +import android.os.PowerManager; + +public class LockUtil { + + public static PowerManager.WakeLock getWakeLock(Context context) { + return LockUtil.getWakeLock(context, context.getClass().getName()); + } + + public static PowerManager.WakeLock getWakeLock(Context context, String tag) { + PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); + PowerManager.WakeLock lock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, tag); + lock.acquire(); + return lock; + } + +} diff --git a/funf/src/main/java/edu/mit/media/funf/util/LogUtil.java b/funf/src/main/java/edu/mit/media/funf/util/LogUtil.java new file mode 100644 index 0000000..5fc9486 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/util/LogUtil.java @@ -0,0 +1,43 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.util; + +public class LogUtil { + + public static final String TAG = "Funf"; + + private LogUtil() { + + } + +} diff --git a/src/edu/mit/media/funf/util/NameGenerator.java b/funf/src/main/java/edu/mit/media/funf/util/NameGenerator.java similarity index 64% rename from src/edu/mit/media/funf/util/NameGenerator.java rename to funf/src/main/java/edu/mit/media/funf/util/NameGenerator.java index 12fc740..819e6b4 100644 --- a/src/edu/mit/media/funf/util/NameGenerator.java +++ b/funf/src/main/java/edu/mit/media/funf/util/NameGenerator.java @@ -1,25 +1,34 @@ /** - * - * 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 . - * + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package edu.mit.media.funf.util; diff --git a/funf/src/main/java/edu/mit/media/funf/util/StringUtil.java b/funf/src/main/java/edu/mit/media/funf/util/StringUtil.java new file mode 100644 index 0000000..b9b32a7 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/util/StringUtil.java @@ -0,0 +1,71 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.util; + +import java.util.Collection; +import java.util.Iterator; + +public class StringUtil { + + private StringUtil() { + + } + + + /** + * Convenience function for joining strings using a delimeter + * @param strings + * @param delimeter + * @return + */ + public static String join(final Collection strings, String delimeter) { + if (delimeter == null) { + delimeter = ","; + } + if (strings.isEmpty()) { + return ""; + } + StringBuffer joined = new StringBuffer(); + Iterator stringIter = strings.iterator(); + joined.append(stringIter.next().toString()); + while (stringIter.hasNext()) { + joined.append(delimeter); + joined.append(stringIter.next().toString()); + } + return joined.toString(); + } + + public static String simpleFilesafe(String value) { + return value == null ? "" : value.replaceAll("[^a-zA-Z0-9-_\\.]", "_").toLowerCase(); + } +} diff --git a/funf/src/main/java/edu/mit/media/funf/util/UuidUtil.java b/funf/src/main/java/edu/mit/media/funf/util/UuidUtil.java new file mode 100644 index 0000000..dceca84 --- /dev/null +++ b/funf/src/main/java/edu/mit/media/funf/util/UuidUtil.java @@ -0,0 +1,60 @@ +/** + * BSD 3-Clause License + * + * Copyright (c) 2010-2012, MIT + * Copyright (c) 2012-2016, Nadav Aharony, Alan Gardner, and Cody Sumter + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package edu.mit.media.funf.util; + +import static edu.mit.media.funf.util.AsyncSharedPrefs.async; + +import java.util.UUID; + +import android.content.Context; +import android.content.SharedPreferences; + +public class UuidUtil { + + public static String getInstallationId(Context context) { + if (UuidUtil.uuid == null) { + SharedPreferences prefs = async(context.getSharedPreferences(UuidUtil.FUNF_UTILS_PREFS, Context.MODE_PRIVATE)); + UuidUtil.uuid = prefs.getString(UuidUtil.INSTALLATION_UUID_KEY, null); + if (UuidUtil.uuid == null) { + UuidUtil.uuid = UUID.randomUUID().toString(); + prefs.edit().putString(UuidUtil.INSTALLATION_UUID_KEY, UuidUtil.uuid).commit(); + } + } + return UuidUtil.uuid; + } + + public static String uuid = null; + public static final String INSTALLATION_UUID_KEY = "INSTALLATION_UUID"; + public static final String FUNF_UTILS_PREFS = "edu.mit.media.funf.Utils"; + +} diff --git a/funf/src/main/res/values/strings.xml b/funf/src/main/res/values/strings.xml new file mode 100644 index 0000000..a5fba12 --- /dev/null +++ b/funf/src/main/res/values/strings.xml @@ -0,0 +1,35 @@ + + + + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae 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..04e285f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Dec 28 10:00:20 PST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/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..255cf31 --- /dev/null +++ b/import-summary.txt @@ -0,0 +1,325 @@ +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: + +* .gitignore +* .idea/ +* .idea/compiler.xml +* .idea/copyright/ +* .idea/copyright/profiles_settings.xml +* .idea/misc.xml +* .idea/workspace.xml +* README.md +* ant.properties +* app/ +* app/build.gradle +* app/lint.xml +* app/src/ +* app/src/main/ +* app/src/main/AndroidManifest.xml +* app/src/main/java/ +* app/src/main/java/com/ +* app/src/main/java/com/google/ +* app/src/main/java/com/google/gson/ +* app/src/main/java/com/google/gson/internal/ +* app/src/main/java/com/google/gson/internal/bind/ +* app/src/main/java/com/google/gson/internal/bind/JsonTreeReader.java +* app/src/main/java/com/google/gson/internal/bind/JsonTreeWriter.java +* app/src/main/java/edu/ +* app/src/main/java/edu/mit/ +* app/src/main/java/edu/mit/media/ +* app/src/main/java/edu/mit/media/funf/ +* app/src/main/java/edu/mit/media/funf/FunfManager.java +* app/src/main/java/edu/mit/media/funf/Launcher.java +* app/src/main/java/edu/mit/media/funf/Schedule.java +* app/src/main/java/edu/mit/media/funf/action/ +* app/src/main/java/edu/mit/media/funf/action/Action.java +* app/src/main/java/edu/mit/media/funf/action/ActionAdapter.java +* app/src/main/java/edu/mit/media/funf/action/RunArchiveAction.java +* app/src/main/java/edu/mit/media/funf/action/RunUpdateAction.java +* app/src/main/java/edu/mit/media/funf/action/RunUploadAction.java +* app/src/main/java/edu/mit/media/funf/action/StartDataSourceAction.java +* app/src/main/java/edu/mit/media/funf/action/StartableAction.java +* app/src/main/java/edu/mit/media/funf/action/StopDataSourceAction.java +* app/src/main/java/edu/mit/media/funf/action/WriteDataAction.java +* app/src/main/java/edu/mit/media/funf/config/ +* app/src/main/java/edu/mit/media/funf/config/ConfigRewriteUtil.java +* app/src/main/java/edu/mit/media/funf/config/ConfigUpdater.java +* app/src/main/java/edu/mit/media/funf/config/Configurable.java +* app/src/main/java/edu/mit/media/funf/config/ConfigurableTypeAdapterFactory.java +* app/src/main/java/edu/mit/media/funf/config/ContextInjectorTypeAdapaterFactory.java +* app/src/main/java/edu/mit/media/funf/config/DefaultRuntimeTypeAdapterFactory.java +* app/src/main/java/edu/mit/media/funf/config/DefaultScheduleSerializer.java +* app/src/main/java/edu/mit/media/funf/config/HttpConfigUpdater.java +* app/src/main/java/edu/mit/media/funf/config/ListenerInjectorTypeAdapterFactory.java +* app/src/main/java/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java +* app/src/main/java/edu/mit/media/funf/config/SingletonTypeAdapterFactory.java +* app/src/main/java/edu/mit/media/funf/data/ +* app/src/main/java/edu/mit/media/funf/data/DataNormalizer.java +* app/src/main/java/edu/mit/media/funf/datasource/ +* app/src/main/java/edu/mit/media/funf/datasource/CompositeDataSource.java +* app/src/main/java/edu/mit/media/funf/datasource/DataSource.java +* app/src/main/java/edu/mit/media/funf/datasource/ProbeDataSource.java +* app/src/main/java/edu/mit/media/funf/datasource/Startable.java +* app/src/main/java/edu/mit/media/funf/datasource/StartableDataSource.java +* app/src/main/java/edu/mit/media/funf/filter/ +* app/src/main/java/edu/mit/media/funf/filter/CompositeFilter.java +* app/src/main/java/edu/mit/media/funf/filter/KeyValueFilter.java +* app/src/main/java/edu/mit/media/funf/filter/LocalTimeOfDayFilter.java +* app/src/main/java/edu/mit/media/funf/filter/ProbabilisticFilter.java +* app/src/main/java/edu/mit/media/funf/json/ +* app/src/main/java/edu/mit/media/funf/json/BundleTypeAdapter.java +* app/src/main/java/edu/mit/media/funf/json/IJsonArray.java +* app/src/main/java/edu/mit/media/funf/json/IJsonObject.java +* app/src/main/java/edu/mit/media/funf/json/JsonUtils.java +* app/src/main/java/edu/mit/media/funf/math/ +* app/src/main/java/edu/mit/media/funf/math/FFT.java +* app/src/main/java/edu/mit/media/funf/math/MFCC.java +* app/src/main/java/edu/mit/media/funf/math/Matrix.java +* app/src/main/java/edu/mit/media/funf/math/Window.java +* app/src/main/java/edu/mit/media/funf/pipeline/ +* app/src/main/java/edu/mit/media/funf/pipeline/BasicPipeline.java +* app/src/main/java/edu/mit/media/funf/pipeline/Pipeline.java +* app/src/main/java/edu/mit/media/funf/pipeline/PipelineFactory.java +* app/src/main/java/edu/mit/media/funf/probe/ +* app/src/main/java/edu/mit/media/funf/probe/Probe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ +* app/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerFeaturesProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/AccountsProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ActivityProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/AlarmProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ApplicationsProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/AudioCaptureProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/AudioFeaturesProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/AudioMediaProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/BatteryProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/BluetoothProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/CallLogProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/CellTowerProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ContactProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ContentProviderProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/DatedContentProviderProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/GravitySensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/HardwareInfoProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ImageCaptureProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ImageMediaProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ImpulseProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/LightSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/LocationProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ProbeKeys.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ProcessStatisticsProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/RunningApplicationsProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ScreenProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/SensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/ServicesProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/SimpleLocationProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/SimpleProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/SmsProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/TelephonyProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/TimeOffsetProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/VideoCaptureProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/VideoMediaProbe.java +* app/src/main/java/edu/mit/media/funf/probe/builtin/WifiProbe.java +* app/src/main/java/edu/mit/media/funf/security/ +* app/src/main/java/edu/mit/media/funf/security/Base64Coder.java +* app/src/main/java/edu/mit/media/funf/security/HashUtil.java +* app/src/main/java/edu/mit/media/funf/security/MD5.java +* app/src/main/java/edu/mit/media/funf/security/RSAEncode.java +* app/src/main/java/edu/mit/media/funf/storage/ +* app/src/main/java/edu/mit/media/funf/storage/BackedUpArchive.java +* app/src/main/java/edu/mit/media/funf/storage/CompositeFileArchive.java +* app/src/main/java/edu/mit/media/funf/storage/DefaultArchive.java +* app/src/main/java/edu/mit/media/funf/storage/DirectoryCleaner.java +* app/src/main/java/edu/mit/media/funf/storage/FileArchive.java +* app/src/main/java/edu/mit/media/funf/storage/FileCopier.java +* app/src/main/java/edu/mit/media/funf/storage/FileDirectoryArchive.java +* app/src/main/java/edu/mit/media/funf/storage/HttpArchive.java +* app/src/main/java/edu/mit/media/funf/storage/LargeFileArchive.java +* app/src/main/java/edu/mit/media/funf/storage/NameValueDatabaseHelper.java +* app/src/main/java/edu/mit/media/funf/storage/RemoteFileArchive.java +* app/src/main/java/edu/mit/media/funf/storage/UploadService.java +* app/src/main/java/edu/mit/media/funf/time/ +* app/src/main/java/edu/mit/media/funf/time/DecimalTimeUnit.java +* app/src/main/java/edu/mit/media/funf/time/NtpMessage.java +* app/src/main/java/edu/mit/media/funf/time/TimeUnit.java +* app/src/main/java/edu/mit/media/funf/time/TimeUtil.java +* app/src/main/java/edu/mit/media/funf/util/ +* app/src/main/java/edu/mit/media/funf/util/AnnotationUtil.java +* app/src/main/java/edu/mit/media/funf/util/ArrayUtil.java +* app/src/main/java/edu/mit/media/funf/util/AsyncSharedPrefs.java +* app/src/main/java/edu/mit/media/funf/util/BundleUtil.java +* app/src/main/java/edu/mit/media/funf/util/CameraUtil.java +* app/src/main/java/edu/mit/media/funf/util/EqualsUtil.java +* app/src/main/java/edu/mit/media/funf/util/FileUtil.java +* app/src/main/java/edu/mit/media/funf/util/HashCodeUtil.java +* app/src/main/java/edu/mit/media/funf/util/IOUtil.java +* app/src/main/java/edu/mit/media/funf/util/LockUtil.java +* app/src/main/java/edu/mit/media/funf/util/LogUtil.java +* app/src/main/java/edu/mit/media/funf/util/NameGenerator.java +* app/src/main/java/edu/mit/media/funf/util/StringUtil.java +* app/src/main/java/edu/mit/media/funf/util/UuidUtil.java +* app/src/main/res/ +* app/src/main/res/values/ +* app/src/main/res/values/strings.xml +* app/src/main/resources/ +* app/src/main/resources/edu/ +* app/src/main/resources/edu/mit/ +* app/src/main/resources/edu/mit/media/ +* app/src/main/resources/edu/mit/media/funf/ +* app/src/main/resources/edu/mit/media/funf/probe/ +* app/src/main/resources/edu/mit/media/funf/probe/.DS_Store +* build.gradle +* build.xml +* custom_rules.xml +* default.properties +* gradle/ +* gradle/wrapper/ +* gradle/wrapper/gradle-wrapper.jar +* gradle/wrapper/gradle-wrapper.properties +* gradlew +* gradlew.bat +* proguard-project.txt +* proguard.cfg +* settings.gradle +* 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/res/values/ +* test/res/values/strings.xml +* 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 + +Replaced Jars with Dependencies: +-------------------------------- +The importer recognized the following .jar files as third party +libraries and replaced them with Gradle dependencies instead. This has +the advantage that more explicit version information is known, and the +libraries can be updated automatically. However, it is possible that +the .jar file in your project was of an older version than the +dependency we picked, which could render the project not compileable. +You can disable the jar replacement in the import wizard and try again: + +gson-2.1-javadoc.jar => com.google.code.gson:gson:2.3.1 +gson-2.1-sources.jar => com.google.code.gson:gson:2.3.1 +gson-2.1.jar => com.google.code.gson:gson:2.1 + +Potentially Missing Dependency: +------------------------------- +When we replaced the following .jar files with a Gradle dependency, we +inferred the dependency version number from the filename. This +specific version may not actually be available from the repository. +If you get a build error stating that the dependency is missing, edit +the version number to for example "+" to pick up the latest version +instead. (This may require you to update your code if the library APIs +have changed.) + +gson-2.1.jar => version 2.1 in com.google.code.gson:gson:2.1 + +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 +* lint.xml => app/lint.xml +* res/ => app/src/main/res/ +* src/ => app/src/main/java/ +* 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-javadoc.jar b/libs/gson-2.1-javadoc.jar deleted file mode 100644 index 4924a4d..0000000 Binary files a/libs/gson-2.1-javadoc.jar and /dev/null differ diff --git a/libs/gson-2.1-sources.jar b/libs/gson-2.1-sources.jar deleted file mode 100644 index 74598c2..0000000 Binary files a/libs/gson-2.1-sources.jar and /dev/null differ diff --git a/libs/gson-2.1.jar b/libs/gson-2.1.jar deleted file mode 100644 index aa1d28e..0000000 Binary files a/libs/gson-2.1.jar and /dev/null differ 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/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/res/values/strings.xml b/res/values/strings.xml deleted file mode 100644 index 8c335aa..0000000 --- a/res/values/strings.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..d3d63dd --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':funf' diff --git a/src/edu/mit/media/funf/Launcher.java b/src/edu/mit/media/funf/Launcher.java deleted file mode 100644 index b53ff82..0000000 --- a/src/edu/mit/media/funf/Launcher.java +++ /dev/null @@ -1,29 +0,0 @@ -package edu.mit.media.funf; - -import static edu.mit.media.funf.util.LogUtil.TAG; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.util.Log; - -public class Launcher extends BroadcastReceiver { - - private static boolean launched = false; - - public static void launch(Context context) { - Log.v(TAG, "Launched!"); - Intent i = new Intent(context.getApplicationContext(), FunfManager.class); - context.getApplicationContext().startService(i); - launched = true; - } - - public static boolean isLaunched() { - return launched; - } - - @Override - public void onReceive(Context context, Intent intent) { - launch(context); - } - -} diff --git a/src/edu/mit/media/funf/action/ActionAdapter.java b/src/edu/mit/media/funf/action/ActionAdapter.java deleted file mode 100644 index 6e73aad..0000000 --- a/src/edu/mit/media/funf/action/ActionAdapter.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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.action; - -import com.google.gson.JsonElement; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.datasource.Startable.TriggerAction; -import edu.mit.media.funf.json.IJsonObject; -import edu.mit.media.funf.probe.Probe.DataListener; - -public class ActionAdapter implements DataListener { - - @Configurable - private Action target = null; - - ActionAdapter() { - } - - public ActionAdapter(Action action) { - this.target = action; - } - - public ActionAdapter(TriggerAction action) { - this.target = (Action)action; - } - - @Override - public void onDataReceived(IJsonObject dataSourceConfig, IJsonObject data) { - if (target != null) { - target.run(); - } - } - - @Override - public void onDataCompleted(IJsonObject dataSourceConfig, JsonElement checkpoint) { - } - -} diff --git a/src/edu/mit/media/funf/action/RunArchiveAction.java b/src/edu/mit/media/funf/action/RunArchiveAction.java deleted file mode 100644 index f7c2c9b..0000000 --- a/src/edu/mit/media/funf/action/RunArchiveAction.java +++ /dev/null @@ -1,46 +0,0 @@ -package edu.mit.media.funf.action; - -import java.io.File; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.storage.FileArchive; -import edu.mit.media.funf.util.LogUtil; - -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; -import android.util.Log; - -public class RunArchiveAction extends Action { - - @Configurable - private FileArchive archive = null; - - @Configurable - private SQLiteOpenHelper dbHelper = null; - - RunArchiveAction() { - } - - public RunArchiveAction(FileArchive archive, SQLiteOpenHelper dbHelper) { - this.archive = archive; - this.dbHelper = dbHelper; - } - - protected void execute() { - Log.d(LogUtil.TAG, "running archive"); - SQLiteDatabase db = dbHelper.getWritableDatabase(); - // TODO: add check to make sure this is not empty - File dbFile = new File(db.getPath()); - db.close(); - if (archive.add(dbFile)) { - dbFile.delete(); - } - dbHelper.getWritableDatabase(); // Build new database - Log.d(LogUtil.TAG, "archived!"); - setHandler(null); // free system resources - } - - protected boolean isLongRunningAction() { - return true; - } -} diff --git a/src/edu/mit/media/funf/action/RunUpdateAction.java b/src/edu/mit/media/funf/action/RunUpdateAction.java deleted file mode 100644 index 4fdf68e..0000000 --- a/src/edu/mit/media/funf/action/RunUpdateAction.java +++ /dev/null @@ -1,43 +0,0 @@ -package edu.mit.media.funf.action; - -import edu.mit.media.funf.FunfManager; -import edu.mit.media.funf.config.ConfigUpdater; -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.util.LogUtil; - -import android.util.Log; - -public class RunUpdateAction extends Action { - - @Configurable - private String name = null; - - @Configurable - private FunfManager manager = null; - - @Configurable - protected ConfigUpdater update = null; - - RunUpdateAction() { - } - - public RunUpdateAction(String name, FunfManager manager, ConfigUpdater update) { - this.name = name; - this.manager = manager; - this.update = update; - } - - protected void execute() { - if (name != null && manager != null && update != null) { - Log.d(LogUtil.TAG, "running update"); - update.run(name, manager); - } else { - Log.d(LogUtil.TAG, "update failed"); - } - setHandler(null); // free system resources - } - - protected boolean isLongRunningAction() { - return true; - } -} diff --git a/src/edu/mit/media/funf/action/RunUploadAction.java b/src/edu/mit/media/funf/action/RunUploadAction.java deleted file mode 100644 index 322af01..0000000 --- a/src/edu/mit/media/funf/action/RunUploadAction.java +++ /dev/null @@ -1,43 +0,0 @@ -package edu.mit.media.funf.action; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.storage.FileArchive; -import edu.mit.media.funf.storage.RemoteFileArchive; -import edu.mit.media.funf.storage.UploadService; -import edu.mit.media.funf.util.LogUtil; - -import android.util.Log; - -public class RunUploadAction extends Action { - - @Configurable - private FileArchive archive = null; - - @Configurable - private RemoteFileArchive upload = null; - - private UploadService uploader; - - RunUploadAction() { - } - - public RunUploadAction(FileArchive archive, RemoteFileArchive upload, UploadService uploader) { - this.archive = archive; - this.upload = upload; - this.uploader = uploader; - } - - protected void execute() { - if (archive != null && upload != null && uploader != null) { - Log.d(LogUtil.TAG, "running upload"); - uploader.run(archive, upload); - } else { - Log.d(LogUtil.TAG, "upload failed"); - } - setHandler(null); // free system resources - } - - protected boolean isLongRunningAction() { - return true; - } -} \ No newline at end of file diff --git a/src/edu/mit/media/funf/action/StartDataSourceAction.java b/src/edu/mit/media/funf/action/StartDataSourceAction.java deleted file mode 100644 index a6d91a6..0000000 --- a/src/edu/mit/media/funf/action/StartDataSourceAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package edu.mit.media.funf.action; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.datasource.Startable; -import edu.mit.media.funf.datasource.Startable.TriggerAction; -import edu.mit.media.funf.util.LogUtil; -import android.util.Log; - -public class StartDataSourceAction extends Action implements TriggerAction { - - @Configurable - private Startable target = null; - - StartDataSourceAction() { - } - - public void setTarget(Startable target) { - this.target = target; - } - - protected void execute() { - if (target == null) - return; - Log.d(LogUtil.TAG, "running probe action start"); - target.start(); - } -} diff --git a/src/edu/mit/media/funf/action/StartableAction.java b/src/edu/mit/media/funf/action/StartableAction.java deleted file mode 100644 index 0e0facf..0000000 --- a/src/edu/mit/media/funf/action/StartableAction.java +++ /dev/null @@ -1,45 +0,0 @@ -package edu.mit.media.funf.action; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.datasource.Startable; -import edu.mit.media.funf.datasource.Startable.TriggerAction; -import edu.mit.media.funf.time.TimeUtil; -import edu.mit.media.funf.util.LogUtil; -import android.util.Log; - -public class StartableAction extends Action implements TriggerAction { - - @Configurable - private Double duration = null; - - @Configurable - private Startable target = null; - - StartableAction() { - } - - public void setTarget(Startable target) { - this.target = target; - } - - protected void execute() { - if (target == null) - return; - Log.d(LogUtil.TAG, "running action start"); - Log.d(LogUtil.TAG, target.getClass().getName()); - target.start(); - if (duration != null && duration > 0.0) { - getHandler().postDelayed(new Runnable() { - @Override - public void run() { - Log.d(LogUtil.TAG, "running action stop"); - target.stop(); - } - }, TimeUtil.secondsToMillis(duration)); - } - } - - protected boolean isLongRunningAction() { - return true; - } -} diff --git a/src/edu/mit/media/funf/action/StopDataSourceAction.java b/src/edu/mit/media/funf/action/StopDataSourceAction.java deleted file mode 100644 index 8872e52..0000000 --- a/src/edu/mit/media/funf/action/StopDataSourceAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package edu.mit.media.funf.action; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.datasource.Startable; -import edu.mit.media.funf.datasource.Startable.TriggerAction; -import edu.mit.media.funf.util.LogUtil; -import android.util.Log; - -public class StopDataSourceAction extends Action implements TriggerAction { - - @Configurable - private Startable target = null; - - StopDataSourceAction() { - } - - public void setTarget(Startable target) { - this.target = target; - } - - protected void execute() { - if (target == null) - return; - Log.d(LogUtil.TAG, "running probe action stop"); - target.stop(); - } -} diff --git a/src/edu/mit/media/funf/config/ConfigUpdater.java b/src/edu/mit/media/funf/config/ConfigUpdater.java deleted file mode 100644 index f4ff145..0000000 --- a/src/edu/mit/media/funf/config/ConfigUpdater.java +++ /dev/null @@ -1,53 +0,0 @@ -package edu.mit.media.funf.config; - -import android.util.Log; - -import com.google.gson.JsonObject; - -import edu.mit.media.funf.FunfManager; -import edu.mit.media.funf.util.EqualsUtil; -import edu.mit.media.funf.util.LogUtil; - -public abstract class ConfigUpdater { - - - public void run(String name, FunfManager mgr) { - JsonObject oldConfig = mgr.getPipelineConfig(name); - try { - JsonObject newConfig = getConfig(); - if (!EqualsUtil.areEqual(oldConfig, newConfig)) { - mgr.saveAndReload(name, newConfig); - } - } catch (ConfigUpdateException e) { - Log.w(LogUtil.TAG, "Unable to get config", e); - } - } - - abstract protected JsonObject getConfig() throws ConfigUpdateException; - - - - - - public class ConfigUpdateException extends Exception { - - private static final long serialVersionUID = 7595505577357891121L; - - public ConfigUpdateException() { - super(); - } - - public ConfigUpdateException(String detailMessage, Throwable throwable) { - super(detailMessage, throwable); - } - - public ConfigUpdateException(String detailMessage) { - super(detailMessage); - } - - public ConfigUpdateException(Throwable throwable) { - super(throwable); - } - - } -} diff --git a/src/edu/mit/media/funf/config/Configurable.java b/src/edu/mit/media/funf/config/Configurable.java deleted file mode 100644 index a98779c..0000000 --- a/src/edu/mit/media/funf/config/Configurable.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.config; - -import static java.lang.annotation.ElementType.FIELD; -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; - -/** - * Used to indicate that a particular field is configurable. The name of the - * field will be used as the configuration name, and the default value will be - * calculated by creating an instance with no config and inspecting what value - * gets created. - * - */ -@Documented -@Retention(RUNTIME) -@Target(FIELD) -@Inherited -public @interface Configurable { - /** - * @return Overrides the field name, if specified. - */ - String name() default ""; -} \ No newline at end of file diff --git a/src/edu/mit/media/funf/config/DefaultScheduleSerializer.java b/src/edu/mit/media/funf/config/DefaultScheduleSerializer.java deleted file mode 100644 index eca64f0..0000000 --- a/src/edu/mit/media/funf/config/DefaultScheduleSerializer.java +++ /dev/null @@ -1,73 +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.config; - -import java.lang.reflect.Type; -import java.util.Arrays; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import edu.mit.media.funf.Schedule.DefaultSchedule; - -public class DefaultScheduleSerializer implements JsonSerializer { - - private static final String - VALUE = "value", - INTERVAL = "interval", - DURATION = "duration", - OPPORTUNISTIC = "opportunistic", - STRICT = "strict"; - - static { - // Ensure expected methods exist - for (String methodName : Arrays.asList(VALUE, INTERVAL, DURATION, OPPORTUNISTIC, STRICT)) { - try { - DefaultSchedule.class.getMethod(methodName); - } catch (SecurityException e) { - throw new RuntimeException("Default schedule does not have expected accessible method."); - } catch (NoSuchMethodException e) { - throw new RuntimeException("Default schedule does not have expected accessible method.", e); - } - } - } - - @Override - public JsonElement serialize(DefaultSchedule src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject jsonObject = new JsonObject(); - // TODO: figure out what to do with value - if (!"".equals(src.value())) { - jsonObject.addProperty(VALUE, src.value()); - } - jsonObject.addProperty(RuntimeTypeAdapterFactory.TYPE, src.type().getName()); - jsonObject.addProperty(INTERVAL, src.interval()); - jsonObject.addProperty(DURATION, src.duration()); - jsonObject.addProperty(OPPORTUNISTIC, src.opportunistic()); - jsonObject.addProperty(STRICT, src.strict()); - return jsonObject; - } - -} diff --git a/src/edu/mit/media/funf/config/HttpConfigUpdater.java b/src/edu/mit/media/funf/config/HttpConfigUpdater.java deleted file mode 100644 index 4ed3f06..0000000 --- a/src/edu/mit/media/funf/config/HttpConfigUpdater.java +++ /dev/null @@ -1,45 +0,0 @@ -package edu.mit.media.funf.config; - -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; - -import edu.mit.media.funf.util.IOUtil; - -/** - * ConfigUpdater which does an Http get to the given url. - * - */ -public class HttpConfigUpdater extends ConfigUpdater { - - @Configurable - private String url; - - @Override - public JsonObject getConfig() throws ConfigUpdateException { - try { - String content = null; - if (IOUtil.isValidUrl(url)) { - content = IOUtil.httpGet(url, null); - } - if (content == null) { - throw new ConfigUpdateException("Unable to download configuration."); - } - return new JsonParser().parse(content).getAsJsonObject(); - } catch (JsonSyntaxException e) { - throw new ConfigUpdateException("Bad json in configuration.", e); - } catch (IllegalStateException e) { - throw new ConfigUpdateException("Bad json in configuration.", e); - } - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - -} diff --git a/src/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java b/src/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java deleted file mode 100644 index 37add27..0000000 --- a/src/edu/mit/media/funf/config/RuntimeTypeAdapterFactory.java +++ /dev/null @@ -1,35 +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.config; - -import com.google.gson.JsonElement; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -public interface RuntimeTypeAdapterFactory extends TypeAdapterFactory { - - public static final String TYPE = "@type"; - - public Class getRuntimeType(final JsonElement el, final TypeToken type); -} diff --git a/src/edu/mit/media/funf/data/DataNormalizer.java b/src/edu/mit/media/funf/data/DataNormalizer.java deleted file mode 100644 index 2047a02..0000000 --- a/src/edu/mit/media/funf/data/DataNormalizer.java +++ /dev/null @@ -1,52 +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.data; - -public interface DataNormalizer { - - public T normalize(T data); - - public class EmailNormalizer implements DataNormalizer { - - @Override - public String normalize(String data) { - return data == null ? null : data.trim().toLowerCase(); - } - - } - - public class PhoneNumberNormalizer implements DataNormalizer { - - @Override - public String normalize(String numberString) { - numberString = numberString.replaceAll("[^0-9]",""); - int i = numberString.length(); - if (i <= 10) - return numberString; - else - return numberString.substring(i - 10); - } - - } -} diff --git a/src/edu/mit/media/funf/datasource/CompositeDataSource.java b/src/edu/mit/media/funf/datasource/CompositeDataSource.java deleted file mode 100644 index c3a64c0..0000000 --- a/src/edu/mit/media/funf/datasource/CompositeDataSource.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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.datasource; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.probe.Probe.DataListener; - -public class CompositeDataSource extends StartableDataSource { - - @Configurable - protected StartableDataSource source = null; - - @Configurable - protected DataListener filter = null; - - @Configurable - private boolean isEnabled = false; - - CompositeDataSource() { - } - - protected void ensureIsEnabled() { - if (!isEnabled) { - if (filter == null) { - filter = delegator; - } - source.setListener(filter); - isEnabled = true; - } - } - - @Override - protected void onStart() { - ensureIsEnabled(); - source.start(); - } - - @Override - protected void onStop() { - source.stop(); - } -} diff --git a/src/edu/mit/media/funf/datasource/DataSource.java b/src/edu/mit/media/funf/datasource/DataSource.java deleted file mode 100644 index 06b2203..0000000 --- a/src/edu/mit/media/funf/datasource/DataSource.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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.datasource; - -import edu.mit.media.funf.probe.Probe.DataListener; - -public interface DataSource { - - public void setListener(DataListener listener); -} diff --git a/src/edu/mit/media/funf/datasource/ProbeDataSource.java b/src/edu/mit/media/funf/datasource/ProbeDataSource.java deleted file mode 100644 index d663228..0000000 --- a/src/edu/mit/media/funf/datasource/ProbeDataSource.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 - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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.datasource; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.probe.Probe; -import edu.mit.media.funf.probe.Probe.ContinuousProbe; - -public class ProbeDataSource extends StartableDataSource { - - @Configurable - protected Probe source; - - ProbeDataSource() { - } - - @Override - protected void onStart() { - source.registerListener(delegator); - } - - @Override - protected void onStop() { - if (source instanceof ContinuousProbe) { - ((ContinuousProbe) source).unregisterListener(delegator); - } - } -} diff --git a/src/edu/mit/media/funf/datasource/Startable.java b/src/edu/mit/media/funf/datasource/Startable.java deleted file mode 100644 index 11fb5cb..0000000 --- a/src/edu/mit/media/funf/datasource/Startable.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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.datasource; - -public interface Startable { - - public void start(); - - public void stop(); - - public interface TriggerAction { - - public void setTarget(Startable target); - } -} diff --git a/src/edu/mit/media/funf/datasource/StartableDataSource.java b/src/edu/mit/media/funf/datasource/StartableDataSource.java deleted file mode 100644 index c5107df..0000000 --- a/src/edu/mit/media/funf/datasource/StartableDataSource.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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.datasource; - -import com.google.gson.JsonElement; - -import edu.mit.media.funf.json.IJsonObject; -import edu.mit.media.funf.probe.Probe.DataListener; - -public class StartableDataSource implements Startable, DataSource { - - public static enum State { - OFF, - ON - }; - - protected State currentState = State.OFF; - - protected DataListener outputListener; - - protected DataListener delegator = new DataListener() { - - @Override - public void onDataReceived(IJsonObject probeConfig, IJsonObject data) { - if (outputListener != null) { - outputListener.onDataReceived(probeConfig, data); - } - } - - @Override - public void onDataCompleted(IJsonObject probeConfig, - JsonElement checkpoint) { - if (outputListener != null) { - outputListener.onDataCompleted(probeConfig, checkpoint); - } - } - }; - - public DataListener getDelegator() { - return delegator; - } - - @Override - public final void start() { - if (currentState == State.ON) - return; - currentState = State.ON; - onStart(); - } - - @Override - public final void stop() { - if (currentState == State.OFF) - return; - currentState = State.OFF; - onStop(); - } - - @Override - public void setListener(DataListener listener) { - this.outputListener = listener; - } - - protected void onStart() { - - } - - protected void onStop() { - - } -} diff --git a/src/edu/mit/media/funf/filter/KeyValueFilter.java b/src/edu/mit/media/funf/filter/KeyValueFilter.java deleted file mode 100644 index 563b9e7..0000000 --- a/src/edu/mit/media/funf/filter/KeyValueFilter.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * - * Funf: Open Sensing Framework - * Copyright (C) 2010-2011 Nadav Aharony, Wei Pan, Alex Pentland. - * Acknowledgments: Alan Gardner - * Contact: nadav@media.mit.edu - * - * Author(s): Pararth Shah (pararthshah717@gmail.com) - * - * 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.filter; - -import java.util.Map; - -import com.google.gson.JsonElement; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.datasource.DataSource; -import edu.mit.media.funf.json.IJsonObject; -import edu.mit.media.funf.probe.Probe.DataListener; - -public class KeyValueFilter implements DataListener, DataSource { - - @Configurable - private DataListener listener; - - @Configurable - private Map matches = null; - - KeyValueFilter() { - } - - public KeyValueFilter(DataListener listener) { - this.listener = listener; - } - - @Override - public void onDataReceived(IJsonObject probeConfig, IJsonObject data) { - if (listener == null) - return; - - if (matches != null) { - for (String key: matches.keySet()) { - if (data.has(key)) { - String dataValue = data.get(key).getAsString(); - if (dataValue.equals(matches.get(key))) { - listener.onDataReceived(probeConfig, data); - return; - } - } - } - } - } - - @Override - public void onDataCompleted(IJsonObject probeConfig, JsonElement checkpoint) { - listener.onDataCompleted(probeConfig, checkpoint); - } - - @Override - public void setListener(DataListener listener) { - this.listener = listener; - } - -} diff --git a/src/edu/mit/media/funf/math/Window.java b/src/edu/mit/media/funf/math/Window.java deleted file mode 100644 index 658ff94..0000000 --- a/src/edu/mit/media/funf/math/Window.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.math; - -public class Window -{ - public double[] window; - public int n; - - public Window(int windowSize) - { - n = windowSize; - - // Make a Hamming window - window = new double[n]; - for(int i = 0; i < n; i++) - { - window[i] = 0.54 - 0.46*Math.cos(2*Math.PI*(double)i/((double)n-1)); - } - } - - public void applyWindow(double[] buffer) - { - for (int i = 0; i < n; i ++) - { - buffer[i] *= window[i]; - } - } - -} diff --git a/src/edu/mit/media/funf/pipeline/Pipeline.java b/src/edu/mit/media/funf/pipeline/Pipeline.java deleted file mode 100644 index 2f675a0..0000000 --- a/src/edu/mit/media/funf/pipeline/Pipeline.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.pipeline; - -import com.google.gson.JsonElement; - -import edu.mit.media.funf.FunfManager; - - - -public interface Pipeline { - - /** - * Called once when the pipeline is created. This method can be used - * to register any scheduled operations. - * - * @param manager - */ - public void onCreate(FunfManager manager); - - /** - * Instructs pipeline to perform an operation. - * @param action The action to perform. - * @param config The object to perform the action on. - */ - public void onRun(String action, JsonElement config); // maybe intent, IJsonObject? - - /** - * The teardown method called once when the pipeline should shut down. - */ - public void onDestroy(); - - /** - * Returns true if this pipeline is enabled, meaning onCreate has been called - * and onDestroy has not yet been called. - */ - public boolean isEnabled(); - -} 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/probe/builtin/AccelerometerSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java deleted file mode 100644 index 0adb368..0000000 --- a/src/edu/mit/media/funf/probe/builtin/AccelerometerSensorProbe.java +++ /dev/null @@ -1,46 +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.hardware.Sensor; -import edu.mit.media.funf.probe.Probe.PassiveProbe; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.AccelerometerSensorKeys; - -@RequiredFeatures("android.hardware.sensor.accelerometer") -public class AccelerometerSensorProbe extends SensorProbe implements PassiveProbe, AccelerometerSensorKeys { - - @Override - public int getSensorType() { - return Sensor.TYPE_ACCELEROMETER; - } - - @Override - public String[] getValueNames() { - return new String[] { - X, Y, Z - }; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/AccountsProbe.java b/src/edu/mit/media/funf/probe/builtin/AccountsProbe.java deleted file mode 100644 index da31902..0000000 --- a/src/edu/mit/media/funf/probe/builtin/AccountsProbe.java +++ /dev/null @@ -1,69 +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.lang.reflect.Type; - -import android.accounts.Account; -import android.accounts.AccountManager; -import android.content.Context; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import edu.mit.media.funf.probe.Probe.RequiredPermissions; -import edu.mit.media.funf.probe.builtin.ProbeKeys.AccountsKeys; - -@RequiredPermissions(android.Manifest.permission.GET_ACCOUNTS) -public class AccountsProbe extends ImpulseProbe implements AccountsKeys { - - @Override - protected GsonBuilder getGsonBuilder() { - GsonBuilder builder = super.getGsonBuilder(); - builder.registerTypeAdapter(Account.class, new JsonSerializer() { - @Override - public JsonElement serialize(Account src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject account = new JsonObject(); - account.addProperty(NAME, sensitiveData(src.name)); - account.addProperty(TYPE, src.type); - return account; - } - }); - return builder; - } - - @Override - public void onStart() { - AccountManager am = (AccountManager)getContext().getSystemService(Context.ACCOUNT_SERVICE); - Gson gson = getGson(); - for (Account account : am.getAccounts()) { - sendData(gson.toJsonTree(account).getAsJsonObject()); - } - disable(); - } -} diff --git a/src/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java b/src/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.java deleted file mode 100644 index 747bb76..0000000 --- a/src/edu/mit/media/funf/probe/builtin/AndroidInfoProbe.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 android.os.Build; - -import com.google.gson.JsonObject; - -import edu.mit.media.funf.probe.builtin.ProbeKeys.AndroidInfoKeys; - -public class AndroidInfoProbe extends ImpulseProbe implements AndroidInfoKeys { - - @Override - protected void onStart() { - super.onStart(); - JsonObject data = new JsonObject(); - data.addProperty(FIRMWARE_VERSION, Build.VERSION.RELEASE); - data.addProperty(BUILD_NUMBER, - Build.PRODUCT + "-" + Build.TYPE - + " " + Build.VERSION.RELEASE - + " " + Build.ID - + " " + Build.VERSION.INCREMENTAL - + " " + Build.TAGS); - data.addProperty(SDK, Integer.parseInt(Build.VERSION.SDK, 10)); - sendData(data); - stop(); - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/BatteryProbe.java b/src/edu/mit/media/funf/probe/builtin/BatteryProbe.java deleted file mode 100644 index 773171f..0000000 --- a/src/edu/mit/media/funf/probe/builtin/BatteryProbe.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 android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.Base; -import edu.mit.media.funf.probe.Probe.PassiveProbe; -import edu.mit.media.funf.probe.Probe.RequiredPermissions; - -@Schedule.DefaultSchedule(interval=300) -@RequiredPermissions(android.Manifest.permission.BATTERY_STATS) -public class BatteryProbe extends Base implements PassiveProbe { - - private final BroadcastReceiver receiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { - sendData(getGson().toJsonTree(intent.getExtras()).getAsJsonObject()); - stop(); - } - } - }; - - @Override - protected void onStart() { - super.onStart(); - getContext().registerReceiver(receiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); - } - - @Override - protected void onStop() { - super.onStop(); - getContext().unregisterReceiver(receiver); - } -} diff --git a/src/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java b/src/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java deleted file mode 100644 index f4745a6..0000000 --- a/src/edu/mit/media/funf/probe/builtin/BrowserBookmarksProbe.java +++ /dev/null @@ -1,62 +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.HashMap; -import java.util.Map; - -import android.net.Uri; -import android.provider.Browser; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.RequiredPermissions; - -@Schedule.DefaultSchedule(interval=604800) -@RequiredPermissions(android.Manifest.permission.READ_HISTORY_BOOKMARKS) -public class BrowserBookmarksProbe extends DatedContentProviderProbe { - - @Override - protected Uri getContentProviderUri() { - return Browser.BOOKMARKS_URI; - } - - @Override - protected String getDateColumnName() { - return Browser.BookmarkColumns.DATE; - } - - @Override - protected Map> getProjectionMap() { - Map> projectionKeyToType = new HashMap>(); - projectionKeyToType.put(Browser.BookmarkColumns._ID, intCell()); - projectionKeyToType.put(Browser.BookmarkColumns.TITLE, sensitiveStringCell()); - projectionKeyToType.put(Browser.BookmarkColumns.URL, sensitiveStringCell()); - projectionKeyToType.put(Browser.BookmarkColumns.VISITS, intCell()); - projectionKeyToType.put(Browser.BookmarkColumns.DATE, longCell()); - projectionKeyToType.put(Browser.BookmarkColumns.CREATED, longCell()); - projectionKeyToType.put(Browser.BookmarkColumns.BOOKMARK, intCell()); - //projectionKeyToType.put(Browser.BookmarkColumns.DESCRIPTION, hashedStringCell()); // TODO: Description doesn't exist - return projectionKeyToType; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java b/src/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.java deleted file mode 100644 index f479427..0000000 --- a/src/edu/mit/media/funf/probe/builtin/BrowserSearchesProbe.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.HashMap; -import java.util.Map; - -import android.net.Uri; -import android.provider.Browser; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.RequiredPermissions; - -@Schedule.DefaultSchedule(interval=604800) -@RequiredPermissions(android.Manifest.permission.READ_HISTORY_BOOKMARKS) -public class BrowserSearchesProbe extends DatedContentProviderProbe { - - @Override - protected Uri getContentProviderUri() { - return Browser.SEARCHES_URI; - } - - @Override - protected String getDateColumnName() { - return Browser.SearchColumns.DATE; - } - - @Override - protected Map> getProjectionMap() { - Map> projectionKeyToType = new HashMap>(); - projectionKeyToType.put(Browser.SearchColumns._ID, intCell()); - projectionKeyToType.put(Browser.SearchColumns.SEARCH, sensitiveStringCell()); - projectionKeyToType.put(Browser.SearchColumns.DATE, longCell()); - return projectionKeyToType; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/CallLogProbe.java b/src/edu/mit/media/funf/probe/builtin/CallLogProbe.java deleted file mode 100644 index d65ec78..0000000 --- a/src/edu/mit/media/funf/probe/builtin/CallLogProbe.java +++ /dev/null @@ -1,64 +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.HashMap; -import java.util.Map; - -import android.net.Uri; -import android.provider.CallLog; -import android.provider.CallLog.Calls; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.RequiredPermissions; -import edu.mit.media.funf.probe.builtin.ContentProviderProbe.CursorCell.PhoneNumberCell; - -@Schedule.DefaultSchedule(interval=36000) -@RequiredPermissions(android.Manifest.permission.READ_CONTACTS) -public class CallLogProbe extends DatedContentProviderProbe { - - @Override - protected Uri getContentProviderUri() { - return CallLog.Calls.CONTENT_URI; - } - - @Override - protected String getDateColumnName() { - return Calls.DATE; - } - - @Override - protected Map> getProjectionMap() { - Map> projectionKeyToType = new HashMap>(); - projectionKeyToType.put(Calls._ID, intCell()); - projectionKeyToType.put(Calls.NUMBER, new SensitiveCell(new PhoneNumberCell())); - projectionKeyToType.put(Calls.DATE, longCell()); - projectionKeyToType.put(Calls.TYPE, intCell()); - projectionKeyToType.put(Calls.DURATION, longCell()); - projectionKeyToType.put(Calls.CACHED_NAME, sensitiveStringCell()); - projectionKeyToType.put(Calls.CACHED_NUMBER_LABEL, sensitiveStringCell()); - projectionKeyToType.put(Calls.CACHED_NUMBER_TYPE, sensitiveStringCell()); - return projectionKeyToType; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/CellTowerProbe.java b/src/edu/mit/media/funf/probe/builtin/CellTowerProbe.java deleted file mode 100644 index 7217d9e..0000000 --- a/src/edu/mit/media/funf/probe/builtin/CellTowerProbe.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.content.Context; -import android.os.Bundle; -import android.telephony.CellLocation; -import android.telephony.TelephonyManager; -import android.telephony.cdma.CdmaCellLocation; -import android.telephony.gsm.GsmCellLocation; -import edu.mit.media.funf.probe.Probe.Base; -import edu.mit.media.funf.probe.Probe.DisplayName; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.Probe.RequiredPermissions; -import edu.mit.media.funf.probe.builtin.ProbeKeys.CellKeys; - -@DisplayName("Nearby Cellular Towers Probe") -@RequiredFeatures("android.hardware.telephony") -@RequiredPermissions(android.Manifest.permission.ACCESS_COARSE_LOCATION) -public class CellTowerProbe extends Base implements CellKeys { - - @Override - protected void onStart() { - super.onStart(); - sendData(getGson().toJsonTree(getData()).getAsJsonObject()); - stop(); - } - - private Bundle getData() { - TelephonyManager manager = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE); - CellLocation location = manager.getCellLocation(); - Bundle data = new Bundle(); - if (location instanceof GsmCellLocation) { - GsmCellLocation gsmLocation = (GsmCellLocation) location; - gsmLocation.fillInNotifierBundle(data); - data.putInt(TYPE, TelephonyManager.PHONE_TYPE_GSM); - } else if (location instanceof CdmaCellLocation) { - CdmaCellLocation cdmaLocation = (CdmaCellLocation) location; - cdmaLocation.fillInNotifierBundle(data); - data.putInt(TYPE, TelephonyManager.PHONE_TYPE_CDMA); - } else { - data.putInt(TYPE, TelephonyManager.PHONE_TYPE_NONE); - } - return data; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.java deleted file mode 100644 index d7dcbf4..0000000 --- a/src/edu/mit/media/funf/probe/builtin/GyroscopeSensorProbe.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 android.hardware.Sensor; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.Description; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.GyroscopeSensorKeys; - -/** - * Measures angular speed around each axis. - * - * All values are in radians/second and measure the rate of rotation around the X, Y and Z axis. - * The coordinate system is the same as is used for the acceleration sensor. - * Rotation is positive in the counter-clockwise direction. That is, an observer looking from some positive location on the x, y. or z axis at a device positioned on the origin would report positive rotation if the device appeared to be rotating counter clockwise. - * Note that this is the standard mathematical definition of positive rotation and does not agree with the definition of roll given earlier. - * - * Android Reference http://developer.android.com/reference/android/hardware/SensorEvent.html - */ -@Description("Measures angular speed around each axis.") -@Schedule.DefaultSchedule(interval=1800, duration = 60) -@RequiredFeatures("android.hardware.sensor.gyroscope") -public class GyroscopeSensorProbe extends SensorProbe implements GyroscopeSensorKeys { - - public int getSensorType() { - return Sensor.TYPE_GYROSCOPE; - } - - public String[] getValueNames() { - return new String[] { - X, Y, Z - }; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/LightSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/LightSensorProbe.java deleted file mode 100644 index 40bcb95..0000000 --- a/src/edu/mit/media/funf/probe/builtin/LightSensorProbe.java +++ /dev/null @@ -1,43 +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.hardware.Sensor; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.LightSensorKeys; - -@Schedule.DefaultSchedule(interval=300, duration=SensorProbe.DEFAULT_DURATION) -@RequiredFeatures("android.hardware.sensor.light") -public class LightSensorProbe extends SensorProbe implements LightSensorKeys { - - public int getSensorType() { - return Sensor.TYPE_LIGHT; - } - public String[] getValueNames() { - return new String[] { - LUX - }; - } -} diff --git a/src/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.java deleted file mode 100644 index 069a9c3..0000000 --- a/src/edu/mit/media/funf/probe/builtin/LinearAccelerationSensorProbe.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.Description; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.LinearAccelerationSensorKeys; - -/** - * Records a three dimensional vector indicating acceleration along each device axis, not including gravity. All values have units of m/s^2. The coordinate system is the same as is used by the acceleration sensor. - * The output of the accelerometer, gravity and linear-acceleration sensors obey the following relation: - * acceleration = gravity + linear-acceleration - * - * Android Reference http://developer.android.com/reference/android/hardware/SensorEvent.html - * - */ -@Description("Records a three dimensional vector indicating acceleration along each device axis, not including gravity.") -@RequiredFeatures({"android.hardware.sensor.accelerometer","android.hardware.sensor.gyroscope"}) -public class LinearAccelerationSensorProbe extends SensorProbe implements LinearAccelerationSensorKeys { - - public int getSensorType() { - return 10; //SensorKeys.TYPE_LINEAR_ACCELERATION; // API Level 9 - } - - public String[] getValueNames() { - return new String[] { - X, Y, Z - }; - } -} diff --git a/src/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java deleted file mode 100644 index f990d23..0000000 --- a/src/edu/mit/media/funf/probe/builtin/MagneticFieldSensorProbe.java +++ /dev/null @@ -1,44 +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.hardware.Sensor; -import edu.mit.media.funf.probe.Probe.Description; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.MagneticFieldSensorKeys; - -@Description("Records a three dimensional vector of the magnetic field.") -@RequiredFeatures("android.hardware.sensor.compass") -public class MagneticFieldSensorProbe extends SensorProbe implements MagneticFieldSensorKeys { - - public int getSensorType() { - return Sensor.TYPE_MAGNETIC_FIELD; - } - public String[] getValueNames() { - return new String[] { - X, Y, Z - }; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.java deleted file mode 100644 index d422878..0000000 --- a/src/edu/mit/media/funf/probe/builtin/OrientationSensorProbe.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 android.hardware.Sensor; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.Description; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.OrientationSensorKeys; - -@Description("Records a three dimensional vector of the magnetic field.") -@RequiredFeatures("android.hardware.sensor.gyroscope") -@Schedule.DefaultSchedule(interval=180, duration=15) -public class OrientationSensorProbe extends SensorProbe implements OrientationSensorKeys { - - public int getSensorType() { - return Sensor.TYPE_ORIENTATION; - } - - public String[] getValueNames() { - return new String[] { - AZIMUTH, PITCH, ROLL - }; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java deleted file mode 100644 index d6fa66e..0000000 --- a/src/edu/mit/media/funf/probe/builtin/PressureSensorProbe.java +++ /dev/null @@ -1,43 +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.hardware.Sensor; -import edu.mit.media.funf.probe.Probe.Description; -import edu.mit.media.funf.probe.builtin.ProbeKeys.PressureSensorKeys; - -@Description("Records a three dimensional vector of the magnetic field.") -//@RequiredFeatures("android.hardware.sensor.barometer") // varies -public class PressureSensorProbe extends SensorProbe implements PressureSensorKeys { - - public int getSensorType() { - return Sensor.TYPE_PRESSURE; - } - - public String[] getValueNames() { - return new String[] { - PRESSURE - }; - } -} diff --git a/src/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java b/src/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java deleted file mode 100644 index c01c65d..0000000 --- a/src/edu/mit/media/funf/probe/builtin/ProximitySensorProbe.java +++ /dev/null @@ -1,52 +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.hardware.Sensor; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.Description; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.ProximitySensorKeys; - - -/** - * Returns sensor distance in centimeters or only a binary near/far measurement - * If binary, will return 0 or max range as defined by Sensor.getMaximumRange(). - * - */ -@Description("Returns sensor distance in centimeters or only a binary near/far measurement.") -@RequiredFeatures("android.hardware.sensor.proximity") -@Schedule.DefaultSchedule(interval=300, duration=15) -public class ProximitySensorProbe extends SensorProbe implements ProximitySensorKeys { - - public int getSensorType() { - return Sensor.TYPE_PROXIMITY; - } - - public String[] getValueNames() { - return new String[] { - DISTANCE - }; - } -} diff --git a/src/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java deleted file mode 100644 index 07f07f7..0000000 --- a/src/edu/mit/media/funf/probe/builtin/RotationVectorSensorProbe.java +++ /dev/null @@ -1,46 +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.Schedule; -import edu.mit.media.funf.probe.Probe.Description; -import edu.mit.media.funf.probe.Probe.RequiredFeatures; -import edu.mit.media.funf.probe.builtin.ProbeKeys.RotationVectorSensorKeys; - -@Description("Returns sensor distance in centimeters or only a binary near/far measurement.") -@RequiredFeatures("android.hardware.sensor.gyroscope") -@Schedule.DefaultSchedule(interval=300, duration=15) -public class RotationVectorSensorProbe extends SensorProbe implements RotationVectorSensorKeys { - - public int getSensorType() { - return 11; //SensorKeys.TYPE_ROTATION_VECTOR; // API Level 9 - } - - public String[] getValueNames() { - return new String[] { - X_SIN_THETA_OVER_2, Y_SIN_THETA_OVER_2, Z_SIN_THETA_OVER_2, COS_THETA_OVER_2 - }; - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/ServicesProbe.java b/src/edu/mit/media/funf/probe/builtin/ServicesProbe.java deleted file mode 100644 index 705b748..0000000 --- a/src/edu/mit/media/funf/probe/builtin/ServicesProbe.java +++ /dev/null @@ -1,63 +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.Arrays; -import java.util.List; - -import android.app.ActivityManager; -import android.app.ActivityManager.RunningServiceInfo; -import android.content.Context; - -import com.google.gson.Gson; - -import edu.mit.media.funf.config.Configurable; -import edu.mit.media.funf.probe.Probe.Base; -import edu.mit.media.funf.probe.builtin.ProbeKeys.ServicesKeys; - -public class ServicesProbe extends Base implements ServicesKeys { - - /** - * The array of packages from which service info will be emitted. - * If this parameter is null, will return every service. - */ - @Configurable - private String[] packages = null; - - @Override - protected void onStart() { - super.onStart(); - Gson gson = getGson(); - ActivityManager am = (ActivityManager)getContext().getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE); - List packageList = packages == null ? null : Arrays.asList(packages); - for (RunningServiceInfo info : am.getRunningServices(Integer.MAX_VALUE)) { - String packageName = info.service.getPackageName(); - if (packageList == null || packageList.contains(packageName)) { - sendData(gson.toJsonTree(info).getAsJsonObject()); - } - } - stop(); - } - -} diff --git a/src/edu/mit/media/funf/probe/builtin/SimpleProbe.java b/src/edu/mit/media/funf/probe/builtin/SimpleProbe.java deleted file mode 100644 index d5f7179..0000000 --- a/src/edu/mit/media/funf/probe/builtin/SimpleProbe.java +++ /dev/null @@ -1,58 +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 com.google.gson.GsonBuilder; -import com.google.gson.JsonSerializer; - -import edu.mit.media.funf.probe.Probe.Base; - -public abstract class SimpleProbe extends Base { - - // TODO: possibly integrate this into base, so that both impulse and continuous probes can make use of it - - @Override - protected GsonBuilder getGsonBuilder() { - GsonBuilder builder = super.getGsonBuilder(); - JsonSerializer serializer = getSerializer(); - if (serializer != null) { - builder.registerTypeAdapter(getClass().getGenericInterfaces()[0], serializer); - } - return builder; - } - - protected void sendData(T data) { - sendData(getGson().toJsonTree(data).getAsJsonObject()); - } - - /** - * Used to override the default serialization technique for the object - * @return - */ - protected JsonSerializer getSerializer() { - return null; - } - - -} diff --git a/src/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java b/src/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.java deleted file mode 100644 index 7dcb8a9..0000000 --- a/src/edu/mit/media/funf/probe/builtin/TemperatureSensorProbe.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 android.hardware.Sensor; -import edu.mit.media.funf.Schedule; -import edu.mit.media.funf.probe.Probe.Description; -import edu.mit.media.funf.probe.builtin.ProbeKeys.TemperatureSensorKeys; - -/** - * Used to record temperature. Implementation depends on the device and does not exist on all devices. - * Some will record temperature of battery, others temperature of CPU or environment. - * - */ -@Description("Returns sensor distance in centimeters or only a binary near/far measurement.") -//@RequiredFeatures("android.hardware.sensor.temperature") // doesn't exist yet -@Schedule.DefaultSchedule(interval=1200, duration=10) -public class TemperatureSensorProbe extends SensorProbe implements TemperatureSensorKeys { - - public int getSensorType() { - return Sensor.TYPE_TEMPERATURE; - } - - public String[] getValueNames() { - return new String[] { - TEMPERATURE - }; - } - -} diff --git a/src/edu/mit/media/funf/security/MD5.java b/src/edu/mit/media/funf/security/MD5.java deleted file mode 100644 index 53afcc3..0000000 --- a/src/edu/mit/media/funf/security/MD5.java +++ /dev/null @@ -1,58 +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.security; - -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public class MD5 { - - private static String convertToHex(byte[] data) { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < data.length; i++) { - int halfbyte = (data[i] >>> 4) & 0x0F; - int two_halfs = 0; - do { - if ((0 <= halfbyte) && (halfbyte <= 9)) - buf.append((char) ('0' + halfbyte)); - else - buf.append((char) ('a' + (halfbyte - 10))); - halfbyte = data[i] & 0x0F; - } while(two_halfs++ < 1); - } - return buf.toString(); - } - - public static String MD5Digest(String text) - throws NoSuchAlgorithmException, UnsupportedEncodingException { - MessageDigest md; - md = MessageDigest.getInstance("MD5"); - byte[] md5hash = new byte[32]; - md.update(text.getBytes("iso-8859-1"), 0, text.length()); - md5hash = md.digest(); - return convertToHex(md5hash); - } -} - \ No newline at end of file diff --git a/src/edu/mit/media/funf/storage/BackedUpArchive.java b/src/edu/mit/media/funf/storage/BackedUpArchive.java deleted file mode 100644 index ac1b9b7..0000000 --- a/src/edu/mit/media/funf/storage/BackedUpArchive.java +++ /dev/null @@ -1,66 +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.File; - -/** - * Delegates all actions to archive. Adds an item to the backup archive before removing from the archive. - * It is up to the backup archive to determine when those items will remove themselves. - * - */ -public class BackedUpArchive implements FileArchive { - - private final FileArchive archive, backupArchive; - - public BackedUpArchive(FileArchive archive, FileArchive backupArchive) { - this.archive = archive; - this.backupArchive = backupArchive; - } - - @Override - public boolean add(File item) { - return archive.add(item); - } - - @Override - public File[] getAll() { - return archive.getAll(); - } - - @Override - public boolean contains(File item) { - return archive.contains(item); - } - - @Override - public boolean remove(File item) { - if (archive.contains(item)) { - backupArchive.add(item); - } - return archive.remove(item); - } - - -} diff --git a/src/edu/mit/media/funf/storage/CompositeFileArchive.java b/src/edu/mit/media/funf/storage/CompositeFileArchive.java deleted file mode 100644 index 876573b..0000000 --- a/src/edu/mit/media/funf/storage/CompositeFileArchive.java +++ /dev/null @@ -1,88 +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.File; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -/** - * Attempts to use the first archive. If that fails, continues down the list until a successful archive is reached. - * - */ -public class CompositeFileArchive implements FileArchive { - - private final FileArchive[] archives; - - public CompositeFileArchive(FileArchive... archives) { - this.archives = archives; - } - - @Override - public boolean add(File item) { - // Add to archive one by one, until one is successful or archives are exhausted. - for (FileArchive archive : archives) { - if(archive.add(item)) { - return true; - } - } - return false; - } - - @Override - public File[] getAll() { - // Merge files from all archives, ignoring duplicates - Set fileSet = new HashSet(); - for (FileArchive archive : archives) { - fileSet.addAll(Arrays.asList(archive.getAll())); - } - File[] files = new File[fileSet.size()]; - fileSet.toArray(files); - return files; - } - - @Override - public boolean remove(File item) { - // Remove on every archive, returning true if at least one was successful - boolean success = false; - for (FileArchive archive : archives) { - if(archive.remove(item)) { - success = true; - } - } - return success; - } - - @Override - public boolean contains(File item) { - for (FileArchive archive : archives) { - if (archive.contains(item)) { - return true; - } - } - return false; - } - -} diff --git a/src/edu/mit/media/funf/storage/FileArchive.java b/src/edu/mit/media/funf/storage/FileArchive.java deleted file mode 100644 index 03819ff..0000000 --- a/src/edu/mit/media/funf/storage/FileArchive.java +++ /dev/null @@ -1,62 +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.File; - - -/** - * Responsible for storing a representation of the object. - */ -public interface FileArchive { - - /** - * Adds the item to the archive - * @param item - * @return true if archive was successful - */ - public boolean add(File item); - - /** - * Removes the item from the archive if it exists - * @param item - * @return true if item exists in archive and was successfully removed - */ - public boolean remove(File item); - - /** - * @param item - * @return true if item exists in archive - */ - public boolean contains(File item); - - - /** - * @return All items in the archive - */ - public File[] getAll(); - - - -} \ No newline at end of file diff --git a/src/edu/mit/media/funf/storage/RemoteFileArchive.java b/src/edu/mit/media/funf/storage/RemoteFileArchive.java deleted file mode 100644 index fbaa9ac..0000000 --- a/src/edu/mit/media/funf/storage/RemoteFileArchive.java +++ /dev/null @@ -1,52 +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.File; - -/** - * Interface for representing file archives that are not on the device. - * - */ -public interface RemoteFileArchive { - - /** - * Synchronously add the file to the remote archive - * @param file the File to upload - * @return true if successfully added, false otherwise - */ - public boolean add(File file); - - /** - * @return true if this remote archive is available currently - */ - public boolean isAvailable(); - - /** - * A unique string that represents this remote archive. These will mostly be URIs, - * but implementation is dependent on implementation. - * @return - */ - public String getId(); -} diff --git a/src/edu/mit/media/funf/util/ArrayUtil.java b/src/edu/mit/media/funf/util/ArrayUtil.java deleted file mode 100644 index 37e73e3..0000000 --- a/src/edu/mit/media/funf/util/ArrayUtil.java +++ /dev/null @@ -1,49 +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.util; - -public class ArrayUtil { - - public ArrayUtil() { - - } - - - - /** - * Convenience function for concatenating two arrays - * @param - * @param first - * @param second - * @return - */ - @SuppressWarnings("unchecked") - public static T[] concat(T[] first, T[] second) { - T[] result = (T[])new Object[first.length + second.length]; - System.arraycopy(first, 0, result, 0, first.length); - System.arraycopy(second, 0, result, first.length, second.length); - return result; - } - -} diff --git a/src/edu/mit/media/funf/util/LockUtil.java b/src/edu/mit/media/funf/util/LockUtil.java deleted file mode 100644 index 216b20d..0000000 --- a/src/edu/mit/media/funf/util/LockUtil.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.util; - -import android.content.Context; -import android.os.PowerManager; - -public class LockUtil { - - public static PowerManager.WakeLock getWakeLock(Context context) { - return LockUtil.getWakeLock(context, context.getClass().getName()); - } - - public static PowerManager.WakeLock getWakeLock(Context context, String tag) { - PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - PowerManager.WakeLock lock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, tag); - lock.acquire(); - return lock; - } - -} diff --git a/src/edu/mit/media/funf/util/LogUtil.java b/src/edu/mit/media/funf/util/LogUtil.java deleted file mode 100644 index 6032b03..0000000 --- a/src/edu/mit/media/funf/util/LogUtil.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.util; - -public class LogUtil { - - public static final String TAG = "Funf"; - - private LogUtil() { - - } - -} diff --git a/src/edu/mit/media/funf/util/StringUtil.java b/src/edu/mit/media/funf/util/StringUtil.java deleted file mode 100644 index cb37775..0000000 --- a/src/edu/mit/media/funf/util/StringUtil.java +++ /dev/null @@ -1,62 +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.util; - -import java.util.Collection; -import java.util.Iterator; - -public class StringUtil { - - private StringUtil() { - - } - - - /** - * Convenience function for joining strings using a delimeter - * @param strings - * @param delimeter - * @return - */ - public static String join(final Collection strings, String delimeter) { - if (delimeter == null) { - delimeter = ","; - } - if (strings.isEmpty()) { - return ""; - } - StringBuffer joined = new StringBuffer(); - Iterator stringIter = strings.iterator(); - joined.append(stringIter.next().toString()); - while (stringIter.hasNext()) { - joined.append(delimeter); - joined.append(stringIter.next().toString()); - } - return joined.toString(); - } - - public static String simpleFilesafe(String value) { - return value == null ? "" : value.replaceAll("[^a-zA-Z0-9-_\\.]", "_").toLowerCase(); - } -} diff --git a/src/edu/mit/media/funf/util/UuidUtil.java b/src/edu/mit/media/funf/util/UuidUtil.java deleted file mode 100644 index e86fb30..0000000 --- a/src/edu/mit/media/funf/util/UuidUtil.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.util; - -import static edu.mit.media.funf.util.AsyncSharedPrefs.async; - -import java.util.UUID; - -import android.content.Context; -import android.content.SharedPreferences; - -public class UuidUtil { - - public static String getInstallationId(Context context) { - if (UuidUtil.uuid == null) { - SharedPreferences prefs = async(context.getSharedPreferences(UuidUtil.FUNF_UTILS_PREFS, Context.MODE_PRIVATE)); - UuidUtil.uuid = prefs.getString(UuidUtil.INSTALLATION_UUID_KEY, null); - if (UuidUtil.uuid == null) { - UuidUtil.uuid = UUID.randomUUID().toString(); - prefs.edit().putString(UuidUtil.INSTALLATION_UUID_KEY, UuidUtil.uuid).commit(); - } - } - return UuidUtil.uuid; - } - - public static String uuid = null; - public static final String INSTALLATION_UUID_KEY = "INSTALLATION_UUID"; - public static final String FUNF_UTILS_PREFS = "edu.mit.media.funf.Utils"; - -}