Skip to content

Commit 489d509

Browse files
author
Ted Schmidt
committed
Merge pull request #151 from senseobservationsystems/release/v3.4
Release/v3.4
2 parents 04442af + 041a553 commit 489d509

File tree

15 files changed

+529
-30
lines changed

15 files changed

+529
-30
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ gen/
2020

2121
# Local configuration file (sdk path, etc)
2222
local.properties
23-
23+
# ignore changes to the AppInfoVersion
24+
sense-android-library/src/nl/sense_os/service/phonestate/AppInfoVersion.java
25+
docs

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2+
## v3.4-rc2 (2015-03-10)
3+
4+
### Fixed
5+
* Changed the implicit intents for starting services to explicit with the package as scope
6+
7+
## v3.4-rc1 (2015-03-02)
8+
9+
### Added
10+
* Added a new implementation for the position sensor which uses the FusedLocationProvider of Google Play Services via SensePrefs.Location.FUSED_PROVIDER. The goal accuracy/battery consumption can be set via SensePrefs.Location.FUSED_PROVIDER_PRIORITY.
11+
12+
### Deprecated
13+
* The position sensor using the Android framework location API's via SensePrefs.Location.GPS|WIFI|AUTO_GPS
14+
15+
### Dependency
16+
* Google Play services client library
17+
18+
119
## v3.3.5 (2015-03-30)
220

321
### Fixed
@@ -15,7 +33,6 @@
1533
### Fixed
1634
* Fix setPrefInt in SenseServiceStub to use putInt instead of putFloat
1735

18-
1936
## v3.3.2 (2015-03-02)
2037

2138
### Changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ into your local Maven repository as follows.
1919
First add some dependencies to your local Maven repository that are not available
2020
in Maven central:
2121

22-
#### Dependency 1: compatibility-v4 library (rev 12)
22+
#### Dependency 1: compatibility-v4 library (rev 21.0.3)
2323

