Skip to content

Commit

Permalink
Added Random Sampling interval (#76)
Browse files Browse the repository at this point in the history
* updated sampling interval

* updated alarm types into constants

* fixed bird count recordings not uploading right away
  • Loading branch information
GP authored Aug 23, 2019
1 parent e1fe988 commit 5d034cf
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 487 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

ext.versionMajor = 1
ext.versionMinor = 6
ext.versionPatch = 1
ext.versionPatch = 2
ext.versionClassifier = null
ext.isSnapshot = false
// Increased to 15 ie Android 4.03 Icecream sandwich to allow debugging with instant run https://developer.android.com/studio/run/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,13 @@ public void ignoreLowBatteryTest() {

@Test
public void frequencyRecordTest() {
Util.setUseFrequentRecordings(targetContext, false);
Util.setUseFrequentUploads(targetContext, false);

onView(withId(R.id.btnAdvanced)).perform(click());
HelperCode.nowNavigateRightTimes(4);

onView(withId(R.id.swRecordMoreOften)).check(matches(isNotChecked())); // Record more often should be off
onView(withId(R.id.swUseFrequentUploads)).check(matches(isNotChecked())); // Upload after every recording should be off

// Now turn record more often on
onView(withId(R.id.swRecordMoreOften)).perform(click());
onView(withId(R.id.swRecordMoreOften)).check(matches(isChecked())); // confirm it is checked
// Check correct prefs variable was set and others were not set
boolean recordMoreOften = prefs.getUseFrequentRecordings();
assertTrue(recordMoreOften);

boolean useFrequentUploads = prefs.getUseFrequentUploads();
assertFalse(useFrequentUploads);

Expand All @@ -158,39 +149,28 @@ public void frequencyRecordTest() {
nowNavigateLeft(); // leave page
nowNavigateRight(); // return to page

onView(withId(R.id.swRecordMoreOften)).check(matches(isChecked()));
onView(withId(R.id.swUseFrequentUploads)).check(matches(isNotChecked()));

// and check prefs are still correct
recordMoreOften = prefs.getUseFrequentRecordings();
assertTrue(recordMoreOften);

useFrequentUploads = prefs.getUseFrequentUploads();
assertFalse(useFrequentUploads);

periodicallyUpdateGPS = prefs.getPeriodicallyUpdateGPS();
assertFalse(periodicallyUpdateGPS);

// Finished so leave all off
onView(withId(R.id.swRecordMoreOften)).perform(click());
}

@Test
public void frequencyUploadTest() {
Util.setUseFrequentRecordings(targetContext, false);
Util.setUseFrequentUploads(targetContext, false);

onView(withId(R.id.btnAdvanced)).perform(click());
HelperCode.nowNavigateRightTimes(4);

onView(withId(R.id.swRecordMoreOften)).check(matches(isNotChecked()));
onView(withId(R.id.swUseFrequentUploads)).check(matches(isNotChecked()));

onView(withId(R.id.swUseFrequentUploads)).perform(click());
onView(withId(R.id.swUseFrequentUploads)).check(matches(isChecked())); // confirm it is checked
// Check correct prefs variable was set and others were not set
boolean recordMoreOften = prefs.getUseFrequentRecordings();
assertFalse(recordMoreOften);


boolean useFrequentUploads = prefs.getUseFrequentUploads();
assertTrue(useFrequentUploads);
Expand All @@ -203,13 +183,8 @@ public void frequencyUploadTest() {
nowNavigateLeft(); // leave page
nowNavigateRight(); // return to page

onView(withId(R.id.swRecordMoreOften)).check(matches(isNotChecked()));
onView(withId(R.id.swUseFrequentUploads)).check(matches(isChecked()));

// and check prefs are still correct
recordMoreOften = prefs.getUseFrequentRecordings();
assertFalse(recordMoreOften);

useFrequentUploads = prefs.getUseFrequentUploads();
assertTrue(useFrequentUploads);

Expand All @@ -223,19 +198,13 @@ public void frequencyUploadTest() {
@Test
@Ignore("This feature of periodically updating GPS seems to no longer exist")
public void frequencyGPSTest() {
Util.setUseFrequentRecordings(targetContext, false);
Util.setUseFrequentUploads(targetContext, false);

onView(withId(R.id.btnAdvanced)).perform(click());
HelperCode.nowNavigateRightTimes(4);

onView(withId(R.id.swRecordMoreOften)).check(matches(isNotChecked()));
onView(withId(R.id.swUseFrequentUploads)).check(matches(isNotChecked()));

// Check correct prefs variable was set and others were not set
boolean recordMoreOften = prefs.getUseFrequentRecordings();
assertFalse(recordMoreOften);

boolean useFrequentUploads = prefs.getUseFrequentUploads();
assertFalse(useFrequentUploads);

Expand All @@ -247,13 +216,8 @@ public void frequencyGPSTest() {
nowNavigateLeft(); // leave page
nowNavigateRight(); // return to page

onView(withId(R.id.swRecordMoreOften)).check(matches(isNotChecked()));
onView(withId(R.id.swUseFrequentUploads)).check(matches(isNotChecked()));

// and check prefs are still correct
recordMoreOften = prefs.getUseFrequentRecordings();
assertFalse(recordMoreOften);

useFrequentUploads = prefs.getUseFrequentUploads();
assertFalse(useFrequentUploads);

Expand Down Expand Up @@ -282,14 +246,11 @@ public void rootedTest() {
isRooted = prefs.getHasRootAccess();
assertTrue(isRooted);


// Turn off
onView(withId(R.id.swRooted)).perform(click()); // turn off
onView(withId(R.id.swRooted)).check(matches(isNotChecked())); // should be off
isRooted = prefs.getHasRootAccess();
assertFalse(isRooted);

// Finished so leave off
}

}
20 changes: 3 additions & 17 deletions app/src/main/java/nz/org/cacophony/birdmonitor/BootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,11 @@ public void run() {
long timeout = 1000 * 60 * 2; // give the boot stuff two minutes to run - but the enable flight mode does not seem to be working (however long I wait).
wakeLock.acquire(timeout); // finally never seems to run which is why I used a timeout on the wakelock creation
try {


ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
toneGen1.startTone(ToneGenerator.TONE_CDMA_CALL_SIGNAL_ISDN_NORMAL, 1000);
Util.createTheNextSingleStandardAlarm(context);

DawnDuskAlarms.configureDawnAndDuskAlarms(context, true);
Util.createCreateAlarms(context);

Util.createFailSafeAlarm(context);
Util.enableFlightMode(context);

} catch (Exception e) {
Log.e(TAG, "Error disabling flight mode");
Log.e(TAG, "Error setting boot alarms");
} finally {
wakeLock.release();
}
Expand All @@ -72,13 +64,7 @@ public void run() {
thread.start();

} catch (Exception ex) {
ToneGenerator toneGen1 = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
toneGen1.startTone(ToneGenerator.TONE_CDMA_ABBR_ALERT, 5000);
try {
Thread.sleep(3000);
} catch (Exception e) {
Log.e(TAG, ex.getLocalizedMessage(), ex);
}
Log.e(TAG, ex.getLocalizedMessage(), ex);
}


Expand Down
202 changes: 0 additions & 202 deletions app/src/main/java/nz/org/cacophony/birdmonitor/DawnDuskAlarms.java

This file was deleted.

Loading

0 comments on commit 5d034cf

Please sign in to comment.