Giter VIP home page Giter VIP logo

sense-android-library's Introduction

Sense for Android apps

Library project for Android apps that use the Sense platform and communicate with CommonSense.

Documentation

For information about the used concepts and implementation details visit the GitHub pages.

Tutorial

Please read the tutorial on the Sense Developer Portal.

Maven

When using Maven (3.0.5+), you can add this project as an APKLIB into your local Maven repository as follows.

First add some dependencies to your local Maven repository that are not available in Maven central:

Dependency 1: compatibility-v4 library (rev 21.0.3)

Note that you need the compatibility-v4 library, revision 21.0.3. Google didn't put that into Maven central. If your local Maven repository does not contain it, install it locally by using the maven-android-sdk-deployer.

Dependency 2: cordova 3.6.4

Navigate to the Library's libs/ folder and execute the following command:

mvn install:install-file \
  -Dfile=cordova-3.6.4.jar \
  -DgroupId=org.apache.cordova \
  -DartifactId=cordova \
  -Dversion=3.6.4 \
  -Dpackaging=jar \
  -DgeneratePom=true

Now put the Sense Library to your local Maven repository:

git clone https://github.com/senseobservationsystems/sense-android-library
cd sense-android-library/sense-android-library/
mvn install

which should result in a BUILD SUCCESS.

After that, you can reference the Sense Library in a Maven-flavoured Android App by adding the following dependency to your POM:

<dependency> 
    <groupId>nl.sense_os</groupId> 
    <artifactId>sense-android-library</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <type>apklib</type>
</dependency>

Dependency 3: Google Play services client library

Starting from version 3.4 the Google Play services client library is a requirement because there is a new implementation of the position sensor which uses the Fused Location Provider. To setup Google Play services follow these instructions: https://developer.android.com/google/play-services/setup.html

Pre-build commands

The build/ folder contains scripts that need to be executed right before every build. In Eclipse, they can be added by going to Properties > Builders > New... and selecting the script in the "Location" field.

setAppVersion.sh

Copy the contents of setAppVerionExample.sh into this file, and update the paths for your own system. (Do not modify the example file!) If it does not work, try the following solutions:

  • Change the first line to #!/bin/sh if using sh instead of dash.
  • Use only absolute paths (so no $(pwd)).

Local Storage Encryption

The Sense Android Library uses the sqlcipher for Android library for encrypting the local sqlite database. The native files of the library for each architecture are included in the lib folder. An aditional required file is located in the assets folder which should be copied to the assets folder of your application. Optionally the unused native library folders can be removed if the application is only available for a specific architecture. Please make sure that you use senseService.getPref... for accessing the decrypted SensePrefs.Main.Auth preferences.

Encryption can be turned on or off for the sqlite database via the preference: senseService.setPrefBool(SensePrefs.Main.Advanced.ENCRYPT_DATABASE, true);

An app specific salt key can be provided via: senseService.setPrefString(SensePrefs.Main.Advanced.ENCRYPT_DATABASE_SALT, "1tD#V4#%6BT!@#$%XCBCV");

The encryption for the shared authentication preferences file can be turned on or off via: senseService.setPrefBool(SensePrefs.Main.Advanced.ENCRYPT_CREDENTIAL, true);

And an app specific salt key kan be provided via: senseService.setPrefString(SensePrefs.Main.Advanced.ENCRYPT_CREDENTIAL_SALT, "1tD#V4#%6BT!@#$%XCBCV");

sense-android-library's People

Contributors

pimnijdam avatar ktsitsikas avatar orhan89 avatar smuldr avatar ronaldolsthoorn avatar bkiers avatar marijnvanzelst avatar yulrizka avatar dre21 avatar bartkiers avatar jorishjanssen avatar

Stargazers

 avatar Hugh.Wong avatar Jenny Liu avatar Jiang Lu avatar Yossi Elkrief avatar Sebastiaan Scheers avatar JT5D avatar Mikko Heiskala avatar Joey van der Bie avatar trietbui85 avatar Ludo Stellingwerff avatar Ted Schmidt avatar

Watchers

Joey van der Bie avatar James Cloos avatar  avatar  avatar  avatar  avatar Platon Efstathiadis avatar  avatar  avatar  avatar  avatar  avatar Tatsuya Kaneko avatar  avatar  avatar  avatar Xavier Ramos avatar  avatar  avatar Mikaeil avatar Gilang avatar  avatar  avatar

sense-android-library's Issues

TypeError: Cannot read properties of undefined (reading 'publicId')

Sentry Issue: NICEDAY-PORTAL-17BV

React ErrorBoundary Error: Cannot read properties of undefined (reading 'publicId')
  at room (None:30:2)
...
(18 additional frame(s) were not displayed)

