• 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 #include "shill/binder/binder_adaptor.h"
18 
19 #include <string>
20 
21 #include <utils/String16.h>
22 
23 #include "android/system/connectivity/shill/IPropertyChangedCallback.h"
24 #include "shill/logging.h"
25 
26 using android::sp;
27 using android::String16;
28 using android::system::connectivity::shill::IPropertyChangedCallback;
29 using std::string;
30 
31 namespace shill {
32 
33 namespace Logging {
34 static auto kModuleLogScope = ScopeLogger::kBinder;
ObjectID(BinderAdaptor * b)35 static string ObjectID(BinderAdaptor* b) {
36   return "(binder_adaptor)";
37 }
38 }  // namespace Logging
39 
BinderAdaptor(const string & id)40 BinderAdaptor::BinderAdaptor(const string& id) : id_(id) {
41   SLOG(this, 2) << "BinderAdaptor: " << id;
42 }
43 
AddPropertyChangedSignalHandler(const sp<IPropertyChangedCallback> & property_changed_callback)44 void BinderAdaptor::AddPropertyChangedSignalHandler(
45     const sp<IPropertyChangedCallback>& property_changed_callback) {
46   property_changed_callbacks_.push_back(property_changed_callback);
47 }
48 
SendPropertyChangedSignal(const string & name)49 void BinderAdaptor::SendPropertyChangedSignal(const string& name) {
50   for (const auto& callback : property_changed_callbacks_) {
51     callback->OnPropertyChanged(String16(name.c_str()));
52   }
53 }
54 
55 }  // namespace shill
56