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

Commit d3fdea5e authored by Anthony Stange's avatar Anthony Stange Committed by Android (Google) Code Review
Browse files

Merge changes from topic "update_contexthub" into sc-dev

* changes:
  Update contexthub VTS based on latest spec
  Modify default contexthub impl based on latest spec
  Rework V1.2 ContextHub HAL spec
parents 7832c144 a03042d7
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -50,18 +50,6 @@ interface IContexthub extends @1.1::IContexthub {
     */
    registerCallback_1_2(uint32_t hubId, IContexthubCallback cb) generates (Result result);

    /**
     * Send a message to a hub
     *
     * @param hubId identifier for hub to send message to
     * @param msg   message to be sent
     *
     * @return result OK if successful, error code otherwise
     *                BAD_VALUE if parameters are not valid
     *                TRANSACTION_FAILED if message send failed
     */
    sendMessageToHub_1_2(uint32_t hubId, ContextHubMsg msg) generates (Result result);

    /**
     * Notification sent by the framework to indicate that the user
     * has changed a setting.
+0 −6
Original line number Diff line number Diff line
@@ -80,12 +80,6 @@ Return<Result> Contexthub::registerCallback_1_2(uint32_t hubId,
    return Result::BAD_PARAMS;
}

// We don't expose any nanoapps, therefore all nanoapp-related API calls return with BAD_PARAMS
Return<Result> Contexthub::sendMessageToHub_1_2(uint32_t /* hubId */,
                                                const ContextHubMsg& /* msg */) {
    return Result::BAD_PARAMS;
}

Return<void> Contexthub::onSettingChanged(SettingV1_1 /*setting*/, SettingValue /*newValue*/) {
    return Void();
}
+0 −2
Original line number Diff line number Diff line
@@ -55,8 +55,6 @@ class Contexthub
    Return<Result> registerCallback_1_2(uint32_t hubId,
                                        const sp<V1_2::IContexthubCallback>& cb) override;

    Return<Result> sendMessageToHub_1_2(uint32_t hubId, const ContextHubMsg& msg) override;

  private:
    sp<IContextHubCallbackWrapperBase> mCallback;
};
+2 −5
Original line number Diff line number Diff line
@@ -45,11 +45,8 @@ struct ContextHubMsg {
    @1.0::ContextHubMsg msg_1_0;

    /**
     * The list of Android permissions that the sender of this message has at
     * the time the message was sent.
     *
     * The HAL MUST drop messages to nanoapps if this list of permissions is not
     * a superset of those of the receiving nanoapp(s).
     * The list of Android permissions held by the sending nanoapp at the time
     * the message was sent.
     *
     * The framework MUST drop messages to host apps that don't have a superset
     * of the permissions that the sending nanoapp is using.
+0 −31
Original line number Diff line number Diff line
@@ -195,39 +195,8 @@ class TxnResultCallback : public ContexthubCallbackV1_2 {
    std::promise<TransactionResult> promise;
};

// Parameterized fixture that sets the callback to TxnResultCallback
class ContexthubTxnTest : public ContexthubHidlTest {
  public:
    virtual void SetUp() override {
        ContexthubHidlTest::SetUp();
        ASSERT_OK(registerCallback_1_2(cb));
    }

    sp<TxnResultCallback> cb = new TxnResultCallback();
};

TEST_P(ContexthubTxnTest, TestSendMessageToNonExistentNanoApp) {
    ContextHubMsg msg;
    msg.msg_1_0.appName = kNonExistentAppId;
    msg.msg_1_0.msgType = 1;
    msg.msg_1_0.msg.resize(4);
    std::fill(msg.msg_1_0.msg.begin(), msg.msg_1_0.msg.end(), 0);

    ALOGD("Sending message to non-existent nanoapp");
    Result result = hubApi->sendMessageToHub_1_2(getHubId(), msg);
    if (result != Result::OK && result != Result::BAD_PARAMS &&
        result != Result::TRANSACTION_FAILED) {
        FAIL() << "Got result " << asBaseType(result) << ", expected OK, BAD_PARAMS"
               << ", or TRANSACTION_FAILED";
    }
}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ContexthubHidlTest);
INSTANTIATE_TEST_SUITE_P(HubIdSpecificTests, ContexthubHidlTest, testing::ValuesIn(kTestParameters),
                         android::hardware::PrintInstanceTupleNameToString<>);

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ContexthubTxnTest);
INSTANTIATE_TEST_SUITE_P(HubIdSpecificTests, ContexthubTxnTest, testing::ValuesIn(kTestParameters),
                         android::hardware::PrintInstanceTupleNameToString<>);

}  // anonymous namespace