Feedback for failed and successful installations. Closes #19.
This commit is contained in:
parent
3355be79e6
commit
4ff57dfdab
|
@ -4,6 +4,7 @@
|
|||
* Experimental pbw installation support (watchfaces/apps)
|
||||
* New icons for device and app lists
|
||||
* Fix for device list not refreshing when bluetooth gets turned on
|
||||
* Filter out annyoing low battery notifications
|
||||
* Fix for crash on some devices when creating a debug notification
|
||||
* Lots of internal changes preparing multi device support
|
||||
|
||||
|
|
|
@ -186,11 +186,18 @@ public class BluetoothCommunicationService extends Service {
|
|||
GBDeviceCommandAppManagementResult appMgmtRes = (GBDeviceCommandAppManagementResult) deviceCmd;
|
||||
switch (appMgmtRes.type) {
|
||||
case DELETE:
|
||||
// right now on the Pebble we also receive this on a failed/successful installation ;/
|
||||
switch (appMgmtRes.result) {
|
||||
case FAILURE:
|
||||
Log.i(TAG, "failure removing app"); // TODO: report to AppManager
|
||||
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
|
||||
((PebbleIoThread) mGBDeviceIoThread).finishInstall(true);
|
||||
}
|
||||
break;
|
||||
case SUCCESS:
|
||||
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
|
||||
((PebbleIoThread) mGBDeviceIoThread).finishInstall(false);
|
||||
}
|
||||
// refresh app list
|
||||
mGBDeviceIoThread.write(mGBDeviceProtocol.encodeAppInfoReq());
|
||||
break;
|
||||
|
@ -202,6 +209,9 @@ public class BluetoothCommunicationService extends Service {
|
|||
switch (appMgmtRes.result) {
|
||||
case FAILURE:
|
||||
Log.i(TAG, "failure installing app"); // TODO: report to Installer
|
||||
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
|
||||
((PebbleIoThread) mGBDeviceIoThread).finishInstall(true);
|
||||
}
|
||||
break;
|
||||
case SUCCESS:
|
||||
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
|
||||
|
@ -517,6 +527,7 @@ public class BluetoothCommunicationService extends Service {
|
|||
switch (mmInstallState) {
|
||||
case APP_WAIT_SLOT:
|
||||
if (mmInstallSlot != -1) {
|
||||
updateNotification("starting installation");
|
||||
mmInstallState = PebbleAppInstallState.APP_START_INSTALL;
|
||||
continue;
|
||||
}
|
||||
|
@ -541,13 +552,8 @@ public class BluetoothCommunicationService extends Service {
|
|||
} else if (fileName.equals("app_resources.pbpack")) {
|
||||
type = PebbleProtocol.PUTBYTES_TYPE_RESOURCES;
|
||||
} else {
|
||||
// FIXME: proper state for cancellation
|
||||
mmInstallState = PebbleAppInstallState.UNKNOWN;
|
||||
mmPBWReader = null;
|
||||
mmIsInstalling = false;
|
||||
mmZis = null;
|
||||
mmAppInstallToken = -1;
|
||||
mmInstallSlot = -1;
|
||||
finishInstall(true);
|
||||
break;
|
||||
}
|
||||
|
||||
writeInstallApp(mmPebbleProtocol.encodeUploadStart(type, (byte) mmInstallSlot, binarySize));
|
||||
|
@ -595,11 +601,6 @@ public class BluetoothCommunicationService extends Service {
|
|||
break;
|
||||
case APP_REFRESH:
|
||||
writeInstallApp(mmPebbleProtocol.encodeAppRefresh(mmInstallSlot));
|
||||
mmPBWReader = null;
|
||||
mmIsInstalling = false;
|
||||
mmZis = null;
|
||||
mmAppInstallToken = -1;
|
||||
mmInstallSlot = -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -748,6 +749,28 @@ public class BluetoothCommunicationService extends Service {
|
|||
mmIsInstalling = true;
|
||||
}
|
||||
|
||||
public void finishInstall(boolean hadError) {
|
||||
if (!mmIsInstalling) {
|
||||
return;
|
||||
}
|
||||
if (hadError) {
|
||||
updateNotification("installation failed!");
|
||||
} else {
|
||||
updateNotification("installation successful");
|
||||
}
|
||||
mmInstallState = PebbleAppInstallState.UNKNOWN;
|
||||
|
||||
if (hadError == true && mmAppInstallToken != -1) {
|
||||
writeInstallApp(mmPebbleProtocol.encodeUploadCancel(mmAppInstallToken));
|
||||
}
|
||||
|
||||
mmPBWReader = null;
|
||||
mmIsInstalling = false;
|
||||
mmZis = null;
|
||||
mmAppInstallToken = -1;
|
||||
mmInstallSlot = -1;
|
||||
}
|
||||
|
||||
public void quit() {
|
||||
mmQuit = true;
|
||||
if (mBtSocket != null) {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class NotificationListener extends NotificationListenerService {
|
|||
*/
|
||||
|
||||
if (source.equals("android") ||
|
||||
source.equals("com.android.systemui" ) ||
|
||||
source.equals("com.android.systemui") ||
|
||||
source.equals("com.android.dialer") ||
|
||||
source.equals("com.fsck.k9") ||
|
||||
source.equals("com.android.mms")) {
|
||||
|
|
|
@ -124,6 +124,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||
static final short LENGTH_UPLOADCHUNK = 9;
|
||||
static final short LENGTH_UPLOADCOMMIT = 9;
|
||||
static final short LENGTH_UPLOADCOMPLETE = 5;
|
||||
static final short LENGTH_UPLOADCANCEL = 5;
|
||||
|
||||
private static byte[] encodeMessage(short endpoint, byte type, int cookie, String[] parts) {
|
||||
// Calculate length first
|
||||
|
@ -342,6 +343,16 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||
return buf.array();
|
||||
}
|
||||
|
||||
public byte[] encodeUploadCancel(int token) {
|
||||
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_UPLOADCANCEL);
|
||||
buf.order(ByteOrder.BIG_ENDIAN);
|
||||
buf.putShort(LENGTH_UPLOADCANCEL);
|
||||
buf.putShort(ENDPOINT_PUTBYTES);
|
||||
buf.put(PUTBYTES_ABORT);
|
||||
buf.putInt(token);
|
||||
return buf.array();
|
||||
}
|
||||
|
||||
public byte[] encodeAppRefresh(int index) {
|
||||
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_REFRESHAPP);
|
||||
buf.order(ByteOrder.BIG_ENDIAN);
|
||||
|
|
Loading…
Reference in New Issue