contexthub: specify size for requestSessionIdRange

Test: build
Flag: N/A
Bug: 361830233
Change-Id: Ifaaff94cb791e2828082af1b6ea49e9afd346c22
diff --git a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
index 93b8ff5..2646d15 100644
--- a/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
+++ b/contexthub/aidl/aidl_api/android.hardware.contexthub/current/android/hardware/contexthub/IContextHub.aidl
@@ -54,7 +54,7 @@
   void registerEndpoint(in android.hardware.contexthub.EndpointInfo endpoint);
   void unregisterEndpoint(in android.hardware.contexthub.EndpointInfo endpoint);
   void registerEndpointCallback(in android.hardware.contexthub.IEndpointCallback callback);
-  int[] requestSessionIdRange(int size);
+  int[2] requestSessionIdRange(int size);
   void openEndpointSession(int sessionId, in android.hardware.contexthub.EndpointId destination, in android.hardware.contexthub.EndpointId initiator, in @nullable String serviceDescriptor);
   void sendMessageToEndpoint(int sessionId, in android.hardware.contexthub.Message msg);
   void sendMessageDeliveryStatusToEndpoint(int sessionId, in android.hardware.contexthub.MessageDeliveryStatus msgStatus);
diff --git a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
index 83f73c3..eb6d051 100644
--- a/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
+++ b/contexthub/aidl/android/hardware/contexthub/IContextHub.aidl
@@ -303,7 +303,7 @@
      * @throws EX_ILLEGAL_ARGUMENT if the size is invalid.
      * @throws EX_SERVICE_SPECIFIC if the id range requested cannot be allocated.
      */
-    int[] requestSessionIdRange(int size);
+    int[2] requestSessionIdRange(int size);
 
     /**
      * Request to open a session for communication between an endpoint previously registered by the
diff --git a/contexthub/aidl/default/ContextHub.cpp b/contexthub/aidl/default/ContextHub.cpp
index 4ae9c09..c1af0a3 100644
--- a/contexthub/aidl/default/ContextHub.cpp
+++ b/contexthub/aidl/default/ContextHub.cpp
@@ -286,7 +286,7 @@
 };
 
 ScopedAStatus ContextHub::requestSessionIdRange(int32_t in_size,
-                                                std::vector<int32_t>* _aidl_return) {
+                                                std::array<int32_t, 2>* _aidl_return) {
     constexpr int32_t kMaxSize = 1024;
     if (in_size > kMaxSize || _aidl_return == nullptr) {
         return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
@@ -297,8 +297,8 @@
         mMaxValidSessionId = in_size;
     }
 
-    _aidl_return->push_back(0);
-    _aidl_return->push_back(in_size);
+    _aidl_return->at(0) = 0;
+    _aidl_return->at(1) = in_size;
     return ScopedAStatus::ok();
 };
 
diff --git a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
index 4968878..6da8bf2 100644
--- a/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
+++ b/contexthub/aidl/default/include/contexthub-impl/ContextHub.h
@@ -61,7 +61,7 @@
     ::ndk::ScopedAStatus registerEndpointCallback(
             const std::shared_ptr<IEndpointCallback>& in_callback) override;
     ::ndk::ScopedAStatus requestSessionIdRange(int32_t in_size,
-                                               std::vector<int32_t>* _aidl_return) override;
+                                               std::array<int32_t, 2>* _aidl_return) override;
     ::ndk::ScopedAStatus openEndpointSession(
             int32_t in_sessionId, const EndpointId& in_destination, const EndpointId& in_initiator,
             const std::optional<std::string>& in_serviceDescriptor) override;
diff --git a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp
index 95a96cd..090d4fe 100644
--- a/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp
+++ b/contexthub/aidl/vts/VtsAidlHalContextHubTargetTest.cpp
@@ -684,7 +684,7 @@
 
     // Request the range
     constexpr int32_t requestedRange = 100;
-    std::vector<int32_t> range;
+    std::array<int32_t, 2> range;
     ASSERT_TRUE(contextHub->requestSessionIdRange(requestedRange, &range).isOk());
     EXPECT_EQ(range.size(), 2);
     EXPECT_GE(range[1] - range[0] + 1, requestedRange);
@@ -737,7 +737,7 @@
 
     // Request the range
     constexpr int32_t requestedRange = 100;
-    std::vector<int32_t> range;
+    std::array<int32_t, 2> range;
     ASSERT_TRUE(contextHub->requestSessionIdRange(requestedRange, &range).isOk());
     EXPECT_EQ(range.size(), 2);
     EXPECT_GE(range[1] - range[0] + 1, requestedRange);