mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 01:09:47 +01:00
App Installation: various improvements
- make FwAppInstallerActivity wait for a completely initialized device - check basalt/aplite compatibility with pbw to be installed and report intead of crashing - fix crash when trying to install pbw with all app slots full
This commit is contained in:
parent
d2173d37ce
commit
faaa04b670
@ -5,9 +5,8 @@
|
|||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="19"
|
android:minSdkVersion="19"
|
||||||
android:targetSdkVersion="21" />
|
android:targetSdkVersion="21" />
|
||||||
<!--
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
-->
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
@ -47,7 +47,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
|
|||||||
} else if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
|
} else if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
|
||||||
device = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
device = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
if (!device.isConnected()) {
|
if (!device.isInitialized()) {
|
||||||
setInstallEnabled(false);
|
setInstallEnabled(false);
|
||||||
if (mayConnect) {
|
if (mayConnect) {
|
||||||
GB.toast(FwAppInstallerActivity.this, getString(R.string.connecting), Toast.LENGTH_SHORT, GB.INFO);
|
GB.toast(FwAppInstallerActivity.this, getString(R.string.connecting), Toast.LENGTH_SHORT, GB.INFO);
|
||||||
|
@ -17,12 +17,11 @@ import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
|||||||
public class PBWInstallHandler implements InstallHandler {
|
public class PBWInstallHandler implements InstallHandler {
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final PBWReader mPBWReader;
|
private PBWReader mPBWReader;
|
||||||
private final Uri mUri;
|
private final Uri mUri;
|
||||||
|
|
||||||
public PBWInstallHandler(Uri uri, Context context) {
|
public PBWInstallHandler(Uri uri, Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mPBWReader = new PBWReader(uri, context, ""); // FIXME: we should know the platform here
|
|
||||||
mUri = uri;
|
mUri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +33,13 @@ public class PBWInstallHandler implements InstallHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mPBWReader = new PBWReader(mUri, mContext, device.getHardwareVersion().equals("dvt") ? "basalt" : "aplite");
|
||||||
|
if (!mPBWReader.isValid()) {
|
||||||
|
installActivity.setInfoText("pbw/pbz is broken or incompatible with your Hardware or Firmware.");
|
||||||
|
installActivity.setInstallEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mPBWReader.isFirmware()) {
|
if (mPBWReader.isFirmware()) {
|
||||||
String hwRevision = mPBWReader.getHWRevision();
|
String hwRevision = mPBWReader.getHWRevision();
|
||||||
if (hwRevision != null && hwRevision.equals(device.getHardwareVersion())) {
|
if (hwRevision != null && hwRevision.equals(device.getHardwareVersion())) {
|
||||||
@ -77,7 +83,8 @@ public class PBWInstallHandler implements InstallHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return mPBWReader.isValid();
|
// always pretend it is valid, as we cant know yet about hw/fw version
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -147,7 +147,6 @@ public class PBWReader {
|
|||||||
if (appName != null && appCreator != null && appVersion != null) {
|
if (appName != null && appCreator != null && appVersion != null) {
|
||||||
// FIXME: dont assume WATCHFACE
|
// FIXME: dont assume WATCHFACE
|
||||||
app = new GBDeviceApp(uuid, appName, appCreator, appVersion, GBDeviceApp.Type.WATCHFACE);
|
app = new GBDeviceApp(uuid, appName, appCreator, appVersion, GBDeviceApp.Type.WATCHFACE);
|
||||||
isValid = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -480,11 +480,13 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
|
|
||||||
mPBWReader = null;
|
mPBWReader = null;
|
||||||
mIsInstalling = false;
|
mIsInstalling = false;
|
||||||
|
if (mZis != null) {
|
||||||
try {
|
try {
|
||||||
mZis.close();
|
mZis.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mZis = null;
|
mZis = null;
|
||||||
mAppInstallToken = -1;
|
mAppInstallToken = -1;
|
||||||
mInstallSlot = -2;
|
mInstallSlot = -2;
|
||||||
|
Loading…
Reference in New Issue
Block a user