Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
511539f
maybe not broken
Gurtok Jan 17, 2017
f03671d
maybe not broken
Gurtok Jan 23, 2017
281be0c
maybe not broken
Gurtok Jan 24, 2017
dd89123
maybe not broken
Gurtok Jan 30, 2017
d0f4872
starting on database storage for upload buffer
Gurtok Feb 2, 2017
cb164c7
starting on database storage for upload buffer
Gurtok Mar 29, 2017
94a2871
starting on database storage for upload buffer
Gurtok Apr 15, 2017
c33e9dc
starting on database storage for upload buffer
Gurtok Apr 19, 2017
ebfd9d0
starting on database storage for upload buffer
Gurtok Apr 20, 2017
f804949
starting on database storage for upload buffer
Gurtok May 10, 2017
aa598ce
starting on database storage for upload buffer
Gurtok May 13, 2017
1c12b3b
starting on database storage for upload buffer
Gurtok May 20, 2017
78ae94f
starting on database storage for upload buffer
Gurtok Jun 6, 2017
2bb2d54
starting on database storage for upload buffer
Gurtok Jun 10, 2017
d0db0eb
starting on database storage for upload buffer
Gurtok Jun 18, 2017
255f149
starting on database storage for upload buffer
Gurtok Jun 18, 2017
0a99d7d
starting on database storage for upload buffer
Gurtok Jun 19, 2017
0bdfd6a
Upload task now correctly sends data with each post request.
Gurtok Jun 26, 2017
77029bb
qwe
PandaConsult Jul 8, 2017
b1f2507
Start on broadcasting intents to the service manager from UI thread.
Gurtok Jul 10, 2017
3b2f2c1
Start on broadcasting intents to the service manager from UI thread.
Gurtok Jul 11, 2017
c3eaabb
Start on broadcasting intents to the service manager from UI thread.
Gurtok Jul 23, 2017
1b5288d
Start on broadcasting intents to the service manager from UI thread.
Gurtok Jul 24, 2017
9034a3e
Start on broadcasting intents to the service manager from UI thread.
Gurtok Jul 25, 2017
80a64e7
Start on broadcasting intents to the service manager from UI thread.
Gurtok Aug 8, 2017
636dec6
Start on broadcasting intents to the service manager from UI thread.
Gurtok Aug 10, 2017
2ab2d1f
Start on broadcasting intents to the service manager from UI thread.
Gurtok Aug 11, 2017
cfaea81
Start on broadcasting intents to the service manager from UI thread.
Gurtok Aug 11, 2017
6317dd8
Beginning of change to thread pooling.
Gurtok Aug 14, 2017
1e1131b
Beginning of change to thread pooling.
Gurtok Aug 21, 2017
67b5c37
Beginning of change to thread pooling.
Gurtok Aug 23, 2017
b06f354
Beginning of change to thread pooling.
Gurtok Aug 25, 2017
cda3b48
Beginning of change to thread pooling.
Gurtok Aug 28, 2017
805beb4
Beginning of change to thread pooling.
Gurtok Sep 23, 2017
0c25e6d
Beginning of change to thread pooling.
Gurtok Sep 23, 2017
e395ac8
working
Gurtok Sep 23, 2017
d2dcce2
working
Gurtok Sep 24, 2017
2971fdf
working
Gurtok Sep 26, 2017
1d2ddca
Finally stable
Gurtok Sep 28, 2017
c1ef355
Finally stable
Gurtok Sep 29, 2017
321af6c
QR scanning function, albeit roughly.
Gurtok Oct 3, 2017
8f5b8b8
QR scanning function, albeit roughly.
Gurtok Oct 3, 2017
2a7e184
QR scanning function, albeit roughly.
Gurtok Oct 13, 2017
1f3a338
QR scanning function, albeit roughly.
Gurtok Oct 21, 2017
323a252
Removing broadcasts, the overhead is too high.
Gurtok Oct 22, 2017
5938be7
Removing broadcasts, the overhead is too high.
Gurtok Oct 24, 2017
2b6f7ae
Removed broadcast receivers.
Gurtok Oct 25, 2017
ddefba0
Removed broadcast receivers.
Gurtok Oct 26, 2017
5828432
Removed broadcast receivers.
Gurtok Oct 27, 2017
8e96bda
Removed most instances of shared preferences. Many were not required.
Gurtok Oct 30, 2017
50c2857
Removed most instances of shared preferences. Many were not required.
Gurtok Nov 3, 2017
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
15 changes: 1 addition & 14 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions ElasticSensorDump/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,35 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion '26.0.2'

