Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPII-884: Implement reading data from sensors within an Android platform #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions gpii/node_modules/sensors/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions gpii/node_modules/sensors/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

140 changes: 140 additions & 0 deletions gpii/node_modules/sensors/sensors.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions gpii/node_modules/sensors/sensorsTests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* Copyright 2012 OCAD University
* Copyright 2014 Lucendo Development Ltd.
* Copyright 2014 Emergya
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
Expand All @@ -19,7 +20,31 @@ var fluid = require("universal");

fluid.module.register("gpii-android", __dirname, require);

// Native modules for settings handlers
//
fluid.require("activitymanager", require);
fluid.require("androidSettings", require);
fluid.require("audioManager", require);
fluid.require("persistentConfiguration", require);

// Native module for sensors
//
fluid.require("sensors", require);

// Enable sensors and tell where the changes should be reported
//
androidSensors = fluid.registerNamespace("gpii.androidSensors");

// This approach produces random crashes, as a workaround the endPoint is being
// set in the Java side of code but it would be better to be able to configure
// it from the javascript side
//
//androidSensors.setEndPoint("http://localhost:8081/environmentChanged");

// Enable environmental light sensor
//
androidSensors.startLightSensor();

// Enable environmental noise detection
//
androidSensors.startNoiseSensor();
1 change: 1 addition & 0 deletions platform/app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>

<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
Expand Down
2 changes: 1 addition & 1 deletion platform/app/ant.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# The password will be asked during the build when you use the 'release' target.
#source.dir=src;${env.ANODE_ROOT}/bridge-java/src;${env.ANODE_ROOT}/libnode/src;../anodeshare/src;../intents/src;../a11yservices/src

source.dir=src;${env.ANODE_ROOT}/bridge-java/src;${env.ANODE_ROOT}/libnode/src;../anodeshare/src;../intents/src;../a11yservices/src;../androidSettings/src;../audioManager/src;../persistentconfig/src;libs
source.dir=src;${env.ANODE_ROOT}/bridge-java/src;${env.ANODE_ROOT}/libnode/src;../anodeshare/src;../intents/src;../a11yservices/src;../androidSettings/src;../audioManager/src;../sensors/src;../persistentconfig/src;libs
1 change: 1 addition & 0 deletions platform/makestubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./androidSettings/s
java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./androidSettings/src --classpath ./app/bin/classes net.gpii.AndroidSettings
java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./audioManager/src --classpath ./app/bin/classes net.gpii.AndroidAudioManager
java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./persistentconfig/src --classpath ./app/bin/classes net.gpii.AndroidPersistentConfiguration
java -jar ./anode/sdk/java/tools/stubgen.jar --verbose --out ./sensors/src --classpath ./app/bin/classes net.gpii.AndroidSensors
29 changes: 29 additions & 0 deletions platform/sensors/src/net/gpii/AndroidSensors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.gpii;

import org.meshpoint.anode.bridge.Env;
import org.meshpoint.anode.java.Base;

import java.util.List;

public abstract class AndroidSensors extends Base {
private static short classId = Env.getInterfaceId(AndroidSensors.class);
public AndroidSensors() { super(classId); }

// This is the way we tell the android environmental reporter where the
// changes on the context should be reported.
//
public abstract String getEndPoint();
public abstract void setEndPoint(String value);

// Light sensor
//
public abstract String getLightSensor();
public abstract void startLightSensor();
public abstract void stopLightSensor();

// Noise sensor
//
public abstract void startNoiseSensor();
public abstract void stopNoiseSensor();
public abstract double getAmplitudeEMA();
}
Loading