24-
Note that you need the compatibility-v4 library, revision 12. Google didn't put that
25-
into Maven central (yet). If your local Maven repository does not contain it, install
24+
Note that you need the compatibility-v4 library, revision 21.0.3. Google didn't put that
25+
into Maven central. If your local Maven repository does not contain it, install
2626
it locally by using the
2727
[maven-android-sdk-deployer](https://github.com/mosabua/maven-android-sdk-deployer).
2828

29-
#### Dependency 2: cordova 2.7.0
29+
#### Dependency 2: cordova 3.6.4
3030

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

3333
```bash
3434
mvn install:install-file \
35-
-Dfile=cordova-2.7.0.jar \
35+
-Dfile=cordova-3.6.4.jar \
3636
-DgroupId=org.apache.cordova \
3737
-DartifactId=cordova \
38-
-Dversion=2.7.0 \
38+
-Dversion=3.6.4 \
3939
-Dpackaging=jar \
4040
-DgeneratePom=true
4141
```
@@ -60,6 +60,9 @@ by adding the following dependency to your POM:
6060
</dependency>
6161
```
6262

63+
#### Dependency 3: Google Play services client library
64+
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
65+
6366
## Pre-build commands
6467

6568
The `build/` folder contains scripts that need to be executed right before every build.

samples/sense-android-demo/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<uses-permission android:name="android.permission.VIBRATE" />
1111
<uses-permission android:name="android.permission.WAKE_LOCK" />
1212
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
13+
<uses-permission android:name="android.permission.GET_TASKS" />
1314

1415
<!-- REQUEST ACCESS TO LOCATION SENSORS -->
1516
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@@ -227,6 +228,9 @@
227228
android:name="nl.sense_os.service.provider.SensorDataProvider"
228229
android:authorities="nl.sense_os.demo.LocalStorage"
229230
android:exported="true" />
231+
<!-- GOOGLE PLAY SERVICES USED FOR THE FUSED LOCATION PROVIDER -->
232+
<meta-data android:name="com.google.android.gms.version"
233+
android:value="@integer/google_play_services_version" />
230234
</application>
231235

232236
</manifest>

samples/sense-android-demo/project.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
# Project target.
1414
target=android-16
1515
android.library.reference.1=../../sense-android-library
16+
android.library.reference.2=../../../google-play-services_lib_brightr

samples/sense-android-demo/src/nl/sense/demo/MainActivity.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import nl.sense_os.service.constants.SenseDataTypes;
77
import nl.sense_os.service.constants.SensePrefs;
88
import nl.sense_os.service.constants.SensePrefs.Main.Ambience;
9+
import nl.sense_os.service.constants.SensePrefs.Main.Location;
910
import nl.sense_os.service.constants.SensePrefs.Main.Advanced;
1011

1112
import org.json.JSONArray;
@@ -205,19 +206,23 @@ private void setPreferences() {
205206
// NOTE: spectrum might be too heavy for the phone or consume too much energy
206207
senseService.setPrefBool(Ambience.AUDIO_SPECTRUM, true);
207208

209+
// use the location sensor with the Google Play Service FusedLocationProvider
210+
senseService.setPrefBool(Location.FUSED_PROVIDER, true);
211+
senseService.setPrefString(Location.FUSED_PROVIDER_PRIORITY, Location.FusedProviderPriority.BALANCED);
212+
208213
// set how often to sample
209214
// 1 := rarely (~every 15 min)
210-
// 0 := normal (~every 5 min)
215+
// 0 := normal (~every 1 min)
211216
// -1 := often (~every 10 sec)
212-
// -2 := real time (this setting affects power consumption considerably!)
213-
senseService.setPrefString(SensePrefs.Main.SAMPLE_RATE, "-1");
217+
// -2 := real time (~every sec, this setting affects power consumption considerably!)
218+
senseService.setPrefString(SensePrefs.Main.SAMPLE_RATE, SensePrefs.Main.SampleRate.BALANCED);
214219

215220
// set how often to upload
216221
// 1 := eco mode (buffer data for 30 minutes before bulk uploading)
217222
// 0 := normal (buffer 5 min)
218223
// -1 := often (buffer 1 min)
219224
// -2 := real time (every new data point is uploaded immediately)
220-
senseService.setPrefString(SensePrefs.Main.SYNC_RATE, "-2");
225+
senseService.setPrefString(SensePrefs.Main.SYNC_RATE, SensePrefs.Main.SyncRate.REAL_TIME);
221226

222227
// show message
223228
showToast(R.string.msg_prefs_set);

sense-android-library/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
package="nl.sense_os.service"
5-
android:versionName="3.3.5">
5+
android:versionName="3.4">
66
<!-- <uses-sdk -->
77
<uses-sdk android:minSdkVersion="7"/>
88
</manifest>
231 KB
Binary file not shown.

sense-android-library/src/com/phonegap/plugins/sense/SensePlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ private void onLoginSuccess() {
439439
if (packageName.equals("nl.sense_os.ivitality")) {
440440
Log.w(TAG, "Set special iVitality sensor settings");
441441
SenseServiceStub service = sensePlatform.getService();
442-
service.setPrefString(SensePrefs.Main.SAMPLE_RATE, "0");
443-
service.setPrefString(SensePrefs.Main.SYNC_RATE, "1");
442+
service.setPrefString(SensePrefs.Main.SAMPLE_RATE, SensePrefs.Main.SampleRate.NORMAL);
443+
service.setPrefString(SensePrefs.Main.SYNC_RATE, SensePrefs.Main.SyncRate.ECO_MODE);
444444

445445
service.setPrefBool(SensePrefs.Main.Ambience.MIC, true);
446446
service.setPrefBool(SensePrefs.Main.Ambience.LIGHT, true);

sense-android-library/src/nl/sense_os/service/SenseService.java

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import nl.sense_os.service.external_sensors.NewOBD2DeviceConnector;
3131
import nl.sense_os.service.external_sensors.ZephyrBioHarness;
3232
import nl.sense_os.service.external_sensors.ZephyrHxM;
33+
import nl.sense_os.service.location.FusedLocationSensor;
3334
import nl.sense_os.service.location.LocationSensor;
3435
import nl.sense_os.service.location.TimeZoneSensor;
3536
import nl.sense_os.service.motion.MotionSensor;
@@ -132,6 +133,7 @@ public SenseServiceStub getService() {
132133
private AppsSensor appsSensor;
133134
private TimeZoneSensor timeZoneSensor;
134135
private AppInfoSensor appInfoSensor;
136+
private FusedLocationSensor fusedLocationListener;
135137

136138
/**
137139
* Handler on main application thread to display toasts to the user.
@@ -724,6 +726,9 @@ synchronized void toggleAmbience(boolean active) {
724726
case 1: // rarely (15 minutes)
725727
interval = 15 * 60 * 1000;
726728
break;
729+
case 2: // balanced (3 minutes)
730+
interval = 3 * 60 * 1000;
731+
break;
727732
default:
728733
Log.e(TAG, "Unexpected sample rate preference.");
729734
}
@@ -883,19 +888,22 @@ synchronized void toggleDeviceProx(boolean active) {
883888
int interval = 1;
884889
switch (rate) {
885890
case -2:
886-
interval = 60 * 1000;
891+
interval = 1000;
887892
break;
888893
case -1:
889894
// often
890-
interval = 5 * 60 * 1000;
895+
interval = 10 * 1000;
891896
break;
892897
case 0:
893898
// normal
894-
interval = 20 * 60 * 1000;
899+
interval = 60 * 1000;
895900
break;
896901
case 1:
897902
// rarely (15 mins)
898-
interval = 60 * 60 * 1000;
903+
interval = 15 * 60 * 1000;
904+
break;
905+
case 2: // balanced (3 minutes)
906+
interval = 3 * 60 * 1000;
899907
break;
900908
default:
901909
Log.e(TAG, "Unexpected device proximity rate preference.");
@@ -997,6 +1005,9 @@ synchronized void toggleExternalSensors(boolean active) {
9971005
// rarely (15 minutes)
9981006
interval = 15 * 60 * 1000;
9991007
break;
1008+
case 2: // balanced (3 minutes)
1009+
interval = 3 * 60 * 1000;
1010+
break;
10001011
default:
10011012
Log.e(TAG, "Unexpected external sensor rate preference.");
10021013
return;
@@ -1105,6 +1116,12 @@ synchronized void toggleLocation(boolean active) {
11051116
timeZoneSensor = null;
11061117
}
11071118

1119+
if(fusedLocationListener != null)
1120+
{
1121+
fusedLocationListener.stopSensing();
1122+
fusedLocationListener = null;
1123+
}
1124+
11081125
// get sample rate
11091126
final SharedPreferences mainPrefs = getSharedPreferences(SensePrefs.MAIN_PREFS,
11101127
MODE_PRIVATE);
@@ -1124,6 +1141,9 @@ synchronized void toggleLocation(boolean active) {
11241141
case 1: // rarely
11251142
minTime = 15 * 60 * 1000;
11261143
break;
1144+
case 2: // balanced (same as normal)
1145+
minTime = 5 * 60 * 1000;
1146+
break;
11271147
default:
11281148
Log.e(TAG, "Unexpected commonsense rate: " + rate);
11291149
break;
@@ -1161,6 +1181,15 @@ public void run() {
11611181
mSubscrMgr.registerProducer(SensorNames.TIME_ZONE, timeZoneSensor);
11621182
timeZoneSensor.startSensing();
11631183
}
1184+
1185+
if (mainPrefs.getBoolean(Location.FUSED_PROVIDER, false))
1186+
{
1187+
fusedLocationListener = FusedLocationSensor.getInstance(SenseService.this);
1188+
mSubscrMgr.registerProducer(SensorNames.LOCATION, fusedLocationListener);
1189+
mSubscrMgr.registerProducer(SensorNames.TRAVELED_DISTANCE_1H, fusedLocationListener);
1190+
mSubscrMgr.registerProducer(SensorNames.TRAVELED_DISTANCE_24H, fusedLocationListener);
1191+
fusedLocationListener.startSensing(time);
1192+
}
11641193
}
11651194
});
11661195

@@ -1177,6 +1206,17 @@ public void run() {
11771206
locListener = null;
11781207
}
11791208

1209+
// stop fused location listener
1210+
if (null != fusedLocationListener)
1211+
{
1212+
fusedLocationListener.stopSensing();
1213+
// unregister is not needed for Singleton Sensors
1214+
mSubscrMgr.unregisterProducer(SensorNames.LOCATION, fusedLocationListener);
1215+
mSubscrMgr.unregisterProducer(SensorNames.TRAVELED_DISTANCE_1H, fusedLocationListener);
1216+
mSubscrMgr.unregisterProducer(SensorNames.TRAVELED_DISTANCE_24H, fusedLocationListener);
1217+
fusedLocationListener = null;
1218+
}
1219+
11801220
if(timeZoneSensor != null)
11811221
{
11821222
mSubscrMgr.unregisterProducer(SensorNames.TIME_ZONE, timeZoneSensor);
@@ -1246,6 +1286,9 @@ synchronized void toggleMotion(boolean active) {
12461286
case 1: // rarely (15 minutes)
12471287
interval = 15 * 60 * 1000;
12481288
break;
1289+
case 2: // balanced (3 minutes)
1290+
interval = 3 * 60 * 1000;
1291+
break;
12491292
default:
12501293
Log.e(TAG, "Unexpected commonsense rate: " + rate);
12511294
break;
@@ -1320,7 +1363,7 @@ synchronized void togglePhoneState(boolean active) {
13201363
batterySensor.stopBatterySensing();
13211364
batterySensor = null;
13221365
}
1323-
1366+
13241367
// check app info sensor presence
13251368
if (appInfoSensor != null) {
13261369
Log.w(TAG, "app info sensor is already present!");
@@ -1334,7 +1377,7 @@ synchronized void togglePhoneState(boolean active) {
13341377
phoneActivitySensor.stopPhoneActivitySensing();
13351378
phoneActivitySensor = null;
13361379
}
1337-
1380+
13381381
// check apps sensor presence
13391382
if (appsSensor != null) {
13401383
Log.w(TAG, "apps sensor is already present!");
@@ -1362,6 +1405,9 @@ synchronized void togglePhoneState(boolean active) {
13621405
case 1: // rarely (15 minutes)
13631406
interval = 15 * 60 * 1000;
13641407
break;
1408+
case 2: // balanced (3 minutes)
1409+
interval = 3 * 60 * 1000;
1410+
break;
13651411
default:
13661412
Log.e(TAG, "Unexpected commonsense rate: " + rate);
13671413
break;

0 commit comments

Comments
 (0)