Feedback for failed and successful installations. Closes #19.

master
Andreas Shimokawa 2015-04-09 18:48:52 +02:00
parent 3355be79e6
commit 4ff57dfdab
4 changed files with 48 additions and 13 deletions

View File

@ -4,6 +4,7 @@
* Experimental pbw installation support (watchfaces/apps) * Experimental pbw installation support (watchfaces/apps)
* New icons for device and app lists * New icons for device and app lists
* Fix for device list not refreshing when bluetooth gets turned on * 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 * Fix for crash on some devices when creating a debug notification
* Lots of internal changes preparing multi device support * Lots of internal changes preparing multi device support

View File

@ -186,11 +186,18 @@ public class BluetoothCommunicationService extends Service {
GBDeviceCommandAppManagementResult appMgmtRes = (GBDeviceCommandAppManagementResult) deviceCmd; GBDeviceCommandAppManagementResult appMgmtRes = (GBDeviceCommandAppManagementResult) deviceCmd;
switch (appMgmtRes.type) { switch (appMgmtRes.type) {
case DELETE: case DELETE:
// right now on the Pebble we also receive this on a failed/successful installation ;/
switch (appMgmtRes.result) { switch (appMgmtRes.result) {
case FAILURE: case FAILURE:
Log.i(TAG, "failure removing app"); // TODO: report to AppManager Log.i(TAG, "failure removing app"); // TODO: report to AppManager
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
((PebbleIoThread) mGBDeviceIoThread).finishInstall(true);
}
break; break;
case SUCCESS: case SUCCESS:
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
((PebbleIoThread) mGBDeviceIoThread).finishInstall(false);
}
// refresh app list // refresh app list
mGBDeviceIoThread.write(mGBDeviceProtocol.encodeAppInfoReq()); mGBDeviceIoThread.write(mGBDeviceProtocol.encodeAppInfoReq());
break; break;
@ -202,6 +209,9 @@ public class BluetoothCommunicationService extends Service {
switch (appMgmtRes.result) { switch (appMgmtRes.result) {
case FAILURE: case FAILURE:
Log.i(TAG, "failure installing app"); // TODO: report to Installer Log.i(TAG, "failure installing app"); // TODO: report to Installer
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
((PebbleIoThread) mGBDeviceIoThread).finishInstall(true);
}
break; break;
case SUCCESS: case SUCCESS:
if (mGBDevice.getType() == GBDevice.Type.PEBBLE) { if (mGBDevice.getType() == GBDevice.Type.PEBBLE) {
@ -517,6 +527,7 @@ public class BluetoothCommunicationService extends Service {
switch (mmInstallState) { switch (mmInstallState) {
case APP_WAIT_SLOT: case APP_WAIT_SLOT:
if (mmInstallSlot != -1) { if (mmInstallSlot != -1) {
updateNotification("starting installation");
mmInstallState = PebbleAppInstallState.APP_START_INSTALL; mmInstallState = PebbleAppInstallState.APP_START_INSTALL;
continue; continue;
} }
@ -541,13 +552,8 @@ public class BluetoothCommunicationService extends Service {
} else if (fileName.equals("app_resources.pbpack")) { } else if (fileName.equals("app_resources.pbpack")) {
type = PebbleProtocol.PUTBYTES_TYPE_RESOURCES; type = PebbleProtocol.PUTBYTES_TYPE_RESOURCES;
} else { } else {
// FIXME: proper state for cancellation finishInstall(true);
mmInstallState = PebbleAppInstallState.UNKNOWN; break;
mmPBWReader = null;
mmIsInstalling = false;
mmZis = null;
mmAppInstallToken = -1;
mmInstallSlot = -1;
} }
writeInstallApp(mmPebbleProtocol.encodeUploadStart(type, (byte) mmInstallSlot, binarySize)); writeInstallApp(mmPebbleProtocol.encodeUploadStart(type, (byte) mmInstallSlot, binarySize));
@ -595,11 +601,6 @@ public class BluetoothCommunicationService extends Service {
break; break;
case APP_REFRESH: case APP_REFRESH:
writeInstallApp(mmPebbleProtocol.encodeAppRefresh(mmInstallSlot)); writeInstallApp(mmPebbleProtocol.encodeAppRefresh(mmInstallSlot));
mmPBWReader = null;
mmIsInstalling = false;
mmZis = null;
mmAppInstallToken = -1;
mmInstallSlot = -1;
break; break;
default: default:
break; break;
@ -748,6 +749,28 @@ public class BluetoothCommunicationService extends Service {
mmIsInstalling = true; 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() { public void quit() {
mmQuit = true; mmQuit = true;
if (mBtSocket != null) { if (mBtSocket != null) {

View File

@ -65,7 +65,7 @@ public class NotificationListener extends NotificationListenerService {
*/ */
if (source.equals("android") || if (source.equals("android") ||
source.equals("com.android.systemui" ) || source.equals("com.android.systemui") ||
source.equals("com.android.dialer") || source.equals("com.android.dialer") ||
source.equals("com.fsck.k9") || source.equals("com.fsck.k9") ||
source.equals("com.android.mms")) { source.equals("com.android.mms")) {

View File

@ -124,6 +124,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
static final short LENGTH_UPLOADCHUNK = 9; static final short LENGTH_UPLOADCHUNK = 9;
static final short LENGTH_UPLOADCOMMIT = 9; static final short LENGTH_UPLOADCOMMIT = 9;
static final short LENGTH_UPLOADCOMPLETE = 5; static final short LENGTH_UPLOADCOMPLETE = 5;
static final short LENGTH_UPLOADCANCEL = 5;
private static byte[] encodeMessage(short endpoint, byte type, int cookie, String[] parts) { private static byte[] encodeMessage(short endpoint, byte type, int cookie, String[] parts) {
// Calculate length first // Calculate length first
@ -342,6 +343,16 @@ public class PebbleProtocol extends GBDeviceProtocol {
return buf.array(); 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) { public byte[] encodeAppRefresh(int index) {
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_REFRESHAPP); ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_REFRESHAPP);
buf.order(ByteOrder.BIG_ENDIAN); buf.order(ByteOrder.BIG_ENDIAN);