wifi: Add WifiRttController object am: 5926828728
am: 6de20076a3
Change-Id: I42573cf460d4a73e07ef57afdd32f59393eb0890
This commit is contained in:
commit
495ffe9bcb
5 changed files with 131 additions and 0 deletions
|
@ -25,6 +25,7 @@ LOCAL_SRC_FILES := \
|
|||
wifi_legacy_hal.cpp \
|
||||
wifi_nan_iface.cpp \
|
||||
wifi_p2p_iface.cpp \
|
||||
wifi_rtt_controller.cpp \
|
||||
wifi_sta_iface.cpp
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
android.hardware.wifi@1.0 \
|
||||
|
|
|
@ -346,11 +346,30 @@ Return<void> WifiChip::getStaIface(const hidl_string& ifname,
|
|||
return Void();
|
||||
}
|
||||
|
||||
Return<void> WifiChip::createRttController(const sp<IWifiIface>& bound_iface,
|
||||
createRttController_cb cb) {
|
||||
if (!is_valid_) {
|
||||
cb(nullptr);
|
||||
return Void();
|
||||
}
|
||||
|
||||
sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_);
|
||||
rtt_controllers_.emplace_back(rtt);
|
||||
cb(rtt);
|
||||
return Void();
|
||||
}
|
||||
|
||||
void WifiChip::invalidateAndRemoveAllIfaces() {
|
||||
invalidateAndClear(ap_iface_);
|
||||
invalidateAndClear(nan_iface_);
|
||||
invalidateAndClear(p2p_iface_);
|
||||
invalidateAndClear(sta_iface_);
|
||||
// Since all the ifaces are invalid now, all RTT controller objects
|
||||
// using those ifaces also need to be invalidated.
|
||||
for (const auto& rtt : rtt_controllers_) {
|
||||
rtt->invalidate();
|
||||
}
|
||||
rtt_controllers_.clear();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "wifi_legacy_hal.h"
|
||||
#include "wifi_nan_iface.h"
|
||||
#include "wifi_p2p_iface.h"
|
||||
#include "wifi_rtt_controller.h"
|
||||
#include "wifi_sta_iface.h"
|
||||
|
||||
namespace android {
|
||||
|
@ -82,6 +83,8 @@ class WifiChip : public IWifiChip {
|
|||
Return<void> getStaIfaceNames(getStaIfaceNames_cb cb) override;
|
||||
Return<void> getStaIface(const hidl_string& ifname,
|
||||
getStaIface_cb cb) override;
|
||||
Return<void> createRttController(const sp<IWifiIface>& bound_iface,
|
||||
createRttController_cb cb) override;
|
||||
|
||||
private:
|
||||
void invalidateAndRemoveAllIfaces();
|
||||
|
@ -93,6 +96,7 @@ class WifiChip : public IWifiChip {
|
|||
sp<WifiNanIface> nan_iface_;
|
||||
sp<WifiP2pIface> p2p_iface_;
|
||||
sp<WifiStaIface> sta_iface_;
|
||||
std::vector<sp<WifiRttController>> rtt_controllers_;
|
||||
bool is_valid_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WifiChip);
|
||||
|
|
48
wifi/1.0/default/wifi_rtt_controller.cpp
Normal file
48
wifi/1.0/default/wifi_rtt_controller.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "wifi_rtt_controller.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "failure_reason_util.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
WifiRttController::WifiRttController(
|
||||
const sp<IWifiIface>& bound_iface,
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal)
|
||||
: bound_iface_(bound_iface), legacy_hal_(legacy_hal), is_valid_(true) {}
|
||||
|
||||
void WifiRttController::invalidate() {
|
||||
legacy_hal_.reset();
|
||||
is_valid_ = false;
|
||||
}
|
||||
|
||||
Return<void> WifiRttController::getBoundIface(getBoundIface_cb cb) {
|
||||
cb(bound_iface_);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
59
wifi/1.0/default/wifi_rtt_controller.h
Normal file
59
wifi/1.0/default/wifi_rtt_controller.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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 WIFI_RTT_CONTROLLER_H_
|
||||
#define WIFI_RTT_CONTROLLER_H_
|
||||
|
||||
#include <android-base/macros.h>
|
||||
#include <android/hardware/wifi/1.0/IWifiIface.h>
|
||||
#include <android/hardware/wifi/1.0/IWifiRttController.h>
|
||||
|
||||
#include "wifi_legacy_hal.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace wifi {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
/**
|
||||
* HIDL interface object used to control all RTT operations.
|
||||
*/
|
||||
class WifiRttController : public IWifiRttController {
|
||||
public:
|
||||
WifiRttController(const sp<IWifiIface>& bound_iface,
|
||||
const std::weak_ptr<WifiLegacyHal> legacy_hal);
|
||||
// Refer to |WifiChip::invalidate()|.
|
||||
void invalidate();
|
||||
|
||||
// HIDL methods exposed.
|
||||
Return<void> getBoundIface(getBoundIface_cb cb) override;
|
||||
|
||||
private:
|
||||
sp<IWifiIface> bound_iface_;
|
||||
std::weak_ptr<WifiLegacyHal> legacy_hal_;
|
||||
bool is_valid_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WifiRttController);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace wifi
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // WIFI_RTT_CONTROLLER_H_
|
Loading…
Reference in a new issue