X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosdroid%2Fapp%2Fsrc%2Fmain%2Fjava%2Forg%2Faltusmetrum%2FAltosDroid%2FTelemetryLogger.java;fp=altosdroid%2Fapp%2Fsrc%2Fmain%2Fjava%2Forg%2Faltusmetrum%2FAltosDroid%2FTelemetryLogger.java;h=ae5702b48b87dfa9cca64bcaa443057724b6f5f3;hp=589e15d07a351d96e6f1d0011521f2726191b758;hb=eb39995ded6b564efcb5a5312119d2672b437bc8;hpb=3488d86de2e114a46e59bd4d2a2d7b95bf633963 diff --git a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryLogger.java b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryLogger.java index 589e15d0..ae5702b4 100644 --- a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryLogger.java +++ b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryLogger.java @@ -1,5 +1,24 @@ +/* + * Copyright © 2021 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ package org.altusmetrum.AltosDroid; +import java.io.*; + import org.altusmetrum.altoslib_14.*; import android.content.BroadcastReceiver; @@ -8,15 +27,24 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Environment; -public class TelemetryLogger { - private Context context = null; +public class TelemetryLogger implements AltosLogTrace { + private TelemetryService service = null; private AltosLink link = null; private AltosLog logger = null; private BroadcastReceiver mExternalStorageReceiver; - public TelemetryLogger(Context in_context, AltosLink in_link) { - context = in_context; + /* AltosLogTrace interface */ + public void trace(String format, Object ... arguments) { + AltosDebug.debug(format, arguments); + } + + public void open_failed(File file) { + service.send_file_failed_to_clients(file); + } + + public TelemetryLogger(TelemetryService in_service, AltosLink in_link) { + service = in_service; link = in_link; startWatchingExternalStorage(); @@ -40,7 +68,7 @@ public class TelemetryLogger { if (Environment.MEDIA_MOUNTED.equals(state)) { if (logger == null) { AltosDebug.debug("Starting up Telemetry Logging"); - logger = new AltosLog(link); + logger = new AltosLog(link,this); } } else { AltosDebug.debug("External Storage not present - stopping"); @@ -58,12 +86,12 @@ public class TelemetryLogger { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_MOUNTED); filter.addAction(Intent.ACTION_MEDIA_REMOVED); - context.registerReceiver(mExternalStorageReceiver, filter); + service.registerReceiver(mExternalStorageReceiver, filter); handleExternalStorageState(); } void stopWatchingExternalStorage() { - context.unregisterReceiver(mExternalStorageReceiver); + service.unregisterReceiver(mExternalStorageReceiver); } }