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

Commit a96fbfe2 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Only send messages to CHRE if client is registered

In the previous API design, we only allowed the ContextHubClient
to be used if a ContextHubClientCallback was supplied. Since we are
updating the API to allow a callback xor a PendingIntent, change
sendMessageToNanoApp to reflect this.

Bug: 117612105
Test: Compile only
Change-Id: Ic1ef7c77b95699a00fe29c5941a53af37e9385de
parent 1bb34a86
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -154,11 +154,7 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
        ContextHubServiceUtil.checkPermissions(mContext);

        int result;
        IContextHubClientCallback callback = null;
        synchronized (this) {
            callback = mCallbackInterface;
        }
        if (callback != null) {
        if (isRegistered()) {
            ContextHubMsg messageToNanoApp =
                    ContextHubServiceUtil.createHidlContextHubMessage(mHostEndPointId, message);

@@ -384,4 +380,11 @@ public class ContextHubClientBroker extends IContextHubClient.Stub
            }
        }
    }

    /**
     * @return true if the client is still registered with the service, false otherwise
     */
    private synchronized boolean isRegistered() {
        return mRegistered;
    }
}