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#include "shill/binder/device_binder_adaptor.h" 18 19#include <binder/Status.h> 20#include <utils/String16.h> 21 22#include "shill/device.h" 23#include "shill/logging.h" 24 25using android::binder::Status; 26using android::IBinder; 27using android::sp; 28using android::String16; 29using android::system::connectivity::shill::IPropertyChangedCallback; 30using std::string; 31using std::vector; 32 33namespace shill { 34 35namespace Logging { 36static auto kModuleLogScope = ScopeLogger::kBinder; 37static string ObjectID(DeviceBinderAdaptor* d) { 38 return "Device binder adaptor (id " + d->GetRpcIdentifier() + ", " + 39 d->device()->UniqueName() + ")"; 40} 41} // namespace Logging 42 43DeviceBinderAdaptor::DeviceBinderAdaptor(Device* device, const string& id) 44 : BinderAdaptor(id), device_(device) {} 45 46DeviceBinderAdaptor::~DeviceBinderAdaptor() { device_ = nullptr; } 47 48void DeviceBinderAdaptor::EmitBoolChanged(const string& name, bool /*value*/) { 49 SLOG(this, 2) << __func__ << ": " << name; 50 SendPropertyChangedSignal(name); 51} 52 53void DeviceBinderAdaptor::EmitUintChanged(const string& name, 54 uint32_t /*value*/) { 55 SLOG(this, 2) << __func__ << ": " << name; 56 SendPropertyChangedSignal(name); 57} 58 59void DeviceBinderAdaptor::EmitUint16Changed(const string& name, 60 uint16_t /*value*/) { 61 SLOG(this, 2) << __func__ << ": " << name; 62 SendPropertyChangedSignal(name); 63} 64 65void DeviceBinderAdaptor::EmitIntChanged(const string& name, int /*value*/) { 66 SLOG(this, 2) << __func__ << ": " << name; 67 SendPropertyChangedSignal(name); 68} 69 70void DeviceBinderAdaptor::EmitStringChanged(const string& name, 71 const string& /*value*/) { 72 SLOG(this, 2) << __func__ << ": " << name; 73 SendPropertyChangedSignal(name); 74} 75 76void DeviceBinderAdaptor::EmitStringmapChanged(const string& name, 77 const Stringmap& /*value*/) { 78 SLOG(this, 2) << __func__ << ": " << name; 79 SendPropertyChangedSignal(name); 80} 81 82void DeviceBinderAdaptor::EmitStringmapsChanged(const string& name, 83 const Stringmaps& /*value*/) { 84 SLOG(this, 2) << __func__ << ": " << name; 85 SendPropertyChangedSignal(name); 86} 87 88void DeviceBinderAdaptor::EmitStringsChanged(const string& name, 89 const Strings& /*value*/) { 90 SLOG(this, 2) << __func__ << ": " << name; 91 SendPropertyChangedSignal(name); 92} 93 94void DeviceBinderAdaptor::EmitKeyValueStoreChanged( 95 const string& name, const KeyValueStore& /*value*/) { 96 SLOG(this, 2) << __func__ << ": " << name; 97 SendPropertyChangedSignal(name); 98} 99 100void DeviceBinderAdaptor::EmitRpcIdentifierChanged( 101 const std::string& name, const std::string& /*value*/) { 102 SLOG(this, 2) << __func__ << ": " << name; 103 SendPropertyChangedSignal(name); 104} 105 106void DeviceBinderAdaptor::EmitRpcIdentifierArrayChanged( 107 const string& name, const vector<string>& /*value*/) { 108 SLOG(this, 2) << __func__ << ": " << name; 109 SendPropertyChangedSignal(name); 110} 111 112Status DeviceBinderAdaptor::GetInterface(String16* _aidl_return) { 113 // STUB IMPLEMENTATION. 114 // TODO(samueltan): replace this with proper implementation. 115 return Status::ok(); 116} 117 118Status DeviceBinderAdaptor::GetSelectedService(sp<IBinder>* _aidl_return) { 119 // STUB IMPLEMENTATION. 120 // TODO(samueltan): replace this with proper implementation. 121 return Status::ok(); 122} 123 124Status DeviceBinderAdaptor::RegisterPropertyChangedSignalHandler( 125 const sp<IPropertyChangedCallback>& callback) { 126 AddPropertyChangedSignalHandler(callback); 127 return Status::ok(); 128} 129 130} // namespace shill 131