diff --git a/CHANGELOG.md b/CHANGELOG.md index 96dfdde00..a9818781d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java index a42549bf9..1040266fa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/BluetoothCommunicationService.java @@ -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) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java index e67a26f71..402ae3273 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/NotificationListener.java @@ -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")) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java index b00e8008b..bd0a69bd7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/protocol/PebbleProtocol.java @@ -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);