1 // 2 // Copyright (C) 2016 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 #ifndef TRUNKS_TRUNKS_BINDER_PROXY_H_ 18 #define TRUNKS_TRUNKS_BINDER_PROXY_H_ 19 20 #include <string> 21 22 #include <base/macros.h> 23 24 #include "android/trunks/ITrunks.h" 25 #include "trunks/command_transceiver.h" 26 #include "trunks/trunks_export.h" 27 28 namespace trunks { 29 30 // TrunksBinderProxy is a CommandTransceiver implementation that forwards all 31 // commands to the trunksd binder daemon. See TrunksBinderService for details on 32 // how the commands are handled once they reach trunksd. 33 class TRUNKS_EXPORT TrunksBinderProxy : public CommandTransceiver { 34 public: 35 TrunksBinderProxy() = default; 36 ~TrunksBinderProxy() override = default; 37 38 // Initializes the client. Returns true on success. 39 bool Init() override; 40 41 // Asynchronous calls assume a message loop and binder watcher have already 42 // been configured elsewhere. 43 void SendCommand(const std::string& command, 44 const ResponseCallback& callback) override; 45 std::string SendCommandAndWait(const std::string& command) override; 46 47 private: 48 android::sp<android::trunks::ITrunks> trunks_service_; 49 50 DISALLOW_COPY_AND_ASSIGN(TrunksBinderProxy); 51 }; 52 53 } // namespace trunks 54 55 #endif // TRUNKS_TRUNKS_BINDER_PROXY_H_ 56