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

Commit c0d1eec4 authored by Matthew Sedam's avatar Matthew Sedam
Browse files

Clear reliable message fields for public input NanoAppMessage

This CL clears the isReliable and messageSequenceNumber fields
in the NanoAppMessage class for inputs to public APIs. These
fields are used internally to track messages, and the public
setter is needed for this purpose.

WANT_LGTM=lelandr

Bug: 328120618
Change-Id: I3fb7a2893e77c7a551c479a4ccee5402d6e5bc78
Test: Presubmits
parent c818a996
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -449,7 +449,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
    }

    /**
     * Sends a reliable message rom this client to a nanoapp.
     * Sends a reliable message from this client to a nanoapp.
     *
     * @param message the message to send
     * @param transactionCallback The callback to use to confirm the delivery of the message for
@@ -473,6 +473,12 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
            @Nullable IContextHubTransactionCallback transactionCallback) {
        ContextHubServiceUtil.checkPermissions(mContext);

        // Clear the isReliable and messageSequenceNumber fields.
        // These will be set to true and a real value if the message
        // is reliable.
        message.setIsReliable(false);
        message.setMessageSequenceNumber(0);

        @ContextHubTransaction.Result int result;
        if (isRegistered()) {
            int authState = mMessageChannelNanoappIdMap.getOrDefault(
@@ -485,7 +491,9 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
                // Return a bland error code for apps targeting old SDKs since they wouldn't be able
                // to use an error code added in S.
                return ContextHubTransaction.RESULT_FAILED_UNKNOWN;
            } else if (authState == AUTHORIZATION_UNKNOWN) {
            }

            if (authState == AUTHORIZATION_UNKNOWN) {
                // Only check permissions the first time a nanoapp is queried since nanoapp
                // permissions don't currently change at runtime. If the host permission changes
                // later, that'll be checked by onOpChanged.