X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosdroid%2Fapp%2Fsrc%2Fmain%2Fjava%2Forg%2Faltusmetrum%2FAltosDroid%2FTelemetryService.java;h=e58906ea425d952fee6804fc5f32846c3ae92788;hb=5214a559acc582d639e2489c82594e5fb3a4c540;hp=31616c825371d5e4f2f411343edf4c2464b622b0;hpb=528fdc4e03466430c8d81fc78c90d3c9e8465ca7;p=fw%2Faltos diff --git a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryService.java index 31616c82..e58906ea 100644 --- a/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryService.java @@ -20,6 +20,7 @@ package org.altusmetrum.AltosDroid; import java.lang.ref.WeakReference; import java.util.concurrent.TimeoutException; +import java.io.*; import java.util.*; import android.app.*; @@ -30,6 +31,7 @@ import android.hardware.usb.*; import android.content.Intent; import android.content.Context; import android.os.*; +import android.os.Build.*; import android.widget.Toast; import androidx.core.app.NotificationCompat; @@ -340,6 +342,21 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene send_idle_mode_to_client(client); } + private void send_file_failed_to_client(Messenger client, File f) { + Message m = Message.obtain(null, AltosDroid.MSG_FILE_FAILED, f); + try { + client.send(m); + } catch (RemoteException e) { + AltosDebug.error("Client %s disappeared", client.toString()); + remove_client(client); + } + } + + public void send_file_failed_to_clients(File f) { + for (Messenger client : clients) + send_file_failed_to_client(client, f); + } + private void telemetry_start() { if (telemetry_reader == null && idle_monitor == null && !ignite_running) { telemetry_reader = new TelemetryReader(altos_link, handler); @@ -416,7 +433,7 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene } private void start_altos_bluetooth(DeviceAddress address, boolean pause) { - if (bluetooth_adapter == null || !bluetooth_adapter.isEnabled()) + if (bluetooth_adapter == null || !bluetooth_adapter.isEnabled() || address.address == null) return; disconnect(false); @@ -646,10 +663,16 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene @Override public int onStartCommand(Intent intent, int flags, int startId) { AltosDebug.debug("Received start id %d: %s", startId, intent); + int flag; + + if (android.os.Build.VERSION.SDK_INT >= 31) // android.os.Build.VERSION_CODES.S + flag = 33554432; // PendingIntent.FLAG_MUTABLE + else + flag = 0; // The PendingIntent to launch our activity if the user selects this notification PendingIntent contentIntent = PendingIntent.getActivity(this, 0, - new Intent(this, AltosDroid.class), 0); + new Intent(this, AltosDroid.class), flag); String channelId = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)