1 /* 2 * Copyright (C) 2023 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 <aidl/com/android/minidroid/testservice/BnTestService.h> 18 #include <minidroid_sd.h> 19 20 #include <stdio.h> 21 #include <string> 22 23 #define LOG_TAG "server_minidroid" 24 #include <log/log.h> 25 26 namespace { 27 start_test_service()28void start_test_service() { 29 class TestService 30 : public aidl::com::android::minidroid::testservice::BnTestService { 31 ndk::ScopedAStatus sayHello() override { 32 ALOGI("Hello World!\n"); 33 return ndk::ScopedAStatus::ok(); 34 } 35 36 ndk::ScopedAStatus printText(const std::string& text) override { 37 ALOGI("%s\n", text.c_str()); 38 return ndk::ScopedAStatus::ok(); 39 } 40 41 ndk::ScopedAStatus addInteger(int32_t a, int32_t b, int32_t* out) override { 42 *out = a + b; 43 return ndk::ScopedAStatus::ok(); 44 } 45 }; 46 auto testService = ndk::SharedRefBase::make<TestService>(); 47 48 bi::sd::setupRpcServer(testService->asBinder(), testService->SERVICE_PORT); 49 } 50 } // namespace 51 main()52int main() { 53 ALOGI("Hello Minidroid server!\n"); 54 55 start_test_service(); 56 57 return 0; 58 } 59