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