Fix compile errors (untested)

This commit is contained in:
Arjan Schrijver
2026-01-17 21:10:31 +01:00
committed by Arjan Schrijver
parent 9c93d11229
commit 320dde9a0e
5 changed files with 113 additions and 105 deletions
@@ -17,8 +17,6 @@
package nodomain.freeyourgadget.gadgetbridge.devices.pinetime; package nodomain.freeyourgadget.gadgetbridge.devices.pinetime;
import android.app.Activity; import android.app.Activity;
import static java.nio.charset.StandardCharsets.UTF_8;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
@@ -41,16 +41,17 @@ import java.util.Vector;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLESingleDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEQueue; import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEQueue;
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.AbstractBleProfile; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.AbstractBleProfile;
import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile;
import nodomain.freeyourgadget.gadgetbridge.util.RemoteFileSystemCache; import nodomain.freeyourgadget.gadgetbridge.util.RemoteFileSystemCache;
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper; import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
import nodomain.freeyourgadget.gadgetbridge.util.ZipFile;
import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException; import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException;
public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends AbstractBleProfile { public class AdaBleFsProfile<T extends AbstractBTLESingleDeviceSupport> extends AbstractBleProfile {
final byte PADDING_BYTE = 0x00; final byte PADDING_BYTE = 0x00;
final byte REQUEST_CONTINUED = 0x01; final byte REQUEST_CONTINUED = 0x01;
final byte REQUEST_WRITE_FILE_START = 0x20; final byte REQUEST_WRITE_FILE_START = 0x20;
@@ -84,7 +85,6 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
int chunkSize; int chunkSize;
private RemoteFileSystemCache remoteFs; private RemoteFileSystemCache remoteFs;
List<String> listingDirectory; List<String> listingDirectory;
private static final Logger LOG = LoggerFactory.getLogger(AdaBleFsProfile.class); private static final Logger LOG = LoggerFactory.getLogger(AdaBleFsProfile.class);
@@ -101,7 +101,7 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
// Unzip // Unzip
try { try {
UriHelper uriHelper = UriHelper.get(uri, context); UriHelper uriHelper = UriHelper.get(uri, context);
ZipFile zipPackage = new ZipFile(uriHelper.openInputStream()); GBZipFile zipPackage = new GBZipFile(uriHelper.openInputStream());
JSONObject resources_manifest = new JSONObject(new String(zipPackage.getFileFromZip(("resources.json")))); JSONObject resources_manifest = new JSONObject(new String(zipPackage.getFileFromZip(("resources.json"))));
JSONArray resources = resources_manifest.getJSONArray("resources"); JSONArray resources = resources_manifest.getJSONArray("resources");
@@ -127,10 +127,14 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
} catch (Exception e) { } catch (Exception e) {
LOG.error("Unknown error occurred.", e); LOG.error("Unknown error occurred.", e);
} }
this.startNextAdaFsAction(); try {
this.startNextAdaFsAction();
} catch (IOException e) {
LOG.error("Error while loading resources: ", e);
}
} }
private void startNextAdaFsAction() { private void startNextAdaFsAction() throws IOException {
if (adaBleFsQueue.size() == 0) { if (adaBleFsQueue.size() == 0) {
return; return;
} }
@@ -149,11 +153,16 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
public void enableNotify(TransactionBuilder builder, boolean enable) { public void enableNotify(TransactionBuilder builder, boolean enable) {
builder.notify(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), enable); builder.notify(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), enable);
} }
public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) {
UUID charUuid = characteristic.getUuid(); UUID charUuid = characteristic.getUuid();
if (charUuid.equals(UUID_CHARACTERISTIC_FS_TRANSFER)) { if (charUuid.equals(UUID_CHARACTERISTIC_FS_TRANSFER)) {
handleNextStatus(gatt, characteristic); try {
handleNextStatus(gatt, characteristic);
} catch (IOException e) {
LOG.error("Error handling status: ", e);
}
return true; return true;
} else { } else {
LOG.info("Unexpected onCharacteristicRead: " + GattCharacteristic.toString(characteristic)); LOG.info("Unexpected onCharacteristicRead: " + GattCharacteristic.toString(characteristic));
@@ -164,7 +173,7 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
return false; return false;
} }
private void handleNextStatus(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { private void handleNextStatus(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) throws IOException {
// Determine what we are waiting on // Determine what we are waiting on
final byte[] returned = characteristic.getValue(); final byte[] returned = characteristic.getValue();
// if doing file upload // if doing file upload
@@ -233,55 +242,55 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
for(int counter = 0; counter < length; counter++) { for(int counter = 0; counter < length; counter++) {
stringBytes[counter] = returned[28+counter]; stringBytes[counter] = returned[28+counter];
} }
Map<String, Object> relativeRoot = directoryTree; // Map<String, Object> relativeRoot = directoryTree;
for(String path: listingDirectory) { // for(String path: listingDirectory) {
relativeRoot = (Map<String, Object>) relativeRoot.get(path); // relativeRoot = (Map<String, Object>) relativeRoot.get(path);
} // }
try { try {
String path = new String(stringBytes, "UTF-8"); String path = new String(stringBytes, "UTF-8");
Map<String, Object> here = directoryTree; // TODO Paths returned are relative to where we requested paths from so we need to alter this // Map<String, Object> here = directoryTree; // TODO Paths returned are relative to where we requested paths from so we need to alter this
// TODO Remove first / ? // // TODO Remove first / ?
// Split path on / // // Split path on /
String soFar = ""; // String soFar = "";
final String[] paths = path.split("/"); // final String[] paths = path.split("/");
for(int counter = 0; counter < paths.length; counter++) { // for(int counter = 0; counter < paths.length; counter++) {
final String dir = paths[counter]; // final String dir = paths[counter];
soFar = soFar + "/" + dir; // soFar = soFar + "/" + dir;
if (here.containsKey(dir)) { // if (here.containsKey(dir)) {
Object entry = here.get(dir); // Object entry = here.get(dir);
if (counter < (paths.length-1) || isDirectory) { // if (counter < (paths.length-1) || isDirectory) {
// If not at last entry in paths, or if the response says this is a directory // // If not at last entry in paths, or if the response says this is a directory
if (entry instanceof HashMap) { // if (entry instanceof HashMap) {
// All good, continue; // // All good, continue;
} else { // } else {
// our map doesn't list directory, but this is? // // our map doesn't list directory, but this is?
LOG.warn("GadgetBridge cache thinks " + soFar + " is a file, but device thinks it's a directory."); // LOG.warn("GadgetBridge cache thinks " + soFar + " is a file, but device thinks it's a directory.");
here.put(dir, new HashMap<String, Object>()); // here.put(dir, new HashMap<String, Object>());
} // }
} else { // } else {
// We are at the last string in paths, and response says this isn't a file // // We are at the last string in paths, and response says this isn't a file
if (entry instanceof String) { // if (entry instanceof String) {
// All good, continue // // All good, continue
} else { // } else {
LOG.warn("GadgetBridge cache thinks " + soFar + " is a directory, but device thinks it's a file."); // LOG.warn("GadgetBridge cache thinks " + soFar + " is a directory, but device thinks it's a file.");
here.put(dir, dir); // here.put(dir, dir);
} // }
} // }
} else { // } else {
// Our cache doesn't know of soFar // // Our cache doesn't know of soFar
if (counter < (paths.length-1) || isDirectory) { // if (counter < (paths.length-1) || isDirectory) {
here.put(dir, new HashMap<String, Object>()); // here.put(dir, new HashMap<String, Object>());
} else { // } else {
here.put(dir, dir); // here.put(dir, dir);
} // }
} // }
} // }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// Pretty sure this branch will never happen // Pretty sure this branch will never happen
} }
if (entryNum == totalEntries) { // if (entryNum == totalEntries) {
relativeRoot.put(".", "."); // relativeRoot.put(".", ".");
} // }
return entryNum == totalEntries; return entryNum == totalEntries;
} }
@@ -310,7 +319,7 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
return true; return true;
} }
private boolean checkContinueFileUpload(byte[] returned) { private boolean checkContinueFileUpload(byte[] returned) throws IOException {
/** /**
* Check that a file upload command has completed * Check that a file upload command has completed
* *
@@ -329,11 +338,11 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
} }
@Override @Override
public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { public boolean onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, byte[] value, int status) {
return onCharacteristicRead(gatt, characteristic, BluetoothGatt.GATT_SUCCESS); return onCharacteristicRead(gatt, characteristic, BluetoothGatt.GATT_SUCCESS);
} }
private void uploadNextFileChunk() { private void uploadNextFileChunk() throws IOException {
final AdaBleFsAction nextAction = adaBleFsQueue.getFirst(); final AdaBleFsAction nextAction = adaBleFsQueue.getFirst();
final int toSendSize = Math.min(chunkSize, nextAction.data.length - bytesOfFileWritten); final int toSendSize = Math.min(chunkSize, nextAction.data.length - bytesOfFileWritten);
ArrayList<Byte> command = new ArrayList<>(); ArrayList<Byte> command = new ArrayList<>();
@@ -356,10 +365,10 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
for(int i = 0; i < command.size(); i++) { for(int i = 0; i < command.size(); i++) {
bytes[i] = command.get(i); bytes[i] = command.get(i);
} }
TransactionBuilder builder = new TransactionBuilder("Upload file chunk"); TransactionBuilder builder = performInitialized("Upload file chunk");
builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes); builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes);
builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER)); builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER));
builder.queue(getQueue()); builder.queue();
} }
private void uploadFileInitialise() { private void uploadFileInitialise() {
@@ -371,33 +380,33 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
// then uploadFileStart() // then uploadFileStart()
} }
private TriState directoryExists(String[] directoryList) { // private TriState directoryExists(String[] directoryList) throws IOException {
Map<String, Object> here = directoryTree; // Map<String, Object> here = directoryTree;
String[] soFar; // String[] soFar;
String totalPath = "/"; // String totalPath = "/";
for(String directory: directoryList) { // for(String directory: directoryList) {
if (here.containsKey(directory)) { // if (here.containsKey(directory)) {
Object entry = here.get(directory); // Object entry = here.get(directory);
if (entry instanceof HashMap) { // if (entry instanceof HashMap) {
here = (Map<String, Object>) entry; // here = (Map<String, Object>) entry;
totalPath += directory + "/"; // totalPath += directory + "/";
} else { // } else {
// Not a HashMap, must be a string then and so this is a file, not a directory // // Not a HashMap, must be a string then and so this is a file, not a directory
return TriState.FALSE; // return TriState.FALSE;
} // }
} else if (here.containsKey(".")) { // } else if (here.containsKey(".")) {
// We have listed this directory, and the requested path does not exist // // We have listed this directory, and the requested path does not exist
return TriState.FALSE; // return TriState.FALSE;
} // }
// Request directory listing for here // // Request directory listing for here
totalPath += directory; // totalPath += directory;
requestListDirectory(totalPath); // requestListDirectory(totalPath);
return TriState.UNKNOWN; // return TriState.UNKNOWN;
} // }
return TriState.TRUE; // return TriState.TRUE;
} // }
private void uploadFileStart() { private void uploadFileStart() throws IOException {
bytesOfFileWritten = 0; bytesOfFileWritten = 0;
// TODO Should this be the time we upload, or should it somehow be the timestamp of the // TODO Should this be the time we upload, or should it somehow be the timestamp of the
// resources.zip archive file // resources.zip archive file
@@ -429,14 +438,14 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
for(int i = 0; i < command.size(); i++) { for(int i = 0; i < command.size(); i++) {
bytes[i] = command.get(i); bytes[i] = command.get(i);
} }
TransactionBuilder builder = new TransactionBuilder("Upload file start"); TransactionBuilder builder = performInitialized("Upload file start");
builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes); builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes);
builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER)); builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER));
builder.queue(getQueue()); builder.queue();
return; return;
} }
private void requestListDirectory(String path) { private void requestListDirectory(String path) throws IOException {
Vector<Byte> command = new Vector<Byte>(); Vector<Byte> command = new Vector<Byte>();
command.add(REQUEST_LIST_DIRECTORY); command.add(REQUEST_LIST_DIRECTORY);
command.add(PADDING_BYTE); command.add(PADDING_BYTE);
@@ -451,14 +460,14 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
for(int i = 0; i < command.size(); i++) { for(int i = 0; i < command.size(); i++) {
bytes[i] = command.get(i); bytes[i] = command.get(i);
} }
TransactionBuilder builder = new TransactionBuilder("List directory"); TransactionBuilder builder = performInitialized("List directory");
builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes); builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes);
builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER)); builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER));
builder.queue(getQueue()); builder.queue();
listingDirectory = Arrays.asList(path.split("/")); listingDirectory = Arrays.asList(path.split("/"));
return; return;
} }
private void deleteFile() { private void deleteFile() throws IOException {
final AdaBleFsAction nextAction = adaBleFsQueue.getFirst(); final AdaBleFsAction nextAction = adaBleFsQueue.getFirst();
Vector<Byte> command = new Vector<Byte>(); Vector<Byte> command = new Vector<Byte>();
command.add(REQUEST_DELETE_FILE); command.add(REQUEST_DELETE_FILE);
@@ -474,14 +483,14 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
for(int i = 0; i < command.size(); i++) { for(int i = 0; i < command.size(); i++) {
bytes[i] = command.get(i); bytes[i] = command.get(i);
} }
TransactionBuilder builder = new TransactionBuilder("Delete file or directory"); TransactionBuilder builder = performInitialized("Delete file or directory");
builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes); builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes);
builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER)); builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER));
builder.queue(getQueue()); builder.queue();
return; return;
} }
private void makeDirectory() { private void makeDirectory() throws IOException {
final AdaBleFsAction nextAction = adaBleFsQueue.getFirst(); final AdaBleFsAction nextAction = adaBleFsQueue.getFirst();
long unixTime = System.currentTimeMillis() / 1000L; long unixTime = System.currentTimeMillis() / 1000L;
Vector<Byte> command = new Vector<Byte>(); Vector<Byte> command = new Vector<Byte>();
@@ -510,14 +519,14 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
for(int i = 0; i < command.size(); i++) { for(int i = 0; i < command.size(); i++) {
bytes[i] = command.get(i); bytes[i] = command.get(i);
} }
TransactionBuilder builder = new TransactionBuilder("Create directory"); TransactionBuilder builder = performInitialized("Create directory");
builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes); builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes);
builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER)); builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER));
builder.queue(getQueue()); builder.queue();
return; return;
} }
private void moveFileOrDirectory() { private void moveFileOrDirectory() throws IOException {
final AdaBleFsAction nextAction = adaBleFsQueue.getFirst(); final AdaBleFsAction nextAction = adaBleFsQueue.getFirst();
long unixTime = System.currentTimeMillis() / 1000L; long unixTime = System.currentTimeMillis() / 1000L;
Vector<Byte> command = new Vector<Byte>(); Vector<Byte> command = new Vector<Byte>();
@@ -540,10 +549,10 @@ public class AdaBleFsProfile<T extends AbstractBTLEDeviceSupport> extends Abstra
for(int i = 0; i < command.size(); i++) { for(int i = 0; i < command.size(); i++) {
bytes[i] = command.get(i); bytes[i] = command.get(i);
} }
TransactionBuilder builder = new TransactionBuilder("Move file or directory"); TransactionBuilder builder = performInitialized("Move file or directory");
builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes); builder.write(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER), bytes);
builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER)); builder.read(getCharacteristic(UUID_CHARACTERISTIC_FS_TRANSFER));
builder.queue(getQueue()); builder.queue();
return; return;
} }
@@ -62,6 +62,7 @@ import no.nordicsemi.android.dfu.DfuServiceInitiator;
import no.nordicsemi.android.dfu.DfuServiceListenerHelper; import no.nordicsemi.android.dfu.DfuServiceListenerHelper;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
@@ -91,15 +92,13 @@ import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
import nodomain.freeyourgadget.gadgetbridge.model.WorldClock; import nodomain.freeyourgadget.gadgetbridge.model.WorldClock;
import nodomain.freeyourgadget.gadgetbridge.model.weather.Weather; import nodomain.freeyourgadget.gadgetbridge.model.weather.Weather;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLESingleDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLESingleDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.adablefs.AdaBleFsProfile;
import nodomain.freeyourgadget.gadgetbridge.service.btle.ResourceUploadProgressListener;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic;
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService;
import nodomain.freeyourgadget.gadgetbridge.service.btle.ResourceUploadProgressListener;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.IntentListener; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.IntentListener;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.adablefs.AdaBleFsProfile;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertCategory; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertCategory;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertNotificationProfile; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertNotificationProfile;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.NewAlert; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.NewAlert;
@@ -563,7 +562,7 @@ public class PineTimeJFSupport extends AbstractBTLESingleDeviceSupport implement
public void installResource(Uri uri) { public void installResource(Uri uri) {
try { try {
gbDevice.setBusyTask("resources upgrade"); gbDevice.setBusyTask(R.string.uploading_resources, getContext());
adaBleFsProfile.loadResources(uri, getContext(), getQueue()); adaBleFsProfile.loadResources(uri, getContext(), getQueue());
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_BAR) LocalBroadcastManager.getInstance(getContext()).sendBroadcast(new Intent(GB.ACTION_SET_PROGRESS_BAR)
@@ -574,7 +573,7 @@ public class PineTimeJFSupport extends AbstractBTLESingleDeviceSupport implement
); );
} catch (Exception ex) { } catch (Exception ex) {
GB.toast(getContext(), getContext().getString(R.string.updatefirmwareoperation_write_failed) + ":" + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex); GB.toast(getContext(), getContext().getString(R.string.updatefirmwareoperation_write_failed) + ":" + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex);
if (gbDevice.isBusy() && gbDevice.getBusyTask().equals("resources upgrade")) { if (gbDevice.isBusy() && gbDevice.getBusyTask().equals(getContext().getString(R.string.uploading_resources))) {
gbDevice.unsetBusyTask(); gbDevice.unsetBusyTask();
} }
} }
@@ -20,6 +20,7 @@ package nodomain.freeyourgadget.gadgetbridge.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
public class RemoteFileSystemCache { public class RemoteFileSystemCache {
+1
View File
@@ -1003,6 +1003,7 @@
<string name="devicestatus_upload_aborted">Upload has been aborted!</string> <string name="devicestatus_upload_aborted">Upload has been aborted!</string>
<string name="devicestatus_upload_failed">Upload has failed</string> <string name="devicestatus_upload_failed">Upload has failed</string>
<string name="firmware_update_progress">Upload is in progress\n%1$d%% at %2$.2fkbps (average %3$.2fkbps)\nPart %4$d of %5$d</string> <string name="firmware_update_progress">Upload is in progress\n%1$d%% at %2$.2fkbps (average %3$.2fkbps)\nPart %4$d of %5$d</string>
<string name="uploading_resources">Uploading resources…</string>
<string name="updating_firmware">Flashing firmware…</string> <string name="updating_firmware">Flashing firmware…</string>
<string name="fwapp_install_device_not_supported">File cannot be installed, device not supported.</string> <string name="fwapp_install_device_not_supported">File cannot be installed, device not supported.</string>
<string name="fwapp_install_device_not_ready">File cannot be installed, device not ready.</string> <string name="fwapp_install_device_not_ready">File cannot be installed, device not ready.</string>