blob: c6821164fdf0f62b6a91dd8ddd052203ee458d52 [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#ifndef WIFI_H_
18#define WIFI_H_
19
20#include <functional>
Roshan Pius3c4e8a32016-10-03 14:53:58 -070021
Roshan Pius3c4e8a32016-10-03 14:53:58 -070022#include <android-base/macros.h>
Roshan Pius79a99752016-10-04 13:03:58 -070023#include <android/hardware/wifi/1.0/IWifi.h>
Roshan Pius3c4e8a32016-10-03 14:53:58 -070024#include <utils/Looper.h>
25
Roshan Pius79a99752016-10-04 13:03:58 -070026#include "wifi_chip.h"
Roshan Piusaabe5752016-09-29 09:03:59 -070027#include "wifi_legacy_hal.h"
Roshan Pius3c4e8a32016-10-03 14:53:58 -070028
29namespace android {
30namespace hardware {
31namespace wifi {
Roshan Pius79a99752016-10-04 13:03:58 -070032namespace V1_0 {
33namespace implementation {
Roshan Pius3c4e8a32016-10-03 14:53:58 -070034
Roshan Piusaabe5752016-09-29 09:03:59 -070035/**
36 * Root HIDL interface object used to control the Wifi HAL.
37 */
Roshan Pius79a99752016-10-04 13:03:58 -070038class Wifi : public IWifi {
Roshan Pius3c4e8a32016-10-03 14:53:58 -070039 public:
Roshan Piusaabe5752016-09-29 09:03:59 -070040 Wifi();
Roshan Pius3c4e8a32016-10-03 14:53:58 -070041
Roshan Pius56476652016-10-26 14:43:05 -070042 bool isValid();
43
Roshan Piusaabe5752016-09-29 09:03:59 -070044 // HIDL methods exposed.
Roshan Pius3c4e8a32016-10-03 14:53:58 -070045 Return<void> registerEventCallback(
Roshan Pius56476652016-10-26 14:43:05 -070046 const sp<IWifiEventCallback>& event_callback,
47 registerEventCallback_cb hidl_status_cb) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070048 Return<bool> isStarted() override;
Roshan Pius503582e2016-10-11 08:25:30 -070049 Return<void> start(start_cb hidl_status_cb) override;
50 Return<void> stop(stop_cb hidl_status_cb) override;
51 Return<void> getChipIds(getChipIds_cb hidl_status_cb) override;
52 Return<void> getChip(ChipId chip_id, getChip_cb hidl_status_cb) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070053
54 private:
Roshan Piusaabe5752016-09-29 09:03:59 -070055 enum class RunState { STOPPED, STARTED, STOPPING };
Roshan Pius3c4e8a32016-10-03 14:53:58 -070056
Roshan Pius56476652016-10-26 14:43:05 -070057 // Corresponding worker functions for the HIDL methods.
58 WifiStatus registerEventCallbackInternal(
59 const sp<IWifiEventCallback>& event_callback);
60 WifiStatus startInternal();
61 WifiStatus stopInternal();
62 std::pair<WifiStatus, std::vector<ChipId>> getChipIdsInternal();
63 std::pair<WifiStatus, sp<IWifiChip>> getChipInternal(ChipId chip_id);
64
Roshan Piusaabe5752016-09-29 09:03:59 -070065 // Instance is created in this root level |IWifi| HIDL interface object
66 // and shared with all the child HIDL interface objects.
67 std::shared_ptr<WifiLegacyHal> legacy_hal_;
68 RunState run_state_;
Roshan Pius503582e2016-10-11 08:25:30 -070069 std::vector<sp<IWifiEventCallback>> event_callbacks_;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070070 sp<WifiChip> chip_;
71
Roshan Pius3c4e8a32016-10-03 14:53:58 -070072 DISALLOW_COPY_AND_ASSIGN(Wifi);
73};
74
Roshan Pius79a99752016-10-04 13:03:58 -070075} // namespace implementation
76} // namespace V1_0
Roshan Pius3c4e8a32016-10-03 14:53:58 -070077} // namespace wifi
78} // namespace hardware
79} // namespace android
80
81#endif // WIFI_H_