Skip to content

Commit b46b0aa

Browse files
Merge pull request #166 from senseobservationsystems/release/v3.4.3
Release/v3.4.3
2 parents 13e3a3e + 67fb855 commit b46b0aa

File tree

6 files changed

+82
-20
lines changed

6 files changed

+82
-20
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ local.properties
2525
# ignore changes to the AppInfoVersion
2626
sense-android-library/src/nl/sense_os/service/phonestate/AppInfoVersion.java
2727
docs
28+
.DS_Store
29+
sense-android-library/.DS_Store
30+
sense-android-library/src/.DS_Store
31+
sense-android-library/src/nl/.DS_Store
32+
sense-android-library/src/nl/sense_os/.DS_Store
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest
33
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
45
package="nl.sense_os.service"
5-
android:versionName="3.4.2">
6+
android:versionName="3.4.3">
67
<!-- <uses-sdk -->
7-
<uses-sdk android:minSdkVersion="7"/>
8+
<uses-sdk android:minSdkVersion="7" tools:overrideLibrary="com.google.android.gms"/>
9+
810
</manifest>

sense-android-library/build.gradle

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,38 @@ buildscript {
33
mavenCentral()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:0.5+'
6+
classpath 'com.android.tools.build:gradle:1.1.0'
77
}
88
}
9-
apply plugin: 'android-library'
10-
9+
apply plugin: 'com.android.library'
10+
1111
repositories {
12-
mavenCentral()
12+
jcenter()
1313
}
14-
14+
1515
dependencies {
16-
compile 'com.android.support:support-v4:13.0.0'
17-
compile files('libs/gcm.jar', 'libs/cordova-3.6.4.jar')
16+
compile 'com.android.support:support-v4:19.+'
17+
compile 'com.android.support:appcompat-v7:19.+'
18+
compile 'com.google.android.gms:play-services:6.1.71'
19+
compile files('libs/gcm.jar', 'libs/cordova-3.6.4.jar', 'libs/sqlcipher.jar')
1820
}
19-
21+
2022
android {
21-
compileSdkVersion 17
22-
buildToolsVersion "17.0.0"
23-
23+
compileSdkVersion 21
24+
buildToolsVersion "21.1.2"
25+
2426
sourceSets {
2527
main {
2628
manifest.srcFile 'AndroidManifest.xml'
2729
java.srcDirs = ['src']
2830
resources.srcDirs = ['src']
2931
aidl.srcDirs = ['src']
3032
renderscript.srcDirs = ['src']
33+
jniLibs.srcDirs = ['libs']
3134
res.srcDirs = ['res']
3235
assets.srcDirs = ['assets']
3336
}
34-
37+
3538
instrumentTest.setRoot('tests')
3639
}
37-
}
40+
}

sense-android-library/documentation/manifest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AndroidManifest {#androidmanifest}
2-
The Android manifest defines the permissions, services and intent handlers used by the Sense Android library.
2+
The Android manifest defines the permissions, services and intent handlers used by the Sense Android library. An example manifest file can be found in the sense-android-demo: https://github.com/senseobservationsystems/sense-android-library/blob/master/samples/sense-android-demo/AndroidManifest.xml
33

44
# Permissions {#permissions}
55
The Sense Android library defines a lot of permissions because the library should be capable of accessing many different resources for the wide variety of sensor output streams. It is not recommended to leave any of these permission out of your application's manifest, but if you want to do so then please make sure that all the required sensors produce valid output.

sense-android-library/src/nl/sense_os/platform/SensePlatform.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,42 @@ public JSONArray getLocalData(String sensorName, int limit) throws IllegalStateE
462462
return result;
463463
}
464464

465+
/**
466+
* Retrieve a number of values of a sensor from the local storage.
467+
*
468+
* @param sensorName
469+
* The name of the sensor to get data from
470+
* @param onlyFromDevice
471+
* Whether or not to only look through sensors that are part of this device. Searches
472+
* all sensors, including those of this device, if set to NO
473+
* @param startDate
474+
* The epoch start date in milliseconds of the period to get the sensor data from
475+
* @param endDate
476+
* The epoch end date in milliseconds of the period to get the sensor data from
477+
* @param limit
478+
* Maximum amount of data points.
479+
* @return JSONArray of data points
480+
* @throws IllegalStateException
481+
* If the Sense service is not bound yet
482+
* @throws JSONException
483+
* If the response from CommonSense could not be parsed
484+
*/
485+
public JSONArray getLocalData(String sensorName, int limit, boolean onlyFromDevice, long startDate, long endDate) throws IllegalStateException,
486+
JSONException {
487+
checkSenseService();
488+
489+
JSONArray result = new JSONArray();
490+
491+
// select remote path in local storage
492+
String localStorage = mContext.getString(R.string.local_storage_authority);
493+
Uri uri = Uri.parse("content://" + localStorage + DataPoint.CONTENT_URI_PATH);
494+
495+
// get the data
496+
result = getValues(sensorName, onlyFromDevice, limit, uri, startDate, endDate);
497+
498+
return result;
499+
}
500+
465501
/**
466502
* Retrieve a number of values of a sensor from the local storage.
467503
*

sense-android-library/src/nl/sense_os/service/location/FusedLocationSensor.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ public class FusedLocationSensor extends BaseSensor implements PeriodicPollingSe
5959
private TraveledDistanceEstimator distanceEstimator;
6060
private PeriodicPollAlarmReceiver pollAlarmReceiver;
6161

62+
private static final long BALANCED_FASTEST_INTERVAL_MILISECONDS = 1*60*1000;
63+
private static final long BALANCED_INTERVAL_MILISECONDS = 5*60*1000;
64+
65+
private static final long HIGH_ACCURACY_FASTEST_INTERVAL_MILISECONDS = 1*1000;
66+
private static final long HIGH_ACCURACY_INTERVAL_MILISECONDS = 5*1000;
67+
68+
69+
70+
6271
/**
6372
* Constructor.
6473
*
@@ -132,10 +141,16 @@ protected LocationRequest createLocationRequest() {
132141
String priority = mainPrefs.getString(SensePrefs.Main.Location.FUSED_PROVIDER_PRIORITY, SensePrefs.Main.Location.FusedProviderPriority.BALANCED);
133142
if(priority.equals(SensePrefs.Main.Location.FusedProviderPriority.LOW_POWER))
134143
locationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
135-
else if(priority.equals(SensePrefs.Main.Location.FusedProviderPriority.ACCURATE))
144+
else if(priority.equals(SensePrefs.Main.Location.FusedProviderPriority.ACCURATE)){
136145
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
137-
else
146+
locationRequest.setFastestInterval(HIGH_ACCURACY_FASTEST_INTERVAL_MILISECONDS);
147+
locationRequest.setInterval(HIGH_ACCURACY_INTERVAL_MILISECONDS);
148+
}
149+
else{
138150
locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
151+
locationRequest.setFastestInterval(BALANCED_FASTEST_INTERVAL_MILISECONDS);
152+
locationRequest.setInterval(BALANCED_INTERVAL_MILISECONDS);
153+
}
139154
return locationRequest;
140155
}
141156

@@ -280,9 +295,10 @@ private void stopPolling() {
280295

281296
@Override
282297
public void stopSensing() {
283-
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
284-
if(googleApiClient.isConnected())
298+
if(googleApiClient.isConnected()) {
299+
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
285300
googleApiClient.disconnect();
301+
}
286302

287303
active = false;
288304
stopAlarms();

0 commit comments

Comments
 (0)