defaultConfig {
applicationId "ca.dungeons.sensordump"
minSdkVersion 20
minSdkVersion 25
//noinspection OldTargetApi
targetSdkVersion 25
versionCode 16
versionName "1.4.7"
versionName "2.1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
implementation 'com.google.android.gms:play-services:11.4.2'
}

apply plugin: 'com.google.gms.google-services'
20 changes: 19 additions & 1 deletion ElasticSensorDump/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA"/>

<application
android:allowBackup="true"
Expand All @@ -16,13 +20,27 @@
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".SettingsActivity"
android:label="Settings">
</activity>

<service
android:name=".EsdServiceManager"
android:exported="false"
android:label="ESD Service Manager">
</service>

<activity android:name=".ui.camera.BarcodeCaptureActivity">
</activity>

<activity android:name=".ui.camera.BarcodeMainActivity">
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
* Copyright (C) The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ca.dungeons.sensordump;

import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

class AudioRunnable implements Runnable {
/** Identify logcat messages. */
private final String logTag = "audioLogger";
/** We use this to indicate to the sensor thread if we have data to send. */
boolean hasData = false;
/** Use this control variable to stop the recording of audio data. */
private boolean stopThread = false;
/** A reference to the current audio sample "loudness" in terms of percentage of mic capability. */
private float amplitude = 0;
/** A reference to the current audio sample frequency. */
private float frequency = 0;
/** The sampling rate of the audio recording. */
private final int SAMPLE_RATE = 44100;
/** Short type array to feed to the recording API. */
private short[] audioBuffer;
/** Minimum buffer size required by AudioRecord API. */
private int bufferSize;

/**
* Default constructor.
* Determine minimum buffer size, get data from Android audio api.
* Set variables before executing the runnable.
*/
AudioRunnable() {
// Buffer size in bytes.
bufferSize = AudioRecord.getMinBufferSize(
SAMPLE_RATE, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT
);
// A check to make sure we are doing math on valid objects.
if (bufferSize == AudioRecord.ERROR || bufferSize == AudioRecord.ERROR_BAD_VALUE) {
bufferSize = SAMPLE_RATE * 2;
}
}

/** Stop the audio logging thread. */
void setStopAudioThread() {
stopThread = true;
}

/** Main run method. */
@SuppressWarnings("ConstantConditions")
@Override
public void run() {
// ?????
audioBuffer = new short[bufferSize / 2];
// New instance of Android audio recording api.
AudioRecord audioRecord = new AudioRecord(
MediaRecorder.AudioSource.DEFAULT,
SAMPLE_RATE,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT,
bufferSize
);

if (audioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
Log.e("Audio Error", "AudioRecord has not been initialized properly.");
return;
}
while (!stopThread) {
audioRecord.read(audioBuffer, 0, audioBuffer.length);
float lowest = 0;
float highest = 0;
int zeroes = 0;
int last_value = 0;
if (audioBuffer != null) {
// Exploring the buffer. Record the highest and lowest readings
for (short anAudioBuffer : audioBuffer) {
lowest = anAudioBuffer < lowest ? anAudioBuffer : lowest;
highest = anAudioBuffer > highest ? anAudioBuffer : highest;
// Down and coming up
if (anAudioBuffer > 0 && last_value < 0) {
zeroes++;
}
// Up and down
if (anAudioBuffer < 0 && last_value > 0) {
zeroes++;
}
last_value = anAudioBuffer;
// Calculate highest and lowest peak difference as a % of the max possible
// value
amplitude = (highest - lowest) / 65536 * 100;
// Take the count of the peaks in the time that we had based on the sample
// rate to calculate frequency
if (audioBuffer != null) {
float seconds = (float) audioBuffer.length / SAMPLE_RATE;
frequency = (float) zeroes / seconds / 2;

hasData = true;
}
}
}
}
audioRecord.stop();
audioRecord.release();
Log.i(logTag, "Audio recording stopping.");
}

/** Called on the sensor thread, delivers data to the sensor message handler. */
JSONObject getAudioData(JSONObject passedJson) {
if (passedJson != null) {
try {
passedJson.put("frequency", frequency);
passedJson.put("amplitude", amplitude);
} catch (JSONException jsonEx) {
Log.e(logTag, "Error adding data to json. ");
return passedJson;
}
}
audioBuffer = new short[bufferSize / 2];
hasData = false;
return passedJson;
}


}
Loading