Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d08f509d authored by Vasu Nori's avatar Vasu Nori
Browse files

Fix non-working sent-notification.

This is copy of the change reviewed (on internal repo) ag/3553436

Bug:71910324

Test: tested w/ KitchenSink. Sent a message to another phone and
received the sent-notification. Saw a notification pop-up on Mojave
when a new message is received.

Change-Id: I3bc25c95383530448e81f284fe6c609c7249a60b
parent a270f0b9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -267,6 +267,11 @@ public class MapClientService extends ProfileService {

        if (mMnsServer == null) {
            mMnsServer = MapUtils.newMnsServiceInstance(this);
            if (mMnsServer == null) {
                // this can't happen
                Log.w(TAG, "MnsService is *not* created!");
                return false;
            }
        }

        mAdapter = BluetoothAdapter.getDefaultAdapter();
+1 −1
Original line number Diff line number Diff line
@@ -26,6 +26,6 @@ class MapUtils {
    }

    static MnsService newMnsServiceInstance(MapClientService mapClientService) {
        return (sMnsService != null) ? new MnsService(mapClientService) : sMnsService;
        return (sMnsService == null) ? new MnsService(mapClientService) : sMnsService;
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -65,7 +65,9 @@ public class MasClient {
    };
    private static final byte OAP_TAGID_MAP_SUPPORTED_FEATURES = 0x29;
    private static final int MAP_FEATURE_NOTIFICATION_REGISTRATION = 0x00000001;
    private static final int MAP_SUPPORTED_FEATURES = MAP_FEATURE_NOTIFICATION_REGISTRATION;
    private static final int MAP_FEATURE_NOTIFICATION = 0x00000002;
    static final int MAP_SUPPORTED_FEATURES =
            MAP_FEATURE_NOTIFICATION_REGISTRATION | MAP_FEATURE_NOTIFICATION;

    private final StateMachine mCallback;
    private Handler mHandler;
+19 −6
Original line number Diff line number Diff line
@@ -437,7 +437,8 @@ final class MceStateMachine extends StateMachine {
                        if (DBG) {
                            Log.d(TAG, "Message Sent......." + messageHandle);
                        }
                        mSentMessageLog.put(messageHandle,
                        // ignore the top-order byte (converted to string) in the handle for now
                        mSentMessageLog.put(messageHandle.substring(2),
                                ((RequestPushMessage) message.obj).getBMsg());
                    } else if (message.obj instanceof RequestGetMessagesListing) {
                        processMessageListing((RequestGetMessagesListing) message.obj);
@@ -589,10 +590,14 @@ final class MceStateMachine extends StateMachine {
                Log.d(TAG, "got a status for " + handle + " Status = " + status);
            }
            PendingIntent intentToSend = null;
            if (status == EventReport.Type.SENDING_SUCCESS) {
                intentToSend = mSentReceiptRequested.remove(mSentMessageLog.get(handle));
            } else if (status == EventReport.Type.DELIVERY_SUCCESS) {
                intentToSend = mDeliveryReceiptRequested.remove(mSentMessageLog.get(handle));
            // ignore the top-order byte (converted to string) in the handle for now
            String shortHandle = handle.substring(2);
            if (status == EventReport.Type.SENDING_FAILURE
                    || status == EventReport.Type.SENDING_SUCCESS) {
                intentToSend = mSentReceiptRequested.remove(mSentMessageLog.get(shortHandle));
            } else if (status == EventReport.Type.DELIVERY_SUCCESS
                    || status == EventReport.Type.DELIVERY_FAILURE) {
                intentToSend = mDeliveryReceiptRequested.remove(mSentMessageLog.get(shortHandle));
            }

            if (intentToSend != null) {
@@ -600,10 +605,18 @@ final class MceStateMachine extends StateMachine {
                    if (DBG) {
                        Log.d(TAG, "*******Sending " + intentToSend);
                    }
                    intentToSend.send();
                    int result = 0;
                    if (status == EventReport.Type.SENDING_FAILURE
                            || status == EventReport.Type.DELIVERY_FAILURE) {
                        result = -1;
                    }
                    intentToSend.send(result);
                } catch (PendingIntent.CanceledException e) {
                    Log.w(TAG, "Notification Request Canceled" + e);
                }
            } else {
                Log.e(TAG, "Received a notification on message with handle = "
                        + handle + ", but it is NOT found in mSentMessageLog! where did it go?");
            }
        }
    }
+2 −3
Original line number Diff line number Diff line
@@ -40,8 +40,6 @@ class MnsService {
    private static final Boolean VDBG = MapClientService.VDBG;
    /* MAP version 1.1 */
    private static final int MNS_VERSION = 0x0101;
    /* MNS features: Notification Feature */
    private static final int MNS_FEATURE_BITS = 0x0002;
    /* these are shared across instances */
    private static SocketAcceptor sAcceptThread = null;
    private static Handler sSessionHandler = null;
@@ -65,7 +63,8 @@ class MnsService {
            return;
        }
        mSdpHandle = sdpManager.createMapMnsRecord("MAP Message Notification Service",
                sServerSockets.getRfcommChannel(), -1, MNS_VERSION, MNS_FEATURE_BITS);
                sServerSockets.getRfcommChannel(), -1, MNS_VERSION,
                MasClient.MAP_SUPPORTED_FEATURES);
    }

    void stop() {