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 SHILL_BINDER_DEVICE_BINDER_ADAPTOR_H_ 18 #define SHILL_BINDER_DEVICE_BINDER_ADAPTOR_H_ 19 20 #include <string> 21 #include <vector> 22 23 #include <base/macros.h> 24 #include <utils/StrongPointer.h> 25 26 #include "android/system/connectivity/shill/BnDevice.h" 27 28 #include "shill/adaptor_interfaces.h" 29 #include "shill/binder/binder_adaptor.h" 30 31 namespace android { 32 class String16; 33 namespace binder { 34 class Status; 35 } // namespace binder 36 namespace system { 37 namespace connectivity { 38 namespace shill { 39 class IPropertyChangedCallback; 40 } // namespace shill 41 } // namespace connectivity 42 } // namespace system 43 } // namespace android 44 45 namespace shill { 46 47 class Device; 48 49 // There is a 1:1 mapping between Device and DeviceBinderAdaptor instances. 50 // Furthermore, the Device owns the DeviceBinderAdaptor and manages its 51 // lifetime, so we're OK with DeviceBinderAdaptor having a bare pointer to its 52 // owner device. 53 class DeviceBinderAdaptor 54 : public android::system::connectivity::shill::BnDevice, 55 public BinderAdaptor, 56 public DeviceAdaptorInterface { 57 public: 58 DeviceBinderAdaptor(Device* device, const std::string& id); 59 ~DeviceBinderAdaptor() override; 60 61 // Implementation of DeviceAdaptorInterface. GetRpcIdentifier()62 const std::string& GetRpcIdentifier() override { return id(); } 63 void EmitBoolChanged(const std::string& name, bool value) override; 64 void EmitUintChanged(const std::string& name, uint32_t value) override; 65 void EmitUint16Changed(const std::string& name, uint16_t value) override; 66 void EmitIntChanged(const std::string& name, int value) override; 67 void EmitStringChanged(const std::string& name, 68 const std::string& value) override; 69 void EmitStringmapChanged(const std::string& name, 70 const Stringmap& value) override; 71 void EmitStringmapsChanged(const std::string& name, 72 const Stringmaps& value) override; 73 void EmitStringsChanged(const std::string& name, 74 const Strings& value) override; 75 void EmitKeyValueStoreChanged(const std::string& name, 76 const KeyValueStore& value) override; 77 void EmitRpcIdentifierChanged(const std::string& name, 78 const std::string& value) override; 79 void EmitRpcIdentifierArrayChanged( 80 const std::string& name, const std::vector<std::string>& value) override; 81 82 // Implementation of BnDevice. 83 android::binder::Status GetInterface( 84 android::String16* _aidl_return) override; 85 android::binder::Status GetSelectedService( 86 android::sp<IBinder>* _aidl_return) override; 87 android::binder::Status RegisterPropertyChangedSignalHandler( 88 const android::sp< 89 android::system::connectivity::shill::IPropertyChangedCallback>& 90 callback) override; 91 device()92 Device* device() const { return device_; } 93 94 private: 95 Device* device_; 96 97 DISALLOW_COPY_AND_ASSIGN(DeviceBinderAdaptor); 98 }; 99 100 } // namespace shill 101 102 #endif // SHILL_BINDER_DEVICE_BINDER_ADAPTOR_H_ 103