mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 00:30:37 +02:00
Pebble: fix crash on firmware 3.x when pebble requests a pbw that is not in Gadgetbridge's cache
This commit is contained in:
parent
79f92b8495
commit
b05cfc6aac
@ -3,6 +3,7 @@
|
||||
####Next Version
|
||||
* Pebble: fix regression in 0.6.7 when installing pbw/pbz files from content providers (eg. download manager)
|
||||
* Pebble: fix installation of pbw files on firmware 3.x when using content providers (eg. download manager)
|
||||
* Pebble: fix crash on firmware 3.x when pebble requests a pbw that is not in Gadgetbridge's cache
|
||||
+ Treat Signal notifications as chat notifications
|
||||
* Fix crash when contacts cannot be read on Android 6.0 (non-granted pemissions)
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -53,7 +54,14 @@ public class PBWInstallHandler implements InstallHandler {
|
||||
platformName = "aplite";
|
||||
}
|
||||
|
||||
try {
|
||||
mPBWReader = new PBWReader(mUri, mContext, platformName);
|
||||
} catch (FileNotFoundException e) {
|
||||
installActivity.setInfoText("file not found");
|
||||
installActivity.setInstallEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mPBWReader.isValid()) {
|
||||
installActivity.setInfoText("pbw/pbz is broken or incompatible with your Hardware or Firmware.");
|
||||
installActivity.setInstallEnabled(false);
|
||||
|
@ -48,7 +48,7 @@ public class PBWReader {
|
||||
private final Uri uri;
|
||||
private final ContentResolver cr;
|
||||
private GBDeviceApp app;
|
||||
private ArrayList<PebbleInstallable> pebbleInstallables;
|
||||
private ArrayList<PebbleInstallable> pebbleInstallables = null;
|
||||
private boolean isFirmware = false;
|
||||
private boolean isLanguage = false;
|
||||
private boolean isValid = false;
|
||||
@ -58,17 +58,11 @@ public class PBWReader {
|
||||
private int mIconId;
|
||||
private int mFlags;
|
||||
|
||||
public PBWReader(Uri uri, Context context, String platform) {
|
||||
public PBWReader(Uri uri, Context context, String platform) throws FileNotFoundException {
|
||||
this.uri = uri;
|
||||
cr = context.getContentResolver();
|
||||
|
||||
InputStream fin;
|
||||
try {
|
||||
fin = new BufferedInputStream(cr.openInputStream(uri));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
InputStream fin = new BufferedInputStream(cr.openInputStream(uri));
|
||||
|
||||
if (uri.toString().endsWith(".pbl") && platform.equals("aplite")) {
|
||||
STM32CRC stm32crc = new STM32CRC();
|
||||
@ -104,14 +98,7 @@ public class PBWReader {
|
||||
|
||||
if (platform.equals("aplite")) {
|
||||
boolean hasApliteDir = false;
|
||||
InputStream afin;
|
||||
|
||||
try {
|
||||
afin = new BufferedInputStream(cr.openInputStream(uri));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
InputStream afin = new BufferedInputStream(cr.openInputStream(uri));
|
||||
|
||||
ZipInputStream zis = new ZipInputStream(afin);
|
||||
ZipEntry ze;
|
||||
@ -289,6 +276,9 @@ public class PBWReader {
|
||||
}
|
||||
|
||||
public PebbleInstallable[] getPebbleInstallables() {
|
||||
if (pebbleInstallables == null) {
|
||||
return null;
|
||||
}
|
||||
return pebbleInstallables.toArray(new PebbleInstallable[pebbleInstallables.size()]);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -551,7 +552,13 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||
platformName = "aplite";
|
||||
}
|
||||
|
||||
try {
|
||||
mPBWReader = new PBWReader(uri, getContext(), platformName);
|
||||
} catch (FileNotFoundException e) {
|
||||
LOG.warn("file not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
mPebbleInstallables = mPBWReader.getPebbleInstallables();
|
||||
mCurrentInstallableIndex = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user