Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "RemoteAccessService.h" |
| 18 | |
| 19 | #include <VehicleUtils.h> |
| 20 | #include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h> |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 21 | #include <android-base/parseint.h> |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 22 | #include <android-base/stringprintf.h> |
| 23 | #include <android/binder_status.h> |
| 24 | #include <grpc++/grpc++.h> |
| 25 | #include <private/android_filesystem_config.h> |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 26 | #include <sys/stat.h> |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 27 | #include <utils/Log.h> |
| 28 | #include <chrono> |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 29 | #include <fstream> |
| 30 | #include <iostream> |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 31 | #include <thread> |
| 32 | |
| 33 | namespace android { |
| 34 | namespace hardware { |
| 35 | namespace automotive { |
| 36 | namespace remoteaccess { |
| 37 | |
| 38 | namespace { |
| 39 | |
| 40 | using ::aidl::android::hardware::automotive::remoteaccess::ApState; |
| 41 | using ::aidl::android::hardware::automotive::remoteaccess::IRemoteTaskCallback; |
Yu Shan | 06ddbc6 | 2023-08-23 18:05:26 -0700 | [diff] [blame] | 42 | using ::aidl::android::hardware::automotive::remoteaccess::ScheduleInfo; |
Yu Shan | 8459a06 | 2023-12-13 17:49:37 -0800 | [diff] [blame] | 43 | using ::aidl::android::hardware::automotive::remoteaccess::TaskType; |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 44 | using ::aidl::android::hardware::automotive::vehicle::VehicleProperty; |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 45 | using ::android::base::Error; |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 46 | using ::android::base::ParseInt; |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 47 | using ::android::base::Result; |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 48 | using ::android::base::ScopedLockAssertion; |
| 49 | using ::android::base::StringAppendF; |
| 50 | using ::android::base::StringPrintf; |
| 51 | using ::android::frameworks::automotive::vhal::IVhalClient; |
| 52 | using ::android::hardware::automotive::vehicle::toInt; |
| 53 | using ::grpc::ClientContext; |
| 54 | using ::grpc::ClientReaderInterface; |
| 55 | using ::grpc::Status; |
| 56 | using ::grpc::StatusCode; |
| 57 | using ::ndk::ScopedAStatus; |
| 58 | |
| 59 | const std::string WAKEUP_SERVICE_NAME = "com.google.vehicle.wakeup"; |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 60 | const std::string PROCESSOR_ID = "application_processor"; |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 61 | constexpr char COMMAND_SET_AP_STATE[] = "--set-ap-state"; |
| 62 | constexpr char COMMAND_START_DEBUG_CALLBACK[] = "--start-debug-callback"; |
| 63 | constexpr char COMMAND_STOP_DEBUG_CALLBACK[] = "--stop-debug-callback"; |
| 64 | constexpr char COMMAND_SHOW_TASK[] = "--show-task"; |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 65 | constexpr char COMMAND_GET_VEHICLE_ID[] = "--get-vehicle-id"; |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 66 | constexpr char COMMAND_INJECT_TASK[] = "--inject-task"; |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 67 | constexpr char COMMAND_INJECT_TASK_NEXT_REBOOT[] = "--inject-task-next-reboot"; |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 68 | constexpr char COMMAND_STATUS[] = "--status"; |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 69 | |
Yu Shan | 58ff091 | 2023-05-12 18:00:59 -0700 | [diff] [blame] | 70 | constexpr char DEBUG_TASK_FILE[] = "/data/vendor/remoteaccess/debugTask"; |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 71 | |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 72 | std::vector<uint8_t> stringToBytes(std::string_view s) { |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 73 | const char* data = s.data(); |
| 74 | return std::vector<uint8_t>(data, data + s.size()); |
| 75 | } |
| 76 | |
| 77 | ScopedAStatus rpcStatusToScopedAStatus(const Status& status, const std::string& errorMsg) { |
| 78 | return ScopedAStatus::fromServiceSpecificErrorWithMessage( |
| 79 | status.error_code(), (errorMsg + ", error: " + status.error_message()).c_str()); |
| 80 | } |
| 81 | |
| 82 | std::string printBytes(const std::vector<uint8_t>& bytes) { |
| 83 | std::string s; |
| 84 | for (size_t i = 0; i < bytes.size(); i++) { |
| 85 | StringAppendF(&s, "%02x", bytes[i]); |
| 86 | } |
| 87 | return s; |
| 88 | } |
| 89 | |
| 90 | bool checkBoolFlag(const char* flag) { |
| 91 | return !strcmp(flag, "1") || !strcmp(flag, "0"); |
| 92 | } |
| 93 | |
| 94 | void dprintErrorStatus(int fd, const char* detail, const ScopedAStatus& status) { |
| 95 | dprintf(fd, "%s, code: %d, error: %s\n", detail, status.getStatus(), status.getMessage()); |
| 96 | } |
| 97 | |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 98 | std::string boolToString(bool x) { |
| 99 | return x ? "true" : "false"; |
| 100 | } |
| 101 | |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 102 | } // namespace |
| 103 | |
| 104 | RemoteAccessService::RemoteAccessService(WakeupClient::StubInterface* grpcStub) |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 105 | : mGrpcStub(grpcStub) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 106 | if (mGrpcStub != nullptr) { |
| 107 | mGrpcServerExist = true; |
| 108 | } |
| 109 | |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 110 | std::ifstream debugTaskFile; |
| 111 | debugTaskFile.open(DEBUG_TASK_FILE, std::ios::in); |
| 112 | if (!debugTaskFile.is_open()) { |
| 113 | ALOGD("No debug task available"); |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | char buffer[1024] = {}; |
| 118 | debugTaskFile.getline(buffer, sizeof(buffer)); |
| 119 | std::string clientId = std::string(buffer); |
| 120 | debugTaskFile.getline(buffer, sizeof(buffer)); |
| 121 | std::string taskData = std::string(buffer); |
| 122 | int latencyInSec; |
| 123 | debugTaskFile >> latencyInSec; |
| 124 | debugTaskFile.close(); |
| 125 | |
| 126 | ALOGD("Task for client: %s, data: [%s], latency: %d\n", clientId.c_str(), taskData.c_str(), |
| 127 | latencyInSec); |
| 128 | |
| 129 | mInjectDebugTaskThread = std::thread([this, clientId, taskData, latencyInSec] { |
| 130 | std::this_thread::sleep_for(std::chrono::seconds(latencyInSec)); |
| 131 | if (auto result = deliverRemoteTaskThroughCallback(clientId, taskData); !result.ok()) { |
| 132 | ALOGE("Failed to inject debug task, clientID: %s, taskData: %s, error: %s", |
| 133 | clientId.c_str(), taskData.c_str(), result.error().message().c_str()); |
| 134 | return; |
| 135 | } |
| 136 | ALOGD("Task for client: %s, data: [%s] successfully injected\n", clientId.c_str(), |
| 137 | taskData.c_str()); |
| 138 | }); |
| 139 | } |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 140 | |
| 141 | RemoteAccessService::~RemoteAccessService() { |
| 142 | maybeStopTaskLoop(); |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 143 | if (mInjectDebugTaskThread.joinable()) { |
| 144 | mInjectDebugTaskThread.join(); |
| 145 | } |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | void RemoteAccessService::maybeStartTaskLoop() { |
| 149 | std::lock_guard<std::mutex> lockGuard(mStartStopTaskLoopLock); |
| 150 | if (mTaskLoopRunning) { |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | mThread = std::thread([this]() { runTaskLoop(); }); |
| 155 | |
| 156 | mTaskLoopRunning = true; |
| 157 | } |
| 158 | |
| 159 | void RemoteAccessService::maybeStopTaskLoop() { |
| 160 | std::lock_guard<std::mutex> lockGuard(mStartStopTaskLoopLock); |
| 161 | if (!mTaskLoopRunning) { |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | { |
| 166 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 167 | // Try to stop the reading stream. |
| 168 | if (mGetRemoteTasksContext) { |
| 169 | mGetRemoteTasksContext->TryCancel(); |
Yu Shan | df39d6e | 2022-12-02 17:01:57 -0800 | [diff] [blame] | 170 | // Don't reset mGetRemoteTaskContext here since the read stream might still be affective |
| 171 | // and might still be using it. This will cause reader->Read to return false and |
| 172 | // mGetRemoteTasksContext will be cleared after reader->Finish() is called. |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 173 | } |
| 174 | mTaskWaitStopped = true; |
| 175 | mCv.notify_all(); |
| 176 | } |
| 177 | if (mThread.joinable()) { |
| 178 | mThread.join(); |
| 179 | } |
| 180 | |
| 181 | mTaskLoopRunning = false; |
| 182 | } |
| 183 | |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 184 | void RemoteAccessService::updateGrpcReadChannelOpen(bool grpcReadChannelOpen) { |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 185 | std::lock_guard<std::mutex> lockGuard(mLock); |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 186 | mGrpcReadChannelOpen = grpcReadChannelOpen; |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | Result<void> RemoteAccessService::deliverRemoteTaskThroughCallback(const std::string& clientId, |
| 190 | std::string_view taskData) { |
| 191 | std::shared_ptr<IRemoteTaskCallback> callback; |
| 192 | { |
| 193 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 194 | callback = mRemoteTaskCallback; |
| 195 | mClientIdToTaskCount[clientId] += 1; |
| 196 | } |
| 197 | if (callback == nullptr) { |
| 198 | return Error() << "No callback registered, task ignored"; |
| 199 | } |
| 200 | ALOGD("Calling onRemoteTaskRequested callback for client ID: %s", clientId.c_str()); |
| 201 | ScopedAStatus callbackStatus = |
| 202 | callback->onRemoteTaskRequested(clientId, stringToBytes(taskData)); |
| 203 | if (!callbackStatus.isOk()) { |
| 204 | return Error() << "Failed to call onRemoteTaskRequested callback, status: " |
| 205 | << callbackStatus.getStatus() |
| 206 | << ", message: " << callbackStatus.getMessage(); |
| 207 | } |
| 208 | return {}; |
| 209 | } |
| 210 | |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 211 | void RemoteAccessService::runTaskLoop() { |
| 212 | GetRemoteTasksRequest request = {}; |
| 213 | std::unique_ptr<ClientReaderInterface<GetRemoteTasksResponse>> reader; |
| 214 | while (true) { |
| 215 | { |
| 216 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 217 | mGetRemoteTasksContext.reset(new ClientContext()); |
| 218 | reader = mGrpcStub->GetRemoteTasks(mGetRemoteTasksContext.get(), request); |
| 219 | } |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 220 | updateGrpcReadChannelOpen(true); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 221 | GetRemoteTasksResponse response; |
| 222 | while (reader->Read(&response)) { |
| 223 | ALOGI("Receiving one task from remote task client"); |
| 224 | |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 225 | if (auto result = |
| 226 | deliverRemoteTaskThroughCallback(response.clientid(), response.data()); |
| 227 | !result.ok()) { |
| 228 | ALOGE("%s", result.error().message().c_str()); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 229 | continue; |
| 230 | } |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 231 | } |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 232 | updateGrpcReadChannelOpen(false); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 233 | Status status = reader->Finish(); |
Yu Shan | df39d6e | 2022-12-02 17:01:57 -0800 | [diff] [blame] | 234 | mGetRemoteTasksContext.reset(); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 235 | |
| 236 | ALOGE("GetRemoteTasks stream breaks, code: %d, message: %s, sleeping for 10s and retry", |
| 237 | status.error_code(), status.error_message().c_str()); |
| 238 | // The long lasting connection should not return. But if the server returns, retry after |
| 239 | // 10s. |
| 240 | { |
| 241 | std::unique_lock lk(mLock); |
| 242 | if (mCv.wait_for(lk, std::chrono::milliseconds(mRetryWaitInMs), [this] { |
| 243 | ScopedLockAssertion lockAssertion(mLock); |
| 244 | return mTaskWaitStopped; |
| 245 | })) { |
| 246 | // If the stopped flag is set, we are quitting, exit the loop. |
| 247 | break; |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 253 | ScopedAStatus RemoteAccessService::getVehicleId(std::string* vehicleId) { |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 254 | #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
| 255 | auto vhalClient = IVhalClient::tryCreate(); |
| 256 | if (vhalClient == nullptr) { |
| 257 | ALOGE("Failed to connect to VHAL"); |
| 258 | return ScopedAStatus::fromServiceSpecificErrorWithMessage( |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 259 | /*errorCode=*/0, "Failed to connect to VHAL to get vehicle ID"); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 260 | } |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 261 | return getVehicleIdWithClient(*vhalClient.get(), vehicleId); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 262 | #else |
| 263 | // Don't use VHAL client in fuzzing since IPC is not allowed. |
| 264 | return ScopedAStatus::ok(); |
| 265 | #endif |
| 266 | } |
| 267 | |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 268 | ScopedAStatus RemoteAccessService::getVehicleIdWithClient(IVhalClient& vhalClient, |
| 269 | std::string* vehicleId) { |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 270 | auto result = vhalClient.getValueSync( |
| 271 | *vhalClient.createHalPropValue(toInt(VehicleProperty::INFO_VIN))); |
| 272 | if (!result.ok()) { |
| 273 | return ScopedAStatus::fromServiceSpecificErrorWithMessage( |
| 274 | /*errorCode=*/0, |
| 275 | ("failed to get INFO_VIN from VHAL: " + result.error().message()).c_str()); |
| 276 | } |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 277 | *vehicleId = (*result)->getStringValue(); |
| 278 | return ScopedAStatus::ok(); |
| 279 | } |
| 280 | |
| 281 | ScopedAStatus RemoteAccessService::getProcessorId(std::string* processorId) { |
| 282 | *processorId = PROCESSOR_ID; |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 283 | return ScopedAStatus::ok(); |
| 284 | } |
| 285 | |
| 286 | ScopedAStatus RemoteAccessService::getWakeupServiceName(std::string* wakeupServiceName) { |
| 287 | *wakeupServiceName = WAKEUP_SERVICE_NAME; |
| 288 | return ScopedAStatus::ok(); |
| 289 | } |
| 290 | |
| 291 | ScopedAStatus RemoteAccessService::setRemoteTaskCallback( |
| 292 | const std::shared_ptr<IRemoteTaskCallback>& callback) { |
| 293 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 294 | mRemoteTaskCallback = callback; |
| 295 | return ScopedAStatus::ok(); |
| 296 | } |
| 297 | |
| 298 | ScopedAStatus RemoteAccessService::clearRemoteTaskCallback() { |
| 299 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 300 | mRemoteTaskCallback.reset(); |
| 301 | return ScopedAStatus::ok(); |
| 302 | } |
| 303 | |
| 304 | ScopedAStatus RemoteAccessService::notifyApStateChange(const ApState& newState) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 305 | if (!mGrpcServerExist) { |
| 306 | ALOGW("GRPC server does not exist, do nothing"); |
| 307 | return ScopedAStatus::ok(); |
| 308 | } |
| 309 | |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 310 | ClientContext context; |
| 311 | NotifyWakeupRequiredRequest request = {}; |
| 312 | request.set_iswakeuprequired(newState.isWakeupRequired); |
| 313 | NotifyWakeupRequiredResponse response = {}; |
| 314 | Status status = mGrpcStub->NotifyWakeupRequired(&context, request, &response); |
| 315 | if (!status.ok()) { |
| 316 | return rpcStatusToScopedAStatus(status, "Failed to notify isWakeupRequired"); |
| 317 | } |
| 318 | |
| 319 | if (newState.isReadyForRemoteTask) { |
| 320 | maybeStartTaskLoop(); |
| 321 | } else { |
| 322 | maybeStopTaskLoop(); |
| 323 | } |
| 324 | return ScopedAStatus::ok(); |
| 325 | } |
| 326 | |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 327 | bool RemoteAccessService::isTaskScheduleSupported() { |
| 328 | if (!mGrpcServerExist) { |
| 329 | ALOGW("GRPC server does not exist, task scheduling not supported"); |
| 330 | return false; |
| 331 | } |
| 332 | |
| 333 | return true; |
| 334 | } |
| 335 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 336 | ScopedAStatus RemoteAccessService::isTaskScheduleSupported(bool* out) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 337 | *out = isTaskScheduleSupported(); |
Yu Shan | 06ddbc6 | 2023-08-23 18:05:26 -0700 | [diff] [blame] | 338 | return ScopedAStatus::ok(); |
| 339 | } |
| 340 | |
Yu Shan | 8459a06 | 2023-12-13 17:49:37 -0800 | [diff] [blame] | 341 | ndk::ScopedAStatus RemoteAccessService::getSupportedTaskTypesForScheduling( |
| 342 | std::vector<TaskType>* out) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 343 | out->clear(); |
| 344 | if (!isTaskScheduleSupported()) { |
| 345 | ALOGW("Task scheduleing is not supported, return empty task types"); |
| 346 | return ScopedAStatus::ok(); |
| 347 | } |
| 348 | |
Yu Shan | 8459a06 | 2023-12-13 17:49:37 -0800 | [diff] [blame] | 349 | out->push_back(TaskType::CUSTOM); |
Yu Shan | 9f982fb | 2024-02-15 16:16:42 -0800 | [diff] [blame] | 350 | out->push_back(TaskType::ENTER_GARAGE_MODE); |
Yu Shan | 8459a06 | 2023-12-13 17:49:37 -0800 | [diff] [blame] | 351 | return ScopedAStatus::ok(); |
| 352 | } |
| 353 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 354 | ScopedAStatus RemoteAccessService::scheduleTask(const ScheduleInfo& scheduleInfo) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 355 | if (!isTaskScheduleSupported()) { |
| 356 | ALOGW("Task scheduleing is not supported, return exception"); |
| 357 | return ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, |
| 358 | "task scheduling is not supported"); |
| 359 | } |
| 360 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 361 | ClientContext context; |
| 362 | ScheduleTaskRequest request = {}; |
| 363 | ScheduleTaskResponse response = {}; |
Yu Shan | 4f5ede6 | 2023-12-21 17:25:57 -0800 | [diff] [blame] | 364 | |
| 365 | if (scheduleInfo.count < 0) { |
| 366 | return ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, |
| 367 | "count must be >= 0"); |
| 368 | } |
| 369 | if (scheduleInfo.startTimeInEpochSeconds < 0) { |
| 370 | return ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, |
| 371 | "startTimeInEpochSeconds must be >= 0"); |
| 372 | } |
| 373 | if (scheduleInfo.periodicInSeconds < 0) { |
| 374 | return ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, |
| 375 | "periodicInSeconds must be >= 0"); |
| 376 | } |
| 377 | if (scheduleInfo.taskData.size() > scheduleInfo.MAX_TASK_DATA_SIZE_IN_BYTES) { |
| 378 | return ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT, |
| 379 | "task data too big"); |
| 380 | } |
| 381 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 382 | request.mutable_scheduleinfo()->set_clientid(scheduleInfo.clientId); |
Yu Shan | 9f982fb | 2024-02-15 16:16:42 -0800 | [diff] [blame] | 383 | request.mutable_scheduleinfo()->set_tasktype( |
| 384 | static_cast<ScheduleTaskType>(scheduleInfo.taskType)); |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 385 | request.mutable_scheduleinfo()->set_scheduleid(scheduleInfo.scheduleId); |
| 386 | request.mutable_scheduleinfo()->set_data(scheduleInfo.taskData.data(), |
| 387 | scheduleInfo.taskData.size()); |
| 388 | request.mutable_scheduleinfo()->set_count(scheduleInfo.count); |
| 389 | request.mutable_scheduleinfo()->set_starttimeinepochseconds( |
| 390 | scheduleInfo.startTimeInEpochSeconds); |
| 391 | request.mutable_scheduleinfo()->set_periodicinseconds(scheduleInfo.periodicInSeconds); |
| 392 | Status status = mGrpcStub->ScheduleTask(&context, request, &response); |
| 393 | if (!status.ok()) { |
| 394 | return rpcStatusToScopedAStatus(status, "Failed to call ScheduleTask"); |
| 395 | } |
| 396 | int errorCode = response.errorcode(); |
| 397 | switch (errorCode) { |
| 398 | case ErrorCode::OK: |
| 399 | return ScopedAStatus::ok(); |
| 400 | case ErrorCode::INVALID_ARG: |
Yu Shan | 4f5ede6 | 2023-12-21 17:25:57 -0800 | [diff] [blame] | 401 | return ScopedAStatus::fromExceptionCodeWithMessage( |
| 402 | EX_ILLEGAL_ARGUMENT, "received invalid_arg from grpc server"); |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 403 | default: |
| 404 | // Should not happen. |
| 405 | return ScopedAStatus::fromServiceSpecificErrorWithMessage( |
| 406 | -1, ("Got unknown error code: " + ErrorCode_Name(errorCode) + |
| 407 | " from remote access HAL") |
| 408 | .c_str()); |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | ScopedAStatus RemoteAccessService::unscheduleTask(const std::string& clientId, |
| 413 | const std::string& scheduleId) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 414 | if (!isTaskScheduleSupported()) { |
| 415 | ALOGW("Task scheduleing is not supported, do nothing"); |
| 416 | return ScopedAStatus::ok(); |
| 417 | } |
| 418 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 419 | ClientContext context; |
| 420 | UnscheduleTaskRequest request = {}; |
| 421 | UnscheduleTaskResponse response = {}; |
| 422 | request.set_clientid(clientId); |
| 423 | request.set_scheduleid(scheduleId); |
| 424 | Status status = mGrpcStub->UnscheduleTask(&context, request, &response); |
| 425 | if (!status.ok()) { |
| 426 | return rpcStatusToScopedAStatus(status, "Failed to call UnscheduleTask"); |
| 427 | } |
Yu Shan | 06ddbc6 | 2023-08-23 18:05:26 -0700 | [diff] [blame] | 428 | return ScopedAStatus::ok(); |
| 429 | } |
| 430 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 431 | ScopedAStatus RemoteAccessService::unscheduleAllTasks(const std::string& clientId) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 432 | if (!isTaskScheduleSupported()) { |
| 433 | ALOGW("Task scheduleing is not supported, do nothing"); |
| 434 | return ScopedAStatus::ok(); |
| 435 | } |
| 436 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 437 | ClientContext context; |
| 438 | UnscheduleAllTasksRequest request = {}; |
| 439 | UnscheduleAllTasksResponse response = {}; |
| 440 | request.set_clientid(clientId); |
| 441 | Status status = mGrpcStub->UnscheduleAllTasks(&context, request, &response); |
| 442 | if (!status.ok()) { |
| 443 | return rpcStatusToScopedAStatus(status, "Failed to call UnscheduleAllTasks"); |
| 444 | } |
Yu Shan | 06ddbc6 | 2023-08-23 18:05:26 -0700 | [diff] [blame] | 445 | return ScopedAStatus::ok(); |
| 446 | } |
| 447 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 448 | ScopedAStatus RemoteAccessService::isTaskScheduled(const std::string& clientId, |
| 449 | const std::string& scheduleId, bool* out) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 450 | if (!isTaskScheduleSupported()) { |
| 451 | ALOGW("Task scheduleing is not supported, return false"); |
| 452 | *out = false; |
| 453 | return ScopedAStatus::ok(); |
| 454 | } |
| 455 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 456 | ClientContext context; |
| 457 | IsTaskScheduledRequest request = {}; |
| 458 | IsTaskScheduledResponse response = {}; |
| 459 | request.set_clientid(clientId); |
| 460 | request.set_scheduleid(scheduleId); |
| 461 | Status status = mGrpcStub->IsTaskScheduled(&context, request, &response); |
| 462 | if (!status.ok()) { |
| 463 | return rpcStatusToScopedAStatus(status, "Failed to call isTaskScheduled"); |
| 464 | } |
| 465 | *out = response.istaskscheduled(); |
Yu Shan | 06ddbc6 | 2023-08-23 18:05:26 -0700 | [diff] [blame] | 466 | return ScopedAStatus::ok(); |
| 467 | } |
| 468 | |
Yu Shan | 59f33e4 | 2023-12-18 16:10:41 -0800 | [diff] [blame] | 469 | ScopedAStatus RemoteAccessService::getAllPendingScheduledTasks(const std::string& clientId, |
| 470 | std::vector<ScheduleInfo>* out) { |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 471 | if (!isTaskScheduleSupported()) { |
| 472 | ALOGW("Task scheduleing is not supported, return empty array"); |
| 473 | out->clear(); |
| 474 | return ScopedAStatus::ok(); |
| 475 | } |
| 476 | |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 477 | ClientContext context; |
Yu Shan | 59f33e4 | 2023-12-18 16:10:41 -0800 | [diff] [blame] | 478 | GetAllPendingScheduledTasksRequest request = {}; |
| 479 | GetAllPendingScheduledTasksResponse response = {}; |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 480 | request.set_clientid(clientId); |
Yu Shan | 59f33e4 | 2023-12-18 16:10:41 -0800 | [diff] [blame] | 481 | Status status = mGrpcStub->GetAllPendingScheduledTasks(&context, request, &response); |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 482 | if (!status.ok()) { |
| 483 | return rpcStatusToScopedAStatus(status, "Failed to call isTaskScheduled"); |
| 484 | } |
| 485 | out->clear(); |
| 486 | for (int i = 0; i < response.allscheduledtasks_size(); i++) { |
| 487 | const GrpcScheduleInfo& rpcScheduleInfo = response.allscheduledtasks(i); |
| 488 | ScheduleInfo scheduleInfo = { |
| 489 | .clientId = rpcScheduleInfo.clientid(), |
Yu Shan | 9f982fb | 2024-02-15 16:16:42 -0800 | [diff] [blame] | 490 | .taskType = static_cast<TaskType>(rpcScheduleInfo.tasktype()), |
Yu Shan | 72d6f89 | 2023-08-30 11:44:13 -0700 | [diff] [blame] | 491 | .scheduleId = rpcScheduleInfo.scheduleid(), |
| 492 | .taskData = stringToBytes(rpcScheduleInfo.data()), |
| 493 | .count = rpcScheduleInfo.count(), |
| 494 | .startTimeInEpochSeconds = rpcScheduleInfo.starttimeinepochseconds(), |
| 495 | .periodicInSeconds = rpcScheduleInfo.periodicinseconds(), |
| 496 | }; |
| 497 | out->push_back(std::move(scheduleInfo)); |
| 498 | } |
Yu Shan | 06ddbc6 | 2023-08-23 18:05:26 -0700 | [diff] [blame] | 499 | return ScopedAStatus::ok(); |
| 500 | } |
| 501 | |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 502 | bool RemoteAccessService::checkDumpPermission() { |
| 503 | uid_t uid = AIBinder_getCallingUid(); |
| 504 | return uid == AID_ROOT || uid == AID_SHELL || uid == AID_SYSTEM; |
| 505 | } |
| 506 | |
| 507 | void RemoteAccessService::dumpHelp(int fd) { |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 508 | dprintf(fd, |
| 509 | "RemoteAccess HAL debug interface, Usage: \n" |
| 510 | "%s [0/1](isReadyForRemoteTask) [0/1](isWakeupRequired): Set the new AP state\n" |
| 511 | "%s: Start a debug callback that will record the received tasks\n" |
| 512 | "%s: Stop the debug callback\n" |
| 513 | "%s: Show tasks received by debug callback\n" |
| 514 | "%s: Get vehicle id\n" |
| 515 | "%s [client_id] [task_data]: Inject a task\n" |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 516 | "%s [client_id] [task_data] [latencyInSec]: " |
| 517 | "Inject a task on next reboot after latencyInSec seconds\n" |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 518 | "%s: Show status\n", |
| 519 | COMMAND_SET_AP_STATE, COMMAND_START_DEBUG_CALLBACK, COMMAND_STOP_DEBUG_CALLBACK, |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 520 | COMMAND_SHOW_TASK, COMMAND_GET_VEHICLE_ID, COMMAND_INJECT_TASK, |
| 521 | COMMAND_INJECT_TASK_NEXT_REBOOT, COMMAND_STATUS); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | binder_status_t RemoteAccessService::dump(int fd, const char** args, uint32_t numArgs) { |
| 525 | if (!checkDumpPermission()) { |
| 526 | dprintf(fd, "Caller must be root, system or shell\n"); |
| 527 | return STATUS_PERMISSION_DENIED; |
| 528 | } |
| 529 | |
| 530 | if (numArgs == 0) { |
| 531 | dumpHelp(fd); |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 532 | printCurrentStatus(fd); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 533 | return STATUS_OK; |
| 534 | } |
| 535 | |
| 536 | if (!strcmp(args[0], COMMAND_SET_AP_STATE)) { |
| 537 | if (numArgs < 3) { |
| 538 | dumpHelp(fd); |
| 539 | return STATUS_OK; |
| 540 | } |
| 541 | ApState apState = {}; |
| 542 | const char* remoteTaskFlag = args[1]; |
| 543 | if (!strcmp(remoteTaskFlag, "1") && !strcmp(remoteTaskFlag, "0")) { |
| 544 | dumpHelp(fd); |
| 545 | return STATUS_OK; |
| 546 | } |
| 547 | if (!checkBoolFlag(args[1])) { |
| 548 | dumpHelp(fd); |
| 549 | return STATUS_OK; |
| 550 | } |
| 551 | if (!strcmp(args[1], "1")) { |
| 552 | apState.isReadyForRemoteTask = true; |
| 553 | } |
| 554 | if (!checkBoolFlag(args[2])) { |
| 555 | dumpHelp(fd); |
| 556 | return STATUS_OK; |
| 557 | } |
| 558 | if (!strcmp(args[2], "1")) { |
| 559 | apState.isWakeupRequired = true; |
| 560 | } |
| 561 | auto status = notifyApStateChange(apState); |
| 562 | if (!status.isOk()) { |
| 563 | dprintErrorStatus(fd, "Failed to set AP state", status); |
| 564 | } else { |
| 565 | dprintf(fd, "successfully set the new AP state\n"); |
| 566 | } |
| 567 | } else if (!strcmp(args[0], COMMAND_START_DEBUG_CALLBACK)) { |
| 568 | mDebugCallback = ndk::SharedRefBase::make<DebugRemoteTaskCallback>(); |
| 569 | setRemoteTaskCallback(mDebugCallback); |
| 570 | dprintf(fd, "Debug callback registered\n"); |
| 571 | } else if (!strcmp(args[0], COMMAND_STOP_DEBUG_CALLBACK)) { |
| 572 | if (mDebugCallback) { |
| 573 | mDebugCallback.reset(); |
| 574 | } |
| 575 | clearRemoteTaskCallback(); |
| 576 | dprintf(fd, "Debug callback unregistered\n"); |
| 577 | } else if (!strcmp(args[0], COMMAND_SHOW_TASK)) { |
| 578 | if (mDebugCallback) { |
| 579 | dprintf(fd, "%s", mDebugCallback->printTasks().c_str()); |
| 580 | } else { |
| 581 | dprintf(fd, "Debug callback is not currently used, use \"%s\" first.\n", |
| 582 | COMMAND_START_DEBUG_CALLBACK); |
| 583 | } |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 584 | } else if (!strcmp(args[0], COMMAND_GET_VEHICLE_ID)) { |
| 585 | std::string vehicleId; |
| 586 | auto status = getVehicleId(&vehicleId); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 587 | if (!status.isOk()) { |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 588 | dprintErrorStatus(fd, "Failed to get vehicle ID", status); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 589 | } else { |
Eric Jeong | 6c3a1d8 | 2023-03-16 00:45:40 -0700 | [diff] [blame] | 590 | dprintf(fd, "Vehicle Id: %s\n", vehicleId.c_str()); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 591 | } |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 592 | } else if (!strcmp(args[0], COMMAND_INJECT_TASK)) { |
| 593 | if (numArgs < 3) { |
| 594 | dumpHelp(fd); |
| 595 | return STATUS_OK; |
| 596 | } |
| 597 | debugInjectTask(fd, args[1], args[2]); |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 598 | } else if (!strcmp(args[0], COMMAND_INJECT_TASK_NEXT_REBOOT)) { |
| 599 | if (numArgs < 4) { |
| 600 | dumpHelp(fd); |
| 601 | return STATUS_OK; |
| 602 | } |
| 603 | debugInjectTaskNextReboot(fd, args[1], args[2], args[3]); |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 604 | } else if (!strcmp(args[0], COMMAND_STATUS)) { |
| 605 | printCurrentStatus(fd); |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 606 | } else { |
| 607 | dumpHelp(fd); |
| 608 | } |
| 609 | |
| 610 | return STATUS_OK; |
| 611 | } |
| 612 | |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 613 | void RemoteAccessService::printCurrentStatus(int fd) { |
| 614 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 615 | dprintf(fd, |
| 616 | "\nRemoteAccess HAL status \n" |
| 617 | "Remote task callback registered: %s\n" |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 618 | "GRPC server exist: %s\n" |
| 619 | "GRPC read channel for receiving tasks open: %s\n" |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 620 | "Received task count by clientId: \n%s\n", |
Yu Shan | 0fbc17f | 2023-12-26 15:57:47 -0800 | [diff] [blame] | 621 | boolToString(mRemoteTaskCallback.get()).c_str(), boolToString(mGrpcServerExist).c_str(), |
| 622 | boolToString(mGrpcReadChannelOpen).c_str(), |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 623 | clientIdToTaskCountToStringLocked().c_str()); |
| 624 | } |
| 625 | |
| 626 | void RemoteAccessService::debugInjectTask(int fd, std::string_view clientId, |
| 627 | std::string_view taskData) { |
| 628 | std::string clientIdCopy = std::string(clientId); |
| 629 | if (auto result = deliverRemoteTaskThroughCallback(clientIdCopy, taskData); !result.ok()) { |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 630 | dprintf(fd, "Failed to inject task: %s\n", result.error().message().c_str()); |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 631 | return; |
| 632 | } |
| 633 | dprintf(fd, "Task for client: %s, data: [%s] successfully injected\n", clientId.data(), |
| 634 | taskData.data()); |
| 635 | } |
| 636 | |
Yu Shan | 194757d | 2023-04-19 11:44:35 -0700 | [diff] [blame] | 637 | void RemoteAccessService::debugInjectTaskNextReboot(int fd, std::string_view clientId, |
| 638 | std::string_view taskData, |
| 639 | const char* latencyInSecStr) { |
| 640 | int latencyInSec; |
| 641 | if (!ParseInt(latencyInSecStr, &latencyInSec)) { |
| 642 | dprintf(fd, "The input latency in second is not a valid integer"); |
| 643 | return; |
| 644 | } |
| 645 | std::ofstream debugTaskFile; |
| 646 | debugTaskFile.open(DEBUG_TASK_FILE, std::ios::out); |
| 647 | if (!debugTaskFile.is_open()) { |
| 648 | dprintf(fd, |
| 649 | "Failed to open debug task file, please run the command: " |
| 650 | "'adb shell touch %s' first\n", |
| 651 | DEBUG_TASK_FILE); |
| 652 | return; |
| 653 | } |
| 654 | if (taskData.find("\n") != std::string::npos) { |
| 655 | dprintf(fd, "Task data must not contain newline\n"); |
| 656 | return; |
| 657 | } |
| 658 | debugTaskFile << clientId << "\n" << taskData << "\n" << latencyInSec; |
| 659 | debugTaskFile.close(); |
| 660 | dprintf(fd, |
| 661 | "Task with clientId: %s, task data: %s, latency: %d sec scheduled for next reboot\n", |
| 662 | clientId.data(), taskData.data(), latencyInSec); |
| 663 | } |
| 664 | |
Yu Shan | 9549368 | 2023-03-21 18:00:17 -0700 | [diff] [blame] | 665 | std::string RemoteAccessService::clientIdToTaskCountToStringLocked() { |
| 666 | // Print the table header |
| 667 | std::string output = "| ClientId | Count |\n"; |
| 668 | for (const auto& [clientId, taskCount] : mClientIdToTaskCount) { |
| 669 | output += StringPrintf(" %-9s %-6zu\n", clientId.c_str(), taskCount); |
| 670 | } |
| 671 | return output; |
| 672 | } |
| 673 | |
Yu Shan | 7a5283f | 2022-10-25 18:01:05 -0700 | [diff] [blame] | 674 | ScopedAStatus DebugRemoteTaskCallback::onRemoteTaskRequested(const std::string& clientId, |
| 675 | const std::vector<uint8_t>& data) { |
| 676 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 677 | mTasks.push_back({ |
| 678 | .clientId = clientId, |
| 679 | .data = data, |
| 680 | }); |
| 681 | return ScopedAStatus::ok(); |
| 682 | } |
| 683 | |
| 684 | std::string DebugRemoteTaskCallback::printTasks() { |
| 685 | std::lock_guard<std::mutex> lockGuard(mLock); |
| 686 | std::string s = StringPrintf("Received %zu tasks in %f seconds", mTasks.size(), |
| 687 | (android::uptimeMillis() - mStartTimeMillis) / 1000.); |
| 688 | for (size_t i = 0; i < mTasks.size(); i++) { |
| 689 | StringAppendF(&s, "Client Id: %s, Data: %s\n", mTasks[i].clientId.c_str(), |
| 690 | printBytes(mTasks[i].data).c_str()); |
| 691 | } |
| 692 | return s; |
| 693 | } |
| 694 | |
| 695 | } // namespace remoteaccess |
| 696 | } // namespace automotive |
| 697 | } // namespace hardware |
| 698 | } // namespace android |