Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da15cf1b authored by Gabriel Biren's avatar Gabriel Biren Committed by Android (Google) Code Review
Browse files

Merge changes from topic "wifi-vendor-hal-conversion"

* changes:
  Remove dependencies on the HIDL Vendor HAL from the hostapd and supplicant VTS tests.
  Convert vendor HAL service to use new AIDL interface.
parents 73a19e5b fc6bd8c5
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
service vendor.wifi_hal_legacy /vendor/bin/hw/android.hardware.wifi@1.0-service
    interface android.hardware.wifi@1.0::IWifi default
    interface android.hardware.wifi@1.1::IWifi default
    interface android.hardware.wifi@1.2::IWifi default
    interface android.hardware.wifi@1.3::IWifi default
    interface android.hardware.wifi@1.4::IWifi default
    interface android.hardware.wifi@1.5::IWifi default
    interface android.hardware.wifi@1.6::IWifi default
    class hal
    capabilities NET_ADMIN NET_RAW SYS_MODULE
    user wifi
    group wifi gps
+0 −11
Original line number Diff line number Diff line
<manifest version="1.0" type="device">
    <hal format="hidl">
        <name>android.hardware.wifi</name>
        <transport>hwbinder</transport>
        <version>1.6</version>
        <interface>
            <name>IWifi</name>
            <instance>default</instance>
        </interface>
    </hal>
</manifest>
+0 −122
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HIDL_CALLBACK_UTIL_H_
#define HIDL_CALLBACK_UTIL_H_

#include <set>

#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>

namespace {
// Type of callback invoked by the death handler.
using on_death_cb_function = std::function<void(uint64_t)>;

// Private class used to keep track of death of individual
// callbacks stored in HidlCallbackHandler.
template <typename CallbackType>
class HidlDeathHandler : public android::hardware::hidl_death_recipient {
  public:
    HidlDeathHandler(const on_death_cb_function& user_cb_function)
        : cb_function_(user_cb_function) {}
    ~HidlDeathHandler() = default;

    // Death notification for callbacks.
    void serviceDied(uint64_t cookie,
                     const android::wp<android::hidl::base::V1_0::IBase>& /* who */) override {
        cb_function_(cookie);
    }

  private:
    on_death_cb_function cb_function_;

    DISALLOW_COPY_AND_ASSIGN(HidlDeathHandler);
};
}  // namespace

namespace android {
namespace hardware {
namespace wifi {
namespace V1_6 {
namespace implementation {
namespace hidl_callback_util {
template <typename CallbackType>
// Provides a class to manage callbacks for the various HIDL interfaces and
// handle the death of the process hosting each callback.
class HidlCallbackHandler {
  public:
    HidlCallbackHandler()
        : death_handler_(new HidlDeathHandler<CallbackType>(
                  std::bind(&HidlCallbackHandler::onObjectDeath, this, std::placeholders::_1))) {}
    ~HidlCallbackHandler() = default;

    bool addCallback(const sp<CallbackType>& cb) {
        // TODO(b/33818800): Can't compare proxies yet. So, use the cookie
        // (callback proxy's raw pointer) to track the death of individual
        // clients.
        uint64_t cookie = reinterpret_cast<uint64_t>(cb.get());
        for (const auto& s : cb_set_) {
            if (interfacesEqual(cb, s)) {
                LOG(ERROR) << "Duplicate death notification registration";
                return true;
            }
        }
        if (!cb->linkToDeath(death_handler_, cookie)) {
            LOG(ERROR) << "Failed to register death notification";
            return false;
        }
        cb_set_.insert(cb);
        return true;
    }

    const std::set<android::sp<CallbackType>>& getCallbacks() { return cb_set_; }

    // Death notification for callbacks.
    void onObjectDeath(uint64_t cookie) {
        CallbackType* cb = reinterpret_cast<CallbackType*>(cookie);
        const auto& iter = cb_set_.find(cb);
        if (iter == cb_set_.end()) {
            LOG(ERROR) << "Unknown callback death notification received";
            return;
        }
        cb_set_.erase(iter);
        LOG(DEBUG) << "Dead callback removed from list";
    }

    void invalidate() {
        for (const sp<CallbackType>& cb : cb_set_) {
            if (!cb->unlinkToDeath(death_handler_)) {
                LOG(ERROR) << "Failed to deregister death notification";
            }
        }
        cb_set_.clear();
    }

  private:
    std::set<sp<CallbackType>> cb_set_;
    sp<HidlDeathHandler<CallbackType>> death_handler_;

