Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c60a14b6ac | ||
|
|
4381ae78f8 | ||
|
|
81e04e370a | ||
|
|
b94a1d98b7 | ||
|
|
7c8610facb | ||
|
|
90a2aad491 | ||
|
|
065acefeb9 | ||
|
|
dda3d5693a |
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.android.application'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace 'com.example.ueberwachungssystem'
|
||||||
|
compileSdk 33
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.example.ueberwachungssystem"
|
||||||
|
minSdk 28
|
||||||
|
targetSdk 33
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
|
||||||
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
|
implementation 'com.google.android.material:material:1.8.0'
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
|
testImplementation 'junit:junit:4.13.2'
|
||||||
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
|
implementation 'com.jjoe64:graphview:4.2.2'
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
assertEquals("com.example.ueberwachungssystem", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
<!--<uses-permission android:name="android.permission.BLUETOOTH"/>-->
|
||||||
|
<!--<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>-->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.Ueberwachungssystem"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detector;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
/** Detection Report Class */
|
||||||
|
public class DetectionReport {
|
||||||
|
public String timeStamp;
|
||||||
|
public String detectionType;
|
||||||
|
public float detectedValue;
|
||||||
|
public String detectorID;
|
||||||
|
|
||||||
|
public DetectionReport(String detectorID, String detectionType, float detectedAmplitude) {
|
||||||
|
this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
|
||||||
|
this.detectionType = detectionType;
|
||||||
|
this.detectedValue = detectedAmplitude;
|
||||||
|
this.detectorID = detectorID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Get Detection Report in String format */
|
||||||
|
public String toString() {
|
||||||
|
String time = "Time: " + "[" + this.timeStamp + "]";
|
||||||
|
String type = "Type: " + "[" + this.detectionType + "]";
|
||||||
|
String value = "Value: " + "[" + this.detectedValue + "]";
|
||||||
|
String id = "ID: " + "[" + this.detectorID + "]";
|
||||||
|
|
||||||
|
return String.join("\t", time, type, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Debug Report */
|
||||||
|
public void log(String tag) {
|
||||||
|
Log.d(tag, this.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detector;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
|
abstract public class Detector {
|
||||||
|
private OnDetectionListener listener;
|
||||||
|
|
||||||
|
/** Constructor - takes context of current activity */
|
||||||
|
public Detector(Context context) {};
|
||||||
|
|
||||||
|
|
||||||
|
/** On Detection Listener - runs when violation is reported */
|
||||||
|
public interface OnDetectionListener {
|
||||||
|
void onDetection(@NonNull DetectionReport detectionReport);
|
||||||
|
}
|
||||||
|
public void setOnDetectionListener(@NonNull OnDetectionListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Triggers onDetectionListener - call this to trigger violation/alarm */
|
||||||
|
public void reportViolation(String detectorID, String detectionType, float amplitude) {
|
||||||
|
if (listener != null) {
|
||||||
|
DetectionReport detectionReport = new DetectionReport(detectorID, detectionType, amplitude);
|
||||||
|
listener.onDetection(detectionReport);
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("No listener set for violation reporting");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Starts Detection (abstract method: needs to be overridden in child class) */
|
||||||
|
public abstract void startDetection();
|
||||||
|
|
||||||
|
/** Stops Detection (abstract method: needs to be overridden in child class) */
|
||||||
|
public abstract void stopDetection();
|
||||||
|
}
|
||||||
@@ -0,0 +1,421 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detector;
|
||||||
|
|
||||||
|
import static java.lang.Math.*;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.media.AudioFormat;
|
||||||
|
import android.media.AudioRecord;
|
||||||
|
import android.media.MediaRecorder;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex;
|
||||||
|
import com.example.ueberwachungssystem.Detector.Signalverarbeitung.FFT;
|
||||||
|
import com.example.ueberwachungssystem.Detector.logger.Logger;
|
||||||
|
import com.jjoe64.graphview.GraphView;
|
||||||
|
import com.jjoe64.graphview.series.DataPoint;
|
||||||
|
import com.jjoe64.graphview.series.LineGraphSeries;
|
||||||
|
|
||||||
|
public class MicrophoneDetector extends Detector {
|
||||||
|
/**
|
||||||
|
* Constructor - takes context of current activity
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final int RECHTEANFORDERUNG_MIKROFON = 1;
|
||||||
|
|
||||||
|
private AufnahmeTask aufnahmeTask;
|
||||||
|
public boolean armed = false;
|
||||||
|
public int Schwellwert_Alarm = 100;
|
||||||
|
private Activity MainActivityForClass;
|
||||||
|
|
||||||
|
public MicrophoneDetector(Context context) {
|
||||||
|
super(context);
|
||||||
|
MainActivityForClass = (Activity) context;
|
||||||
|
|
||||||
|
if (!istZugriffAufMikrofonErlaubt()) {
|
||||||
|
zugriffAufMikrofonAnfordern();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startDetection() {
|
||||||
|
|
||||||
|
if (!istZugriffAufMikrofonErlaubt()) {
|
||||||
|
zugriffAufMikrofonAnfordern();
|
||||||
|
}
|
||||||
|
if (istZugriffAufMikrofonErlaubt()) {
|
||||||
|
aufnahmeTask = new AufnahmeTask();
|
||||||
|
aufnahmeTask.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopDetection() {
|
||||||
|
if (aufnahmeTask != null) {
|
||||||
|
aufnahmeTask.cancel(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean istZugriffAufMikrofonErlaubt() {
|
||||||
|
if (ContextCompat.checkSelfPermission(MainActivityForClass, android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Log.d("0","Zugriff auf Mikrofon ist verboten.");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Log.d("0","Zugriff auf Mikrofon ist erlaubt.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void zugriffAufMikrofonAnfordern() {
|
||||||
|
ActivityCompat.requestPermissions(MainActivityForClass, new String[]{Manifest.permission.RECORD_AUDIO}, RECHTEANFORDERUNG_MIKROFON);
|
||||||
|
}
|
||||||
|
|
||||||
|
class AufnahmeTask extends AsyncTask<Long, Verarbeitungsergebnis, Void> {
|
||||||
|
private AudioRecord recorder;
|
||||||
|
private final int sampleRateInHz = 44100;
|
||||||
|
private final int channelConfig = AudioFormat.CHANNEL_IN_MONO;
|
||||||
|
private final int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||||
|
private int minPufferGroesseInBytes;
|
||||||
|
private int pufferGroesseInBytes;
|
||||||
|
private RingPuffer ringPuffer = new RingPuffer(10);
|
||||||
|
private float kalibierWert;
|
||||||
|
private DetectionReport detectionReport;
|
||||||
|
|
||||||
|
AufnahmeTask() {
|
||||||
|
minPufferGroesseInBytes = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
|
||||||
|
pufferGroesseInBytes = minPufferGroesseInBytes * 2;
|
||||||
|
if (ActivityCompat.checkSelfPermission(MainActivityForClass, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// TODO: Consider calling
|
||||||
|
// ActivityCompat#requestPermissions
|
||||||
|
// here to request the missing permissions, and then overriding
|
||||||
|
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
||||||
|
// int[] grantResults)
|
||||||
|
// to handle the case where the user grants the permission. See the documentation
|
||||||
|
// for ActivityCompat#requestPermissions for more details.
|
||||||
|
ActivityCompat.requestPermissions(MainActivityForClass, new String[]{Manifest.permission.RECORD_AUDIO}, RECHTEANFORDERUNG_MIKROFON);
|
||||||
|
}
|
||||||
|
|
||||||
|
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRateInHz, channelConfig, audioFormat, pufferGroesseInBytes);
|
||||||
|
|
||||||
|
Log.d("0","Puffergroeße: "+ minPufferGroesseInBytes + " " + pufferGroesseInBytes);
|
||||||
|
Log.d("0","Recorder (SR, CH): "+ recorder.getSampleRate() + " " + recorder.getChannelCount());
|
||||||
|
|
||||||
|
int anzahlBytesProAbtastwert;
|
||||||
|
String s;
|
||||||
|
switch (recorder.getAudioFormat()) {
|
||||||
|
case AudioFormat.ENCODING_PCM_8BIT:
|
||||||
|
s = "8 Bit PCM ";
|
||||||
|
anzahlBytesProAbtastwert = 1;
|
||||||
|
break;
|
||||||
|
case AudioFormat.ENCODING_PCM_16BIT:
|
||||||
|
s = "16 Bit PCM";
|
||||||
|
anzahlBytesProAbtastwert = 2;
|
||||||
|
break;
|
||||||
|
case AudioFormat.ENCODING_PCM_FLOAT:
|
||||||
|
s = "Float PCM";
|
||||||
|
anzahlBytesProAbtastwert = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (recorder.getChannelConfiguration()) {
|
||||||
|
case AudioFormat.CHANNEL_IN_MONO:
|
||||||
|
s = "Mono";
|
||||||
|
break;
|
||||||
|
case AudioFormat.CHANNEL_IN_STEREO:
|
||||||
|
s = "Stereo";
|
||||||
|
anzahlBytesProAbtastwert *= 2;
|
||||||
|
break;
|
||||||
|
case AudioFormat.CHANNEL_INVALID:
|
||||||
|
s = "ungültig";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d("0","Konfiguration: "+ s);
|
||||||
|
|
||||||
|
int pufferGroesseInAnzahlAbtastwerten = pufferGroesseInBytes / anzahlBytesProAbtastwert;
|
||||||
|
int pufferGroesseInMillisekunden = 1000 * pufferGroesseInAnzahlAbtastwerten / recorder.getSampleRate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Long... params) {
|
||||||
|
recorder.startRecording();
|
||||||
|
short[] puffer = new short[pufferGroesseInBytes / 2];
|
||||||
|
long lastTime = System.currentTimeMillis();
|
||||||
|
float verarbeitungsrate = 0;
|
||||||
|
final int maxZaehlerZeitMessung = 10;
|
||||||
|
int zaehlerZeitMessung = 0;
|
||||||
|
int anzahlVerarbeitet = 0;
|
||||||
|
GleitenderMittelwert gleitenderMittelwert = new GleitenderMittelwert(0.3f);
|
||||||
|
|
||||||
|
//Kalibrierung
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000); // Time to lay down the phone
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
for (i = 0; i < 20; i++) {
|
||||||
|
int n = recorder.read(puffer, 0, puffer.length);
|
||||||
|
Verarbeitungsergebnis kalibrierErgebnis = verarbeiten(puffer, n);
|
||||||
|
kalibierWert += kalibrierErgebnis.maxAmp;
|
||||||
|
try {
|
||||||
|
Thread.sleep(50);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kalibierWert = kalibierWert/i;
|
||||||
|
|
||||||
|
// __Part of FFT__
|
||||||
|
// Complex[] zeitSignal = new Complex[puffer.length];
|
||||||
|
// for (int j = 0; j < puffer.length; j++) {
|
||||||
|
// zeitSignal[j] = new Complex(puffer[j], 0);
|
||||||
|
// }
|
||||||
|
// Complex[] spektrum = FFT.fft(zeitSignal);
|
||||||
|
// double[] spektrum = calculateFFT(puffer);
|
||||||
|
// DataPoint AddPoint;
|
||||||
|
// LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(new DataPoint[]{});
|
||||||
|
// for (i = 0; i < spektrum.length; i++) {
|
||||||
|
// AddPoint = new DataPoint(i, spektrum[i]);
|
||||||
|
// series.appendData(AddPoint, true, spektrum.length);
|
||||||
|
// }
|
||||||
|
// graph.addSeries(series);
|
||||||
|
|
||||||
|
for (; ; ) {
|
||||||
|
if (aufnahmeTask.isCancelled()) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
int n = recorder.read(puffer, 0, puffer.length);
|
||||||
|
Verarbeitungsergebnis ergebnis = verarbeiten(puffer, n);
|
||||||
|
anzahlVerarbeitet += n;
|
||||||
|
// __Part of FFT__
|
||||||
|
// spektrum = calculateFFT(puffer);
|
||||||
|
// LineGraphSeries<DataPoint> newseries = new LineGraphSeries<DataPoint>(new DataPoint[]{});
|
||||||
|
// for (i = 0; i < spektrum.length; i++) {
|
||||||
|
// AddPoint = new DataPoint(i, spektrum[i]);
|
||||||
|
// newseries.appendData(AddPoint, true, spektrum.length);
|
||||||
|
// }
|
||||||
|
|
||||||
|
zaehlerZeitMessung++;
|
||||||
|
if (zaehlerZeitMessung == maxZaehlerZeitMessung) {
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
long deltaTime = time - lastTime;
|
||||||
|
verarbeitungsrate = 1000.0f * anzahlVerarbeitet / deltaTime;
|
||||||
|
verarbeitungsrate = gleitenderMittelwert.mittel(verarbeitungsrate);
|
||||||
|
zaehlerZeitMessung = 0;
|
||||||
|
anzahlVerarbeitet = 0;
|
||||||
|
lastTime = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ergebnis.verarbeitungsrate = (int) verarbeitungsrate;
|
||||||
|
publishProgress(ergebnis);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(10);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recorder.release();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Verarbeitungsergebnis verarbeiten(short[] daten, int n) {
|
||||||
|
String status;
|
||||||
|
short maxAmp = -1;
|
||||||
|
if (n == AudioRecord.ERROR_INVALID_OPERATION) {
|
||||||
|
status = "ERROR_INVALID_OPERATION";
|
||||||
|
} else if (n == AudioRecord.ERROR_BAD_VALUE) {
|
||||||
|
status = "ERROR_BAD_VALUE";
|
||||||
|
} else {
|
||||||
|
status = "OK";
|
||||||
|
short max = 0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (daten[i] > max) {
|
||||||
|
max = daten[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ringPuffer.hinzufuegen(max);
|
||||||
|
maxAmp = ringPuffer.maximum();
|
||||||
|
if (maxAmp <= Schwellwert_Alarm+kalibierWert) {
|
||||||
|
armed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Verarbeitungsergebnis(status, maxAmp, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onProgressUpdate(Verarbeitungsergebnis... progress) {
|
||||||
|
super.onProgressUpdate(progress);
|
||||||
|
float maxAmpPrint = round(20*log10(abs(progress[0].maxAmp/1.0)));
|
||||||
|
float kalibierWertPrint = round(20*log10(abs(kalibierWert)));
|
||||||
|
Log.d("0","VR, Max, Kal:" + progress[0].verarbeitungsrate + ", " + maxAmpPrint
|
||||||
|
+ " dB, " + kalibierWertPrint + " dB");
|
||||||
|
|
||||||
|
if (progress[0].maxAmp >= Schwellwert_Alarm+kalibierWert && armed == true) {
|
||||||
|
armed = false;
|
||||||
|
detectionReport = new DetectionReport("Mic1", "Audio", maxAmpPrint);
|
||||||
|
reportViolation("Mic1", "Audio", maxAmpPrint);
|
||||||
|
Log.d("1",detectionReport.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double[] calculateFFT(short[] zeitsignal)
|
||||||
|
{
|
||||||
|
byte signal[] = new byte[zeitsignal.length];
|
||||||
|
// loops through all the values of a Short
|
||||||
|
for (int i = 0; i < zeitsignal.length-1; i++) {
|
||||||
|
signal[i] = (byte) (zeitsignal[i]);
|
||||||
|
signal[i+1] = (byte) (zeitsignal[i] >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
final int mNumberOfFFTPoints =1024;
|
||||||
|
double mMaxFFTSample;
|
||||||
|
|
||||||
|
double temp;
|
||||||
|
Complex[] y;
|
||||||
|
Complex[] complexSignal = new Complex[mNumberOfFFTPoints];
|
||||||
|
double[] absSignal = new double[mNumberOfFFTPoints/2];
|
||||||
|
|
||||||
|
for(int i = 0; i < mNumberOfFFTPoints; i++){
|
||||||
|
temp = (double)((signal[2*i] & 0xFF) | (signal[2*i+1] << 8)) / 32768.0F;
|
||||||
|
complexSignal[i] = new Complex(temp,0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
y = FFT.fft(complexSignal);
|
||||||
|
|
||||||
|
mMaxFFTSample = 0.0;
|
||||||
|
for(int i = 0; i < (mNumberOfFFTPoints/2); i++)
|
||||||
|
{
|
||||||
|
absSignal[i] = y[i].abs();
|
||||||
|
// absSignal[i] = Math.sqrt(Math.pow(y[i].re(), 2) + Math.pow(y[i].im(), 2));
|
||||||
|
// if(absSignal[i] > mMaxFFTSample)
|
||||||
|
// {
|
||||||
|
// mMaxFFTSample = absSignal[i];
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
return absSignal;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Verarbeitungsergebnis {
|
||||||
|
String status;
|
||||||
|
short maxAmp;
|
||||||
|
int verarbeitungsrate;
|
||||||
|
Verarbeitungsergebnis(String status, short maxAmp, int verarbeitungsrate) {
|
||||||
|
this.status = status;
|
||||||
|
this.maxAmp = maxAmp;
|
||||||
|
this.verarbeitungsrate = verarbeitungsrate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RingPuffer {
|
||||||
|
private short[] puffer;
|
||||||
|
private final int laenge;
|
||||||
|
private int anzahlEnthaltenerDaten;
|
||||||
|
private int position;
|
||||||
|
|
||||||
|
public RingPuffer(int n) {
|
||||||
|
laenge = n;
|
||||||
|
anzahlEnthaltenerDaten = 0;
|
||||||
|
position = 0;
|
||||||
|
puffer = new short[laenge];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hinzufuegen(short wert) {
|
||||||
|
puffer[position] = wert;
|
||||||
|
position++;
|
||||||
|
if (position >= laenge) {
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
if (anzahlEnthaltenerDaten < laenge) {
|
||||||
|
anzahlEnthaltenerDaten++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hinzufuegen(short[] daten) {
|
||||||
|
for (short d : daten) {
|
||||||
|
puffer[position] = d;
|
||||||
|
position++;
|
||||||
|
if (position >= laenge) {
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (anzahlEnthaltenerDaten < laenge) {
|
||||||
|
anzahlEnthaltenerDaten += daten.length;
|
||||||
|
if (anzahlEnthaltenerDaten >= laenge) {
|
||||||
|
anzahlEnthaltenerDaten = laenge;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public short maximum() {
|
||||||
|
short max = 0;
|
||||||
|
for (int i = 0; i < anzahlEnthaltenerDaten; i++) {
|
||||||
|
if (puffer[i] > max) {
|
||||||
|
max = puffer[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float mittelwert() {
|
||||||
|
float summe = 0;
|
||||||
|
for (int i = 0; i < anzahlEnthaltenerDaten; i++) {
|
||||||
|
summe += puffer[i];
|
||||||
|
}
|
||||||
|
return summe / anzahlEnthaltenerDaten;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GleitenderMittelwert {
|
||||||
|
private final float wichtungNeuerWert;
|
||||||
|
private final float wichtungAlterWert;
|
||||||
|
private float mittelwert = 0;
|
||||||
|
private boolean istMittelwertGesetzt = false;
|
||||||
|
|
||||||
|
GleitenderMittelwert(float wichtungNeuerWert) {
|
||||||
|
this.wichtungNeuerWert = wichtungNeuerWert;
|
||||||
|
this.wichtungAlterWert = 1 - this.wichtungNeuerWert;
|
||||||
|
}
|
||||||
|
|
||||||
|
float MittelwertPuffer(short[] puffer) {
|
||||||
|
|
||||||
|
for (int i = 0; i < puffer.length; i++) {
|
||||||
|
mittelwert = Math.abs(puffer[i]);
|
||||||
|
}
|
||||||
|
mittelwert = mittelwert/puffer.length;
|
||||||
|
|
||||||
|
return mittelwert;
|
||||||
|
}
|
||||||
|
|
||||||
|
float mittel(float wert) {
|
||||||
|
if (istMittelwertGesetzt) {
|
||||||
|
mittelwert = wert * wichtungNeuerWert + mittelwert * wichtungAlterWert;
|
||||||
|
} else {
|
||||||
|
mittelwert = wert;
|
||||||
|
istMittelwertGesetzt = true;
|
||||||
|
}
|
||||||
|
return mittelwert;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detector.Signalverarbeitung;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class Complex {
|
||||||
|
private final double re; // the real part
|
||||||
|
private final double im; // the imaginary part
|
||||||
|
|
||||||
|
// create a new object with the given real and imaginary parts
|
||||||
|
public Complex(double real, double imag) {
|
||||||
|
re = real;
|
||||||
|
im = imag;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a string representation of the invoking com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object
|
||||||
|
public String toString() {
|
||||||
|
if (im == 0) return re + "";
|
||||||
|
if (re == 0) return im + "i";
|
||||||
|
if (im < 0) return re + " - " + (-im) + "i";
|
||||||
|
return re + " + " + im + "i";
|
||||||
|
}
|
||||||
|
|
||||||
|
// return abs/modulus/magnitude
|
||||||
|
public double abs() {
|
||||||
|
return Math.hypot(re, im);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return angle/phase/argument, normalized to be between -pi and pi
|
||||||
|
public double phase() {
|
||||||
|
return Math.atan2(im, re);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this + b)
|
||||||
|
public Complex plus(Complex b) {
|
||||||
|
Complex a = this; // invoking object
|
||||||
|
double real = a.re + b.re;
|
||||||
|
double imag = a.im + b.im;
|
||||||
|
return new Complex(real, imag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this - b)
|
||||||
|
public Complex minus(Complex b) {
|
||||||
|
Complex a = this;
|
||||||
|
double real = a.re - b.re;
|
||||||
|
double imag = a.im - b.im;
|
||||||
|
return new Complex(real, imag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this * b)
|
||||||
|
public Complex times(Complex b) {
|
||||||
|
Complex a = this;
|
||||||
|
double real = a.re * b.re - a.im * b.im;
|
||||||
|
double imag = a.re * b.im + a.im * b.re;
|
||||||
|
return new Complex(real, imag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new object whose value is (this * alpha)
|
||||||
|
public Complex scale(double alpha) {
|
||||||
|
return new Complex(alpha * re, alpha * im);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the conjugate of this
|
||||||
|
public Complex conjugate() {
|
||||||
|
return new Complex(re, -im);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the reciprocal of this
|
||||||
|
public Complex reciprocal() {
|
||||||
|
double scale = re * re + im * im;
|
||||||
|
return new Complex(re / scale, -im / scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the real or imaginary part
|
||||||
|
public double re() {
|
||||||
|
return re;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double im() {
|
||||||
|
return im;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a / b
|
||||||
|
public Complex divides(Complex b) {
|
||||||
|
Complex a = this;
|
||||||
|
return a.times(b.reciprocal());
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex exponential of this
|
||||||
|
public Complex exp() {
|
||||||
|
return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im));
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex sine of this
|
||||||
|
public Complex sin() {
|
||||||
|
return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im));
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex cosine of this
|
||||||
|
public Complex cos() {
|
||||||
|
return new Complex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im));
|
||||||
|
}
|
||||||
|
|
||||||
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex tangent of this
|
||||||
|
public Complex tan() {
|
||||||
|
return sin().divides(cos());
|
||||||
|
}
|
||||||
|
|
||||||
|
// a static version of plus
|
||||||
|
public static Complex plus(Complex a, Complex b) {
|
||||||
|
double real = a.re + b.re;
|
||||||
|
double imag = a.im + b.im;
|
||||||
|
Complex sum = new Complex(real, imag);
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
// See Section 3.3.
|
||||||
|
public boolean equals(Object x) {
|
||||||
|
if (x == null) return false;
|
||||||
|
if (this.getClass() != x.getClass()) return false;
|
||||||
|
Complex that = (Complex) x;
|
||||||
|
return (this.re == that.re) && (this.im == that.im);
|
||||||
|
}
|
||||||
|
|
||||||
|
// See Section 3.3.
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(re, im);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sample client for testing
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Complex a = new Complex(5.0, 6.0);
|
||||||
|
Complex b = new Complex(-3.0, 4.0);
|
||||||
|
|
||||||
|
System.out.println("a = " + a);
|
||||||
|
System.out.println("b = " + b);
|
||||||
|
System.out.println("Re(a) = " + a.re());
|
||||||
|
System.out.println("Im(a) = " + a.im());
|
||||||
|
System.out.println("b + a = " + b.plus(a));
|
||||||
|
System.out.println("a - b = " + a.minus(b));
|
||||||
|
System.out.println("a * b = " + a.times(b));
|
||||||
|
System.out.println("b * a = " + b.times(a));
|
||||||
|
System.out.println("a / b = " + a.divides(b));
|
||||||
|
System.out.println("(a / b) * b = " + a.divides(b).times(b));
|
||||||
|
System.out.println("conj(a) = " + a.conjugate());
|
||||||
|
System.out.println("|a| = " + a.abs());
|
||||||
|
System.out.println("tan(a) = " + a.tan());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,246 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detector.Signalverarbeitung;
|
||||||
|
// Source: https://introcs.cs.princeton.edu/java/97data/FFT.java.html
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* Compilation: javac FFT.java
|
||||||
|
* Execution: java FFT n
|
||||||
|
* Dependencies: com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex.java
|
||||||
|
*
|
||||||
|
* Compute the FFT and inverse FFT of a length n complex sequence
|
||||||
|
* using the radix 2 Cooley-Tukey algorithm.
|
||||||
|
* Bare bones implementation that runs in O(n log n) time and O(n)
|
||||||
|
* space. Our goal is to optimize the clarity of the code, rather
|
||||||
|
* than performance.
|
||||||
|
*
|
||||||
|
* This implementation uses the primitive root of unity w = e^(-2 pi i / n).
|
||||||
|
* Some resources use w = e^(2 pi i / n).
|
||||||
|
*
|
||||||
|
* Reference: https://www.cs.princeton.edu/~wayne/kleinberg-tardos/pdf/05DivideAndConquerII.pdf
|
||||||
|
*
|
||||||
|
* Limitations
|
||||||
|
* -----------
|
||||||
|
* - assumes n is a power of 2
|
||||||
|
*
|
||||||
|
* - not the most memory efficient algorithm (because it uses
|
||||||
|
* an object type for representing complex numbers and because
|
||||||
|
* it re-allocates memory for the subarray, instead of doing
|
||||||
|
* in-place or reusing a single temporary array)
|
||||||
|
*
|
||||||
|
* For an in-place radix 2 Cooley-Tukey FFT, see
|
||||||
|
* https://introcs.cs.princeton.edu/java/97data/InplaceFFT.java.html
|
||||||
|
*
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
public class FFT {
|
||||||
|
|
||||||
|
// compute the FFT of x[], assuming its length n is a power of 2
|
||||||
|
public static Complex[] fft(Complex[] x) {
|
||||||
|
int n = x.length;
|
||||||
|
|
||||||
|
// base case
|
||||||
|
if (n == 1) return new Complex[]{x[0]};
|
||||||
|
|
||||||
|
// radix 2 Cooley-Tukey FFT
|
||||||
|
if (n % 2 != 0) {
|
||||||
|
throw new IllegalArgumentException("n is not a power of 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute FFT of even terms
|
||||||
|
Complex[] even = new Complex[n / 2];
|
||||||
|
for (int k = 0; k < n / 2; k++) {
|
||||||
|
even[k] = x[2 * k];
|
||||||
|
}
|
||||||
|
Complex[] evenFFT = fft(even);
|
||||||
|
|
||||||
|
// compute FFT of odd terms
|
||||||
|
Complex[] odd = even; // reuse the array (to avoid n log n space)
|
||||||
|
for (int k = 0; k < n / 2; k++) {
|
||||||
|
odd[k] = x[2 * k + 1];
|
||||||
|
}
|
||||||
|
Complex[] oddFFT = fft(odd);
|
||||||
|
|
||||||
|
// combine
|
||||||
|
Complex[] y = new Complex[n];
|
||||||
|
for (int k = 0; k < n / 2; k++) {
|
||||||
|
double kth = -2 * k * Math.PI / n;
|
||||||
|
Complex wk = new Complex(Math.cos(kth), Math.sin(kth));
|
||||||
|
y[k] = evenFFT[k].plus(wk.times(oddFFT[k]));
|
||||||
|
y[k + n / 2] = evenFFT[k].minus(wk.times(oddFFT[k]));
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// compute the inverse FFT of x[], assuming its length n is a power of 2
|
||||||
|
public static Complex[] ifft(Complex[] x) {
|
||||||
|
int n = x.length;
|
||||||
|
Complex[] y = new Complex[n];
|
||||||
|
|
||||||
|
// take conjugate
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
y[i] = x[i].conjugate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute forward FFT
|
||||||
|
y = fft(y);
|
||||||
|
|
||||||
|
// take conjugate again
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
y[i] = y[i].conjugate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// divide by n
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
y[i] = y[i].scale(1.0 / n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return y;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute the circular convolution of x and y
|
||||||
|
public static Complex[] cconvolve(Complex[] x, Complex[] y) {
|
||||||
|
|
||||||
|
// should probably pad x and y with 0s so that they have same length
|
||||||
|
// and are powers of 2
|
||||||
|
if (x.length != y.length) {
|
||||||
|
throw new IllegalArgumentException("Dimensions don't agree");
|
||||||
|
}
|
||||||
|
|
||||||
|
int n = x.length;
|
||||||
|
|
||||||
|
// compute FFT of each sequence
|
||||||
|
Complex[] a = fft(x);
|
||||||
|
Complex[] b = fft(y);
|
||||||
|
|
||||||
|
// point-wise multiply
|
||||||
|
Complex[] c = new Complex[n];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
c[i] = a[i].times(b[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute inverse FFT
|
||||||
|
return ifft(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// compute the linear convolution of x and y
|
||||||
|
public static Complex[] convolve(Complex[] x, Complex[] y) {
|
||||||
|
Complex ZERO = new Complex(0, 0);
|
||||||
|
|
||||||
|
Complex[] a = new Complex[2 * x.length];
|
||||||
|
for (int i = 0; i < x.length; i++) a[i] = x[i];
|
||||||
|
for (int i = x.length; i < 2 * x.length; i++) a[i] = ZERO;
|
||||||
|
|
||||||
|
Complex[] b = new Complex[2 * y.length];
|
||||||
|
for (int i = 0; i < y.length; i++) b[i] = y[i];
|
||||||
|
for (int i = y.length; i < 2 * y.length; i++) b[i] = ZERO;
|
||||||
|
|
||||||
|
return cconvolve(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute the DFT of x[] via brute force (n^2 time)
|
||||||
|
public static Complex[] dft(Complex[] x) {
|
||||||
|
int n = x.length;
|
||||||
|
Complex ZERO = new Complex(0, 0);
|
||||||
|
Complex[] y = new Complex[n];
|
||||||
|
for (int k = 0; k < n; k++) {
|
||||||
|
y[k] = ZERO;
|
||||||
|
for (int j = 0; j < n; j++) {
|
||||||
|
int power = (k * j) % n;
|
||||||
|
double kth = -2 * power * Math.PI / n;
|
||||||
|
Complex wkj = new Complex(Math.cos(kth), Math.sin(kth));
|
||||||
|
y[k] = y[k].plus(x[j].times(wkj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// display an array of com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex numbers to standard output
|
||||||
|
public static void show(Complex[] x, String title) {
|
||||||
|
System.out.println(title);
|
||||||
|
System.out.println("-------------------");
|
||||||
|
for (int i = 0; i < x.length; i++) {
|
||||||
|
System.out.println(x[i]);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Test client and sample execution
|
||||||
|
*
|
||||||
|
* % java FFT 4
|
||||||
|
* x
|
||||||
|
* -------------------
|
||||||
|
* -0.03480425839330703
|
||||||
|
* 0.07910192950176387
|
||||||
|
* 0.7233322451735928
|
||||||
|
* 0.1659819820667019
|
||||||
|
*
|
||||||
|
* y = fft(x)
|
||||||
|
* -------------------
|
||||||
|
* 0.9336118983487516
|
||||||
|
* -0.7581365035668999 + 0.08688005256493803i
|
||||||
|
* 0.44344407521182005
|
||||||
|
* -0.7581365035668999 - 0.08688005256493803i
|
||||||
|
*
|
||||||
|
* z = ifft(y)
|
||||||
|
* -------------------
|
||||||
|
* -0.03480425839330703
|
||||||
|
* 0.07910192950176387 + 2.6599344570851287E-18i
|
||||||
|
* 0.7233322451735928
|
||||||
|
* 0.1659819820667019 - 2.6599344570851287E-18i
|
||||||
|
*
|
||||||
|
* c = cconvolve(x, x)
|
||||||
|
* -------------------
|
||||||
|
* 0.5506798633981853
|
||||||
|
* 0.23461407150576394 - 4.033186818023279E-18i
|
||||||
|
* -0.016542951108772352
|
||||||
|
* 0.10288019294318276 + 4.033186818023279E-18i
|
||||||
|
*
|
||||||
|
* d = convolve(x, x)
|
||||||
|
* -------------------
|
||||||
|
* 0.001211336402308083 - 3.122502256758253E-17i
|
||||||
|
* -0.005506167987577068 - 5.058885073636224E-17i
|
||||||
|
* -0.044092969479563274 + 2.1934338938072244E-18i
|
||||||
|
* 0.10288019294318276 - 3.6147323062478115E-17i
|
||||||
|
* 0.5494685269958772 + 3.122502256758253E-17i
|
||||||
|
* 0.240120239493341 + 4.655566391833896E-17i
|
||||||
|
* 0.02755001837079092 - 2.1934338938072244E-18i
|
||||||
|
* 4.01805098805014E-17i
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int n = Integer.parseInt(args[0]);
|
||||||
|
Complex[] x = new Complex[n];
|
||||||
|
|
||||||
|
// original data
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
x[i] = new Complex(i, 0);
|
||||||
|
}
|
||||||
|
show(x, "x");
|
||||||
|
|
||||||
|
// FFT of original data
|
||||||
|
Complex[] y = fft(x);
|
||||||
|
show(y, "y = fft(x)");
|
||||||
|
|
||||||
|
// FFT of original data
|
||||||
|
Complex[] y2 = dft(x);
|
||||||
|
show(y2, "y2 = dft(x)");
|
||||||
|
|
||||||
|
// take inverse FFT
|
||||||
|
Complex[] z = ifft(y);
|
||||||
|
show(z, "z = ifft(y)");
|
||||||
|
|
||||||
|
// circular convolution of x with itself
|
||||||
|
Complex[] c = cconvolve(x, x);
|
||||||
|
show(c, "c = cconvolve(x, x)");
|
||||||
|
|
||||||
|
// linear convolution of x with itself
|
||||||
|
Complex[] d = convolve(x, x);
|
||||||
|
show(d, "d = convolve(x, x)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Switch;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.Detector.DetectionReport;
|
||||||
|
import com.example.ueberwachungssystem.Detector.Detector;
|
||||||
|
import com.example.ueberwachungssystem.Detector.MicrophoneDetector;
|
||||||
|
import com.jjoe64.graphview.GraphView;
|
||||||
|
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
private TextView tv_log;
|
||||||
|
MicrophoneDetector Mic;
|
||||||
|
private Switch TglBtn_Mic;
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
tv_log = (TextView) findViewById(R.id.tv_log); //Set textview for showing logged content
|
||||||
|
Log.d("Main",this.getClass().getSimpleName() + ".onCreate");
|
||||||
|
Mic = new MicrophoneDetector(this);
|
||||||
|
setupMic();
|
||||||
|
Mic.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
|
@Override
|
||||||
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
|
Log.d("Main", "Detection erkannt!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
Log.d("Main",this.getClass().getSimpleName() + ".onResume");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
Log.d("Main",this.getClass().getSimpleName() + ".onPause");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupMic() {
|
||||||
|
TglBtn_Mic = (Switch) findViewById(R.id.TglBtn_Mic);
|
||||||
|
TglBtn_Mic.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (v == TglBtn_Mic) {
|
||||||
|
Log.d("Main","onClick toggleButtonThread " + TglBtn_Mic.isChecked());
|
||||||
|
if (TglBtn_Mic.isChecked()) {
|
||||||
|
Mic.startDetection();
|
||||||
|
} else {
|
||||||
|
Mic.stopDetection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_log"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Log"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/TglBtn_Mic" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/TglBtn_Mic"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Mic"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
@@ -0,0 +1,16 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.Ueberwachungssystem" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
|
<!-- Primary brand color. -->
|
||||||
|
<item name="colorPrimary">@color/purple_200</item>
|
||||||
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
|
<item name="colorOnPrimary">@color/black</item>
|
||||||
|
<!-- Secondary brand color. -->
|
||||||
|
<item name="colorSecondary">@color/teal_200</item>
|
||||||
|
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||||
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
|
<!-- Status bar color. -->
|
||||||
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Ueberwachungssystem</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme. -->
|
||||||
|
<style name="Theme.Ueberwachungssystem" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
|
<!-- Primary brand color. -->
|
||||||
|
<item name="colorPrimary">@color/purple_500</item>
|
||||||
|
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||||
|
<item name="colorOnPrimary">@color/white</item>
|
||||||
|
<!-- Secondary brand color. -->
|
||||||
|
<item name="colorSecondary">@color/teal_200</item>
|
||||||
|
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||||
|
<item name="colorOnSecondary">@color/black</item>
|
||||||
|
<!-- Status bar color. -->
|
||||||
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
|
for details.
|
||||||
|
Note: This file is ignored for devices older that API 31
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
|
-->
|
||||||
|
<full-backup-content>
|
||||||
|
<!--
|
||||||
|
<include domain="sharedpref" path="."/>
|
||||||
|
<exclude domain="sharedpref" path="device.xml"/>
|
||||||
|
-->
|
||||||
|
</full-backup-content>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
id 'com.android.application' version '7.4.2' apply false
|
||||||
|
id 'com.android.library' version '7.4.2' apply false
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app's APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.useAndroidX=true
|
||||||
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
|
# thereby reducing the size of the R class for that library
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
|
android.enableJetifier=true
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#Thu May 11 15:04:30 CEST 2023
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
@@ -0,0 +1,185 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# https://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.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
##
|
||||||
|
## Gradle start up script for UN*X
|
||||||
|
##
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
|
while [ -h "$PRG" ] ; do
|
||||||
|
ls=`ls -ld "$PRG"`
|
||||||
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
|
PRG="$link"
|
||||||
|
else
|
||||||
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
|
else
|
||||||
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD="java"
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
|
if [ $? -eq 0 ] ; then
|
||||||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
ulimit -n $MAX_FD
|
||||||
|
if [ $? -ne 0 ] ; then
|
||||||
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
|
if $darwin; then
|
||||||
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
|
SEP=""
|
||||||
|
for dir in $ROOTDIRSRAW ; do
|
||||||
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
|
SEP="|"
|
||||||
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%" == "" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = "Ueberwachungssystem"
|
||||||
|
include ':app'
|
||||||