diff --git a/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl b/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl index 9b6eb2f297..b0935c2fb2 100644 --- a/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl +++ b/automotive/remoteaccess/aidl_api/android.hardware.automotive.remoteaccess/current/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl @@ -34,8 +34,9 @@ package android.hardware.automotive.remoteaccess; @VintfStability interface IRemoteAccess { - String getDeviceId(); + String getVehicleId(); String getWakeupServiceName(); + String getProcessorId(); void setRemoteTaskCallback(android.hardware.automotive.remoteaccess.IRemoteTaskCallback callback); void clearRemoteTaskCallback(); void notifyApStateChange(in android.hardware.automotive.remoteaccess.ApState state); diff --git a/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl b/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl index a198b038a5..0f4125f475 100644 --- a/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl +++ b/automotive/remoteaccess/android/hardware/automotive/remoteaccess/IRemoteAccess.aidl @@ -28,19 +28,19 @@ import android.hardware.automotive.remoteaccess.IRemoteTaskCallback; @VintfStability interface IRemoteAccess { /** - * Gets a unique device ID that could be recognized by wake up server. + * Gets a unique vehicle ID that could be recognized by wake up server. * - * This device ID is provisioned during car production and is registered + *

This vehicle ID is provisioned during car production and is registered * with the wake up server. * - * @return a unique device ID. + * @return a unique vehicle ID. */ - String getDeviceId(); + String getVehicleId(); /** * Gets the name for the remote wakeup server. * - * This name will be provided to remote task server during registration + *

This name will be provided to remote task server during registration * and used by remote task server to find the remote wakeup server to * use for waking up the device. This name must be pre-negotiated between * the remote wakeup server/client and the remote task server/client and @@ -50,6 +50,17 @@ interface IRemoteAccess { */ String getWakeupServiceName(); + /** + * Gets a unique processor ID that could be recognized by wake up client. + * + *

This processor ID is used to identify each processor in the vehicle. + * The wake up client which handles many processors determines which + * processor to wake up from the processor ID. + * + *

The processor ID must be unique in the vehicle. + */ + String getProcessorId(); + /** * Sets a callback to be called when a remote task is requested. * diff --git a/automotive/remoteaccess/hal/default/include/RemoteAccessService.h b/automotive/remoteaccess/hal/default/include/RemoteAccessService.h index 74c2af4c9f..5cfca613f4 100644 --- a/automotive/remoteaccess/hal/default/include/RemoteAccessService.h +++ b/automotive/remoteaccess/hal/default/include/RemoteAccessService.h @@ -62,7 +62,9 @@ class RemoteAccessService ~RemoteAccessService(); - ndk::ScopedAStatus getDeviceId(std::string* deviceId) override; + ndk::ScopedAStatus getVehicleId(std::string* vehicleId) override; + + ndk::ScopedAStatus getProcessorId(std::string* processorId) override; ndk::ScopedAStatus getWakeupServiceName(std::string* wakeupServiceName) override; @@ -103,8 +105,8 @@ class RemoteAccessService void runTaskLoop(); void maybeStartTaskLoop(); void maybeStopTaskLoop(); - ndk::ScopedAStatus getDeviceIdWithClient( - android::frameworks::automotive::vhal::IVhalClient& client, std::string* deviceId); + ndk::ScopedAStatus getVehicleIdWithClient( + android::frameworks::automotive::vhal::IVhalClient& client, std::string* vehicleId); void setRetryWaitInMs(size_t retryWaitInMs) { mRetryWaitInMs = retryWaitInMs; } void dumpHelp(int fd); diff --git a/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp b/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp index 4be30a20fa..d9445933ae 100644 --- a/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp +++ b/automotive/remoteaccess/hal/default/src/RemoteAccessService.cpp @@ -48,11 +48,12 @@ using ::grpc::StatusCode; using ::ndk::ScopedAStatus; const std::string WAKEUP_SERVICE_NAME = "com.google.vehicle.wakeup"; +const std::string PROCESSOR_ID = "application_processor"; constexpr char COMMAND_SET_AP_STATE[] = "--set-ap-state"; constexpr char COMMAND_START_DEBUG_CALLBACK[] = "--start-debug-callback"; constexpr char COMMAND_STOP_DEBUG_CALLBACK[] = "--stop-debug-callback"; constexpr char COMMAND_SHOW_TASK[] = "--show-task"; -constexpr char COMMAND_GET_DEVICE_ID[] = "--get-device-id"; +constexpr char COMMAND_GET_VEHICLE_ID[] = "--get-vehicle-id"; std::vector stringToBytes(const std::string& s) { const char* data = s.data(); @@ -176,23 +177,23 @@ void RemoteAccessService::runTaskLoop() { } } -ScopedAStatus RemoteAccessService::getDeviceId(std::string* deviceId) { +ScopedAStatus RemoteAccessService::getVehicleId(std::string* vehicleId) { #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION auto vhalClient = IVhalClient::tryCreate(); if (vhalClient == nullptr) { ALOGE("Failed to connect to VHAL"); return ScopedAStatus::fromServiceSpecificErrorWithMessage( - /*errorCode=*/0, "Failed to connect to VHAL to get device ID"); + /*errorCode=*/0, "Failed to connect to VHAL to get vehicle ID"); } - return getDeviceIdWithClient(*vhalClient.get(), deviceId); + return getVehicleIdWithClient(*vhalClient.get(), vehicleId); #else // Don't use VHAL client in fuzzing since IPC is not allowed. return ScopedAStatus::ok(); #endif } -ScopedAStatus RemoteAccessService::getDeviceIdWithClient(IVhalClient& vhalClient, - std::string* deviceId) { +ScopedAStatus RemoteAccessService::getVehicleIdWithClient(IVhalClient& vhalClient, + std::string* vehicleId) { auto result = vhalClient.getValueSync( *vhalClient.createHalPropValue(toInt(VehicleProperty::INFO_VIN))); if (!result.ok()) { @@ -200,7 +201,12 @@ ScopedAStatus RemoteAccessService::getDeviceIdWithClient(IVhalClient& vhalClient /*errorCode=*/0, ("failed to get INFO_VIN from VHAL: " + result.error().message()).c_str()); } - *deviceId = (*result)->getStringValue(); + *vehicleId = (*result)->getStringValue(); + return ScopedAStatus::ok(); +} + +ScopedAStatus RemoteAccessService::getProcessorId(std::string* processorId) { + *processorId = PROCESSOR_ID; return ScopedAStatus::ok(); } @@ -252,8 +258,8 @@ void RemoteAccessService::dumpHelp(int fd) { COMMAND_START_DEBUG_CALLBACK + " Start a debug callback that will record the received tasks\n" + COMMAND_STOP_DEBUG_CALLBACK + " Stop the debug callback\n" + COMMAND_SHOW_TASK + - " Show tasks received by debug callback\n" + COMMAND_GET_DEVICE_ID + - " Get device id\n") + " Show tasks received by debug callback\n" + COMMAND_GET_VEHICLE_ID + + " Get vehicle id\n") .c_str()); } @@ -316,13 +322,13 @@ binder_status_t RemoteAccessService::dump(int fd, const char** args, uint32_t nu dprintf(fd, "Debug callback is not currently used, use \"%s\" first.\n", COMMAND_START_DEBUG_CALLBACK); } - } else if (!strcmp(args[0], COMMAND_GET_DEVICE_ID)) { - std::string deviceId; - auto status = getDeviceId(&deviceId); + } else if (!strcmp(args[0], COMMAND_GET_VEHICLE_ID)) { + std::string vehicleId; + auto status = getVehicleId(&vehicleId); if (!status.isOk()) { - dprintErrorStatus(fd, "Failed to get device ID", status); + dprintErrorStatus(fd, "Failed to get vehicle ID", status); } else { - dprintf(fd, "Device Id: %s\n", deviceId.c_str()); + dprintf(fd, "Vehicle Id: %s\n", vehicleId.c_str()); } } else { dumpHelp(fd); diff --git a/automotive/remoteaccess/hal/default/test/RemoteAccessServiceUnitTest.cpp b/automotive/remoteaccess/hal/default/test/RemoteAccessServiceUnitTest.cpp index 8c4fa080eb..c5afd6300f 100644 --- a/automotive/remoteaccess/hal/default/test/RemoteAccessServiceUnitTest.cpp +++ b/automotive/remoteaccess/hal/default/test/RemoteAccessServiceUnitTest.cpp @@ -187,8 +187,8 @@ class RemoteAccessServiceUnitTest : public ::testing::Test { void setRetryWaitInMs(size_t retryWaitInMs) { mService->setRetryWaitInMs(retryWaitInMs); } - ScopedAStatus getDeviceIdWithClient(IVhalClient& vhalClient, std::string* deviceId) { - return mService->getDeviceIdWithClient(vhalClient, deviceId); + ScopedAStatus getVehicleIdWithClient(IVhalClient& vhalClient, std::string* vehicleId) { + return mService->getVehicleIdWithClient(vhalClient, vehicleId); } private: @@ -358,13 +358,13 @@ TEST_F(RemoteAccessServiceUnitTest, TestGetRemoteTasksNotReadyAfterReady) { std::this_thread::sleep_for(std::chrono::milliseconds(150)); } -TEST_F(RemoteAccessServiceUnitTest, testGetDeviceId) { - std::string deviceId; +TEST_F(RemoteAccessServiceUnitTest, testGetVehicleId) { + std::string vehicleId; FakeVhalClient vhalClient; - ASSERT_TRUE(getDeviceIdWithClient(vhalClient, &deviceId).isOk()); - ASSERT_EQ(deviceId, kTestVin); + ASSERT_TRUE(getVehicleIdWithClient(vhalClient, &vehicleId).isOk()); + ASSERT_EQ(vehicleId, kTestVin); } } // namespace remoteaccess