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