blob: e829924ffa02656ad1bf5996607657c0e7875035 [file] [log] [blame]
Roshan Pius3c4e8a32016-10-03 14:53:58 -07001/*
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 "wifi_chip.h"
18
19#include <android-base/logging.h>
20
21#include "failure_reason_util.h"
22
23namespace android {
24namespace hardware {
25namespace wifi {
Roshan Pius79a99752016-10-04 13:03:58 -070026namespace V1_0 {
27namespace implementation {
Roshan Pius3c4e8a32016-10-03 14:53:58 -070028
Roshan Piusaabe5752016-09-29 09:03:59 -070029WifiChip::WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal)
30 : legacy_hal_(legacy_hal) {}
Roshan Pius3c4e8a32016-10-03 14:53:58 -070031
Roshan Piusaabe5752016-09-29 09:03:59 -070032void WifiChip::invalidate() {
33 legacy_hal_.reset();
Roshan Pius3c4e8a32016-10-03 14:53:58 -070034 callbacks_.clear();
35}
36
37Return<void> WifiChip::registerEventCallback(
Roshan Pius79a99752016-10-04 13:03:58 -070038 const sp<IWifiChipEventCallback>& callback) {
Roshan Piusaabe5752016-09-29 09:03:59 -070039 if (!legacy_hal_.lock())
Roshan Pius79a99752016-10-04 13:03:58 -070040 return Void();
Roshan Pius3c4e8a32016-10-03 14:53:58 -070041 // TODO(b/31632518): remove the callback when the client is destroyed
42 callbacks_.insert(callback);
43 return Void();
44}
45
46Return<void> WifiChip::getAvailableModes(getAvailableModes_cb cb) {
Roshan Piusaabe5752016-09-29 09:03:59 -070047 if (!legacy_hal_.lock()) {
Roshan Pius3c4e8a32016-10-03 14:53:58 -070048 cb(hidl_vec<ChipMode>());
49 return Void();
50 } else {
51 // TODO add implementation
52 return Void();
53 }
54}
55
56Return<void> WifiChip::configureChip(uint32_t /*mode_id*/) {
Roshan Piusaabe5752016-09-29 09:03:59 -070057 if (!legacy_hal_.lock())
Roshan Pius79a99752016-10-04 13:03:58 -070058 return Void();
Roshan Pius3c4e8a32016-10-03 14:53:58 -070059 // TODO add implementation
60 return Void();
61}
62
63Return<uint32_t> WifiChip::getMode() {
Roshan Piusaabe5752016-09-29 09:03:59 -070064 if (!legacy_hal_.lock())
Roshan Pius79a99752016-10-04 13:03:58 -070065 return 0;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070066 // TODO add implementation
67 return 0;
68}
69
70Return<void> WifiChip::requestChipDebugInfo() {
Roshan Piusaabe5752016-09-29 09:03:59 -070071 if (!legacy_hal_.lock())
Roshan Pius79a99752016-10-04 13:03:58 -070072 return Void();
Roshan Pius4b26c832016-10-03 12:49:58 -070073
74 IWifiChipEventCallback::ChipDebugInfo result;
75
76 std::pair<wifi_error, std::string> ret =
77 legacy_hal_.lock()->getWlanDriverVersion();
78 if (ret.first != WIFI_SUCCESS) {
79 LOG(ERROR) << "Failed to get driver version: "
80 << LegacyErrorToString(ret.first);
81 return Void();
82 }
83 result.driverDescription = ret.second.c_str();
84
85 ret = legacy_hal_.lock()->getWlanFirmwareVersion();
86 if (ret.first != WIFI_SUCCESS) {
87 LOG(ERROR) << "Failed to get firmware version: "
88 << LegacyErrorToString(ret.first);
89 return Void();
90 }
91 result.firmwareDescription = ret.second.c_str();
92
93 for (const auto& callback : callbacks_) {
94 callback->onChipDebugInfoAvailable(result);
95 }
Roshan Pius3c4e8a32016-10-03 14:53:58 -070096 return Void();
97}
98
99Return<void> WifiChip::requestDriverDebugDump() {
100 // TODO implement
101 return Void();
102}
103
104Return<void> WifiChip::requestFirmwareDebugDump() {
105 // TODO implement
106 return Void();
107}
108
Roshan Pius79a99752016-10-04 13:03:58 -0700109} // namespace implementation
110} // namespace V1_0
Roshan Pius3c4e8a32016-10-03 14:53:58 -0700111} // namespace wifi
112} // namespace hardware
113} // namespace android