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_MANAGER_BINDER_ADAPTOR_H_ 18 #define SHILL_BINDER_MANAGER_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/BnManager.h" 27 #include "shill/adaptor_interfaces.h" 28 #include "shill/binder/binder_adaptor.h" 29 30 namespace android { 31 class String16; 32 namespace binder { 33 class Status; 34 } // namespace binder 35 namespace system { 36 namespace connectivity { 37 namespace shill { 38 class IPropertyChangedCallback; 39 } // namespace shill 40 } // namespace connectivity 41 } // namespace system 42 } // namespace android 43 44 namespace shill { 45 46 class Manager; 47 48 // Subclass of BinderAdaptor for Manager objects 49 // There is a 1:1 mapping between Manager and ManagerBinderAdaptor 50 // instances. Furthermore, the Manager owns the ManagerBinderAdaptor 51 // and manages its lifetime, so we're OK with ManagerBinderAdaptor 52 // having a bare pointer to its owner manager. 53 class ManagerBinderAdaptor 54 : public android::system::connectivity::shill::BnManager, 55 public BinderAdaptor, 56 public ManagerAdaptorInterface { 57 public: 58 ManagerBinderAdaptor(Manager* manager, const std::string& id); 59 ~ManagerBinderAdaptor() override; 60 61 // Implementation of ManagerAdaptorInterface. 62 void RegisterAsync( 63 const base::Callback<void(bool)>& completion_callback) override; GetRpcIdentifier()64 const std::string& GetRpcIdentifier() override { return id(); } 65 void EmitBoolChanged(const std::string& name, bool value) override; 66 void EmitUintChanged(const std::string& name, uint32_t value) override; 67 void EmitIntChanged(const std::string& name, int value) override; 68 void EmitStringChanged(const std::string& name, 69 const std::string& value) override; 70 void EmitStringsChanged(const std::string& name, 71 const std::vector<std::string>& value) override; 72 void EmitRpcIdentifierChanged( 73 const std::string& name, const std::string& value) override; 74 void EmitRpcIdentifierArrayChanged( 75 const std::string& name, const std::vector<std::string>& value) override; 76 77 // Implementation of BnManager. 78 android::binder::Status SetupApModeInterface(android::String16* _aidl_return); 79 android::binder::Status SetupStationModeInterface( 80 android::String16* _aidl_return); 81 android::binder::Status ClaimInterface( 82 const android::String16& claimer_name, 83 const android::String16& interface_name); 84 android::binder::Status ReleaseInterface( 85 const android::String16& claimer_name, 86 const android::String16& interface_name); 87 android::binder::Status ConfigureService( 88 const android::os::PersistableBundle& properties, 89 android::sp<android::IBinder>* _aidl_return); 90 android::binder::Status RequestScan(int32_t type); 91 android::binder::Status GetDevices( 92 ::std::vector<android::sp<android::IBinder>>* _aidl_return); 93 android::binder::Status RegisterPropertyChangedSignalHandler( 94 const android::sp< 95 android::system::connectivity::shill::IPropertyChangedCallback>& 96 callback); 97 98 private: 99 Manager* manager_; 100 101 DISALLOW_COPY_AND_ASSIGN(ManagerBinderAdaptor); 102 }; 103 104 } // namespace shill 105 106 #endif // SHILL_BINDER_MANAGER_BINDER_ADAPTOR_H_ 107