TypeError: Cannot read properties of undefined (reading 'publicId')
  at c (webpack://web.getgoalie.com/./src/ts_video/twilioApp/views/participants/feeds/VideoStream.tsx:50:9)
  at Ch (webpack://web.getgoalie.com/./node_modules/react-dom/cjs/react-dom.production.min.js:157:137)
  at li (webpack://web.getgoalie.com/./node_modules/react-dom/cjs/react-dom.production.min.js:180:154)
  at ck (webpack://web.getgoalie.com/./node_modules/react-dom/cjs/react-dom.production.min.js:269:343)
  at bk (webpack://web.getgoalie.com/./node_modules/react-dom/cjs/react-dom.production.min.js:250:347)
...
(13 additional frame(s) were not displayed)

Registering SenseApi.registerUser(...) triggers "Cannot find sensor ID"

When registering an account through the Sense-library (via the Demo App) like this:

...
int result = SenseApi.registerUser(activity, username, passwordHash,
        "Ask", "Test", "TEST_" + System.currentTimeMillis() + "@ask-cs.com",
        "0612346578");
...

(source)

I cannot fetch any data from the Sense back end. I see the following being printed on the log-cat:

05-02 20:15:03.777: ERROR/Sense LocalStorage(7016): Failed to query the CommonSense data points
        java.lang.IllegalArgumentException: Cannot find sensor ID
        at nl.sense_os.service.storage.LocalStorage.queryRemote(LocalStorage.java:369)
        at nl.sense_os.service.storage.LocalStorage.query(LocalStorage.java:319)
        at nl.sense_os.platform.SensePlatform.getValues(SensePlatform.java:334)
        at nl.sense_os.platform.SensePlatform.getValues(SensePlatform.java:300)
        at nl.sense_os.platform.SensePlatform.getData(SensePlatform.java:262)
        at com.askcs.asksensedemo.task.PollSenseTask.check(PollSenseTask.java:89)
        at com.askcs.asksensedemo.task.PollSenseTask.run(PollSenseTask.java:73)
        at java.util.Timer$TimerImpl.run(Timer.java:284)

The data is being received by Sense (I can see it when logging into common.sense-os.nl).

The exception is not thrown when using my existing account ([email protected]).

Upload data in-order to facilitate real-time processing

RIght now data is uploaded out-of order. This happens e.g. when sync rate is real-time and batches with old/failed points are regularly uploaded.

For real-time data processing uploading in-order is a desired feature. E.g. this is needed for the position filter to work properly.

FFT error

From the deepest depths of the Sense library:

E/Sense NoiseSensor(23037): java.lang.IllegalArgumentException: The number of averages for this transform can be at most 256.
E/Sense NoiseSensor(23037):     at nl.sense_os.service.ambience.FourierTransform.linAverages(FourierTransform.java:224)

Seems like we call the FFT with an incorrect spectrum length?

Linear acceleration unreliable

JP just experienced that CS-tracker had no linear acceleration samples during the night, although he does have both accelerometer and gyro samples. No data in common-sense, and also not for the modules that work on that data. Before and after the night there lin. acc. works fine. It seem that it started working again when he was using the app.

UserAgent header according to application

The iPhone sense library has nice UserAgent header that is set according to the application

iPhone example :
CommonSense Tracker (sensePlatform) -> "sensePlatform/1.7 CFNetwork/672.0.2 Darwin/14.0.0"

Goalie -> "Goalie/1048 CFNetwork/672.0.2 Darwin/14.0.0"

but the android library UserAgent is :
"Dalvik/1.6.0 (Linux; U; Android 4.3; Galaxy Nexus Build/JWR66Y)"

This information are recorded in nginx log, it would be nice also to make the android use the same convention.

like

CommonSense Tracker version 2.3 -> "sensePlatform/2.3.0 (Linux; U; Android 4.3; Galaxy Nexus Build/JWR66Y)"

Goalie 1.1.0 -> "Goalie/1.1.0 (Linux; U; Android 4.3; Galaxy Nexus Build/JWR66Y)"
I would suggest NOT to use space in the user agent to make it easier to parse in the future

NumberFormatException in MotionSensorUtils

Not sure whom I should mention here... But in goalie I am getting this exception from within the sense library:

java.lang.NumberFormatException: Infinity or NaN
at java.math.BigDecimal.valueOf(BigDecimal.java:777)
at nl.sense_os.service.motion.MotionSensorUtils.getVector(Unknown Source)
at nl.sense_os.service.motion.MotionBurstSensor.listToString(Unknown Source)
onNewData
at nl.sense_os.service.subscription.BaseDataProducer.removeSubscriber(Unknown Source)
sendToSubscribers
at nl.sense_os.service.motion.MotionSensor.onSensorChanged(Unknown Source)
at android.hardware.SensorManager$ListenerDelegate$1.handleMessage(SensorManager.java:538)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)

Since there is no goalie code in this trace, it is a bit tricky for me to deal with this adequately. For now I will just add a global UncaughtExceptionHandler so that this will at least not crash the whole app, but I can not oversee the consequences of letting the app continue after this error either...

Any ideas would be appreciated, a fix even more so :-)

Thanks!

Need blocking flush

SensePlatform.flush() is asynchronous. There is no way to know the flush is performed. This is a problem for giving feedback over data that might not have been uploaded to the api.

Project doesn't have a license

Right now all copyright is reserved, need to change this to the apache license 2.0. See the sense developers guidelines.

Irregular sample rate of WiFi-sensor on Samsung Galaxy SII

The WiFi-sensor sample rate on Samsung Galaxy SII seems irregular. In the tested setting the sample rate was set to 'often' (which should sample every minute) and CommonSense sync rate was set to 'real-time'. However, samples were send to CommonSense only just when settings were changed on the phone. If the phone is left untouched, sample frequency is irregular and rarely sends updates to CommonSense (only once every 25 minutes or so).

Google Cloud Messaging conflicts

When the library is used in an app that also registers for GCM, conflicts occur. It seems that the Sense lib and the app both receive the registration keys for both the CommonSense sender and the app sender. This creates a problem because we don't check which key is which.

Is there a way to solve this without bothering the apps that use our library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.