• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SERVICE_BINDER_ADAPTOR_H_
18 #define SHILL_BINDER_SERVICE_BINDER_ADAPTOR_H_
19 
20 #include <string>
21 
22 #include <base/macros.h>
23 #include <utils/StrongPointer.h>
24 
25 #include "android/system/connectivity/shill/BnService.h"
26 #include "shill/adaptor_interfaces.h"
27 #include "shill/binder/binder_adaptor.h"
28 
29 namespace android {
30 namespace binder {
31 class Status;
32 }  // namespace binder
33 namespace system {
34 namespace connectivity {
35 namespace shill {
36 class IPropertyChangedCallback;
37 }  // namespace shill
38 }  // namespace connectivity
39 }  // namespace system
40 }  // namespace android
41 
42 namespace shill {
43 
44 class Service;
45 
46 // Subclass of DBusAdaptor for Service objects
47 // There is a 1:1 mapping between Service and ServiceBinderAdaptor
48 // instances.  Furthermore, the Service owns the ServiceBinderAdaptor
49 // and manages its lifetime, so we're OK with ServiceBinderAdaptor
50 // having a bare pointer to its owner service.
51 class ServiceBinderAdaptor
52     : public android::system::connectivity::shill::BnService,
53       public BinderAdaptor,
54       public ServiceAdaptorInterface {
55  public:
56   ServiceBinderAdaptor(Service* service, const std::string& id);
57   ~ServiceBinderAdaptor() override;
58 
59   // Implementation of ServiceAdaptorInterface.
GetRpcIdentifier()60   const std::string& GetRpcIdentifier() override { return id(); }
61   void EmitBoolChanged(const std::string& name, bool value) override;
62   void EmitUint8Changed(const std::string& name, uint8_t value) override;
63   void EmitUint16Changed(const std::string& name, uint16_t value) override;
64   void EmitUint16sChanged(const std::string& name,
65                           const Uint16s& 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 EmitRpcIdentifierChanged(
69       const std::string& name, const std::string& value) override;
70   void EmitStringChanged(
71       const std::string& name, const std::string& value) override;
72   void EmitStringmapChanged(const std::string& name,
73                             const Stringmap& value) override;
74 
75   // Implementation of BnService.
76   android::binder::Status Connect();
77   android::binder::Status GetState(int32_t* _aidl_return);
78   android::binder::Status GetStrength(int8_t* _aidl_return);
79   android::binder::Status GetError(int32_t* _aidl_return);
80   android::binder::Status RegisterPropertyChangedSignalHandler(
81       const android::sp<
82           android::system::connectivity::shill::IPropertyChangedCallback>&
83           callback);
84 
service()85   Service* service() const { return service_; }
86 
87  private:
88   Service* service_;
89 
90   DISALLOW_COPY_AND_ASSIGN(ServiceBinderAdaptor);
91 };
92 
93 }  // namespace shill
94 
95 #endif  // SHILL_BINDER_SERVICE_BINDER_ADAPTOR_H_
96