Skip to content

Commit

Permalink
Merge pull request #114 from shankari/add_data_collection_config_and_…
Browse files Browse the repository at this point in the history
…battery_readings

Turn off UI alerts unless the user wants them for debugging
  • Loading branch information
shankari committed Jun 8, 2016
2 parents 2259a03 + 2cc112c commit 994f196
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.android.gms.location.ActivityRecognitionResult;
import com.google.android.gms.location.DetectedActivity;

import edu.berkeley.eecs.emission.cordova.tracker.ConfigManager;
import edu.berkeley.eecs.emission.cordova.unifiedlogger.NotificationHelper;
import edu.berkeley.eecs.emission.R;

Expand Down Expand Up @@ -34,8 +35,10 @@ protected void onHandleIntent(Intent intent) {
ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
DetectedActivity mostProbableActivity = result.getMostProbableActivity();
Log.i(this, TAG, "Detected new activity "+mostProbableActivity);
if (ConfigManager.getConfig(this).isSimulateUserInteraction()) {
NotificationHelper.createNotification(this, ACTIVITY_IN_NUMBERS,
"Detected new activity "+activityType2Name(mostProbableActivity.getType()));
}
// TODO: Do we want to compare activity and only store when different?
// Can easily do that by getting the last activity
// Let's suck everything up to the server for now and optimize later
Expand Down
25 changes: 25 additions & 0 deletions src/android/location/TripDiaryStateMachineService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.LinkedList;
import java.util.List;

import edu.berkeley.eecs.emission.cordova.tracker.ConfigManager;
import edu.berkeley.eecs.emission.cordova.tracker.sensors.BatteryUtils;
import edu.berkeley.eecs.emission.cordova.unifiedlogger.NotificationHelper;
import edu.berkeley.eecs.emission.R;
Expand Down Expand Up @@ -233,12 +234,16 @@ public void onResult(Status status) {
String newState = fCtxt.getString(R.string.state_waiting_for_trip_start);
if (status.isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to " + newState);
}
} else {
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to " + newState);
}
}
mApiClient.disconnect();
}
});
Expand Down Expand Up @@ -279,12 +284,16 @@ public void onResult(BatchResult batchResult) {
String newState = fCtxt.getString(R.string.state_ongoing_trip);
if (batchResult.getStatus().isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(fCtxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to "+newState);
}
} else {
if (ConfigManager.getConfig(fCtxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to "+newState+" failed");
}
}
mApiClient.disconnect();
}
});
Expand All @@ -301,12 +310,16 @@ public void onResult(BatchResult batchResult) {
String newState = fCtxt.getString(R.string.state_tracking_stopped);
if (batchResult.getStatus().isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(fCtxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to "+newState);
}
} else {
if (ConfigManager.getConfig(fCtxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to "+newState);
}
}
mApiClient.disconnect();
}
});
Expand Down Expand Up @@ -348,12 +361,16 @@ public void onResult(BatchResult batchResult) {
}
if (batchResult.getStatus().isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to "+newState);
}
} else {
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to "+newState);
}
}
mApiClient.disconnect();
}
});
Expand All @@ -373,12 +390,16 @@ public void onResult(BatchResult batchResult) {
String newState = fCtxt.getString(R.string.state_tracking_stopped);
if (batchResult.getStatus().isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to " + newState);
}
} else {
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to " + newState);
}
}
mApiClient.disconnect();
}
});
Expand All @@ -405,12 +426,16 @@ public void onResult(BatchResult batchResult) {
String newState = fCtxt.getString(R.string.state_tracking_stopped);
if (batchResult.getStatus().isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to "+newState);
}
} else {
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to "+newState);
}
}
mApiClient.disconnect();
}
});
Expand Down
9 changes: 9 additions & 0 deletions src/android/location/TripDiaryStateMachineServiceOngoing.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.LinkedList;
import java.util.List;

import edu.berkeley.eecs.emission.cordova.tracker.ConfigManager;
import edu.berkeley.eecs.emission.cordova.unifiedlogger.NotificationHelper;
import edu.berkeley.eecs.emission.R;
import edu.berkeley.eecs.emission.cordova.tracker.location.actions.ActivityRecognitionActions;
Expand Down Expand Up @@ -249,12 +250,16 @@ public void onResult(BatchResult batchResult) {
String newState = fCtxt.getString(R.string.state_tracking_stopped);
if (batchResult.getStatus().isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(fCtxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to " + newState);
}
} else {
if (ConfigManager.getConfig(fCtxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to " + newState);
}
}
mApiClient.disconnect();
}
});
Expand Down Expand Up @@ -287,12 +292,16 @@ public void onResult(BatchResult batchResult) {
String newState = fCtxt.getString(R.string.state_ongoing_trip);
if (batchResult.getStatus().isSuccess()) {
setNewState(newState);
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Success moving to " + newState);
}
} else {
if (ConfigManager.getConfig(ctxt).isSimulateUserInteraction()) {
NotificationHelper.createNotification(fCtxt, STATE_IN_NUMBERS,
"Failed moving to " + newState + " failed");
}
}
mApiClient.disconnect();
}
});
Expand Down

0 comments on commit 994f196

Please sign in to comment.