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

Turn off UI alerts unless the user wants them for debugging #114

Merged
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
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