1// Copyright 2016 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15#ifndef BUFFET_BINDER_COMMAND_PROXY_H_ 16#define BUFFET_BINDER_COMMAND_PROXY_H_ 17 18#include <string> 19 20#include <base/macros.h> 21#include <weave/command.h> 22 23#include "android/weave/BnWeaveCommand.h" 24 25namespace buffet { 26 27// Implementation of android::weave::IWeaveCommand binder object. 28// This class simply redirects binder calls to the underlying weave::Command 29// object (and performs necessary parameter/result type conversions). 30class BinderCommandProxy : public android::weave::BnWeaveCommand { 31 public: 32 explicit BinderCommandProxy(const std::weak_ptr<weave::Command>& command); 33 ~BinderCommandProxy() override = default; 34 35 android::binder::Status getId(android::String16* id) override; 36 android::binder::Status getName(android::String16* name) override; 37 android::binder::Status getComponent(android::String16* component) override; 38 android::binder::Status getState(android::String16* state) override; 39 android::binder::Status getOrigin(android::String16* origin) override; 40 android::binder::Status getParameters(android::String16* parameters) override; 41 android::binder::Status getProgress(android::String16* progress) override; 42 android::binder::Status getResults(android::String16* results) override; 43 android::binder::Status setProgress( 44 const android::String16& progress) override; 45 android::binder::Status complete(const android::String16& results) override; 46 android::binder::Status abort(const android::String16& errorCode, 47 const android::String16& errorMessage) override; 48 android::binder::Status cancel() override; 49 android::binder::Status pause() override; 50 android::binder::Status setError( 51 const android::String16& errorCode, 52 const android::String16& errorMessage) override; 53 54 private: 55 std::weak_ptr<weave::Command> command_; 56 57 DISALLOW_COPY_AND_ASSIGN(BinderCommandProxy); 58}; 59 60} // namespace buffet 61 62#endif // BUFFET_BINDER_COMMAND_PROXY_H_ 63