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
|
||||
android:minSdkVersion="19"
|
||||
android:targetSdkVersion="21" />
|
||||
<!--
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
-->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<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)) {
|
||||
device = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
|
||||
if (device != null) {
|
||||
if (!device.isConnected()) {
|
||||
if (!device.isInitialized()) {
|
||||
setInstallEnabled(false);
|
||||
if (mayConnect) {
|
||||
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 {
|
||||
|
||||
private final Context mContext;
|
||||
private final PBWReader mPBWReader;
|
||||
private PBWReader mPBWReader;
|
||||
private final Uri mUri;
|
||||
|
||||
public PBWInstallHandler(Uri uri, Context context) {
|
||||
mContext = context;
|
||||
mPBWReader = new PBWReader(uri, context, ""); // FIXME: we should know the platform here
|
||||
mUri = uri;
|
||||
}
|
||||
|
||||
|
@ -34,6 +33,13 @@ public class PBWInstallHandler implements InstallHandler {
|
|||
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()) {
|
||||
String hwRevision = mPBWReader.getHWRevision();
|
||||
if (hwRevision != null && hwRevision.equals(device.getHardwareVersion())) {
|
||||
|
@ -77,7 +83,8 @@ public class PBWInstallHandler implements InstallHandler {
|
|||
}
|
||||
|
||||
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) {
|
||||
// FIXME: dont assume WATCHFACE
|
||||
app = new GBDeviceApp(uuid, appName, appCreator, appVersion, GBDeviceApp.Type.WATCHFACE);
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
|
|
|
@ -480,10 +480,12 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
|||
|
||||
mPBWReader = null;
|
||||
mIsInstalling = false;
|
||||
try {
|
||||
mZis.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
if (mZis != null) {
|
||||
try {
|
||||
mZis.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
mZis = null;
|
||||
mAppInstallToken = -1;
|
||||
|
|
Loading…
Reference in New Issue