    DISALLOW_COPY_AND_ASSIGN(HidlCallbackHandler);
};

}  // namespace hidl_callback_util
}  // namespace implementation
}  // namespace V1_6
}  // namespace wifi
}  // namespace hardware
}  // namespace android
#endif  // HIDL_CALLBACK_UTIL_H_
+0 −118
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HIDL_RETURN_UTIL_H_
#define HIDL_RETURN_UTIL_H_

#include "hidl_sync_util.h"
#include "wifi_status_util.h"

namespace android {
namespace hardware {
namespace wifi {
namespace V1_6 {
namespace implementation {
namespace hidl_return_util {
using namespace android::hardware::wifi::V1_0;

/**
 * These utility functions are used to invoke a method on the provided
 * HIDL interface object.
 * These functions checks if the provided HIDL interface object is valid.
 * a) if valid, Invokes the corresponding internal implementation function of
 * the HIDL method. It then invokes the HIDL continuation callback with
 * the status and any returned values.
 * b) if invalid, invokes the HIDL continuation callback with the
 * provided error status and default values.
 */
// Use for HIDL methods which return only an instance of WifiStatus.
template <typename ObjT, typename WorkFuncT, typename... Args>
Return<void> validateAndCall(ObjT* obj, WifiStatusCode status_code_if_invalid, WorkFuncT&& work,
                             const std::function<void(const WifiStatus&)>& hidl_cb,
                             Args&&... args) {
    const auto lock = hidl_sync_util::acquireGlobalLock();
    if (obj->isValid()) {
        hidl_cb((obj->*work)(std::forward<Args>(args)...));
    } else {
        hidl_cb(createWifiStatus(status_code_if_invalid));
    }
    return Void();
}

// Use for HIDL methods which return only an instance of WifiStatus.
// This version passes the global lock acquired to the body of the method.
// Note: Only used by IWifi::stop() currently.
template <typename ObjT, typename WorkFuncT, typename... Args>
Return<void> validateAndCallWithLock(ObjT* obj, WifiStatusCode status_code_if_invalid,
                                     WorkFuncT&& work,
                                     const std::function<void(const WifiStatus&)>& hidl_cb,
                                     Args&&... args) {
    auto lock = hidl_sync_util::acquireGlobalLock();
    if (obj->isValid()) {
        hidl_cb((obj->*work)(&lock, std::forward<Args>(args)...));
    } else {
        hidl_cb(createWifiStatus(status_code_if_invalid));
    }
    return Void();
}

// Use for HIDL methods which return instance of WifiStatus and a single return
// value.
template <typename ObjT, typename WorkFuncT, typename ReturnT, typename... Args>
Return<void> validateAndCall(ObjT* obj, WifiStatusCode status_code_if_invalid, WorkFuncT&& work,
                             const std::function<void(const WifiStatus&, ReturnT)>& hidl_cb,
                             Args&&... args) {
    const auto lock = hidl_sync_util::acquireGlobalLock();
    if (obj->isValid()) {
        const auto& ret_pair = (obj->*work)(std::forward<Args>(args)...);
        const WifiStatus& status = std::get<0>(ret_pair);
        const auto& ret_value = std::get<1>(ret_pair);
        hidl_cb(status, ret_value);
    } else {
        hidl_cb(createWifiStatus(status_code_if_invalid),
                typename std::remove_reference<ReturnT>::type());
    }
    return Void();
}

// Use for HIDL methods which return instance of WifiStatus and 2 return
// values.
template <typename ObjT, typename WorkFuncT, typename ReturnT1, typename ReturnT2, typename... Args>
Return<void> validateAndCall(
        ObjT* obj, WifiStatusCode status_code_if_invalid, WorkFuncT&& work,
        const std::function<void(const WifiStatus&, ReturnT1, ReturnT2)>& hidl_cb, Args&&... args) {
    const auto lock = hidl_sync_util::acquireGlobalLock();
    if (obj->isValid()) {
        const auto& ret_tuple = (obj->*work)(std::forward<Args>(args)...);
        const WifiStatus& status = std::get<0>(ret_tuple);
        const auto& ret_value1 = std::get<1>(ret_tuple);
        const auto& ret_value2 = std::get<2>(ret_tuple);
        hidl_cb(status, ret_value1, ret_value2);
    } else {
        hidl_cb(createWifiStatus(status_code_if_invalid),
                typename std::remove_reference<ReturnT1>::type(),
                typename std::remove_reference<ReturnT2>::type());
    }
    return Void();
}

}  // namespace hidl_return_util
}  // namespace implementation
}  // namespace V1_6
}  // namespace wifi
}  // namespace hardware
}  // namespace android
#endif  // HIDL_RETURN_UTIL_H_

wifi/1.6/default/wifi_chip.h

deleted100644 → 0
+0 −317

File deleted.

Preview size limit exceeded, changes collapsed.

Loading