LOCAL_MODULE := libwificond
LOCAL_CPPFLAGS := $(wificond_cpp_flags)
LOCAL_SRC_FILES := \
+ chip.cpp \
+ client_interface.cpp \
looper_backed_event_loop.cpp \
server.cpp
LOCAL_SHARED_LIBRARIES := \
--- /dev/null
+/*
+ * 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 "chip.h"
+
+using std::vector;
+using android::sp;
+
+namespace android {
+namespace wificond {
+
+Chip::Chip()
+ : ichip_callback_(nullptr),
+ client_interface_id_(0) {
+}
+
+android::binder::Status Chip::RegisterCallback(const sp<android::net::wifi::IChipCallback>& callback) {
+ ichip_callback_ = callback;
+ return binder::Status::ok();
+}
+
+android::binder::Status Chip::UnregisterCallback(const sp<android::net::wifi::IChipCallback>& callback) {
+ ichip_callback_ = nullptr;
+ return binder::Status::ok();
+}
+
+android::binder::Status Chip::ConfigureClientInterface(int32_t* _aidl_return) {
+ // TODO: Configure client interface using HAL.
+ android::wificond::ClientInterface* interface =
+ new android::wificond::ClientInterface();
+ client_interfaces_.push_back(interface);
+ *_aidl_return = client_interface_id_++;
+
+ return binder::Status::ok();
+}
+
+android::binder::Status Chip::ConfigureApInterface(int32_t* _aidl_return) {
+ // TODO: Implement this function
+ return binder::Status::ok();
+}
+
+android::binder::Status Chip::GetClientInterfaces(vector<sp<android::IBinder>>* _aidl_return) {
+ *_aidl_return = client_interfaces_;
+ return binder::Status::ok();
+}
+
+android::binder::Status Chip::GetApInterfaces(vector<sp<android::IBinder>>* _aidl_return) {
+ // TODO: Implement this function
+ return binder::Status::ok();
+}
+
+} // namespace wificond
+} // namespace android
--- /dev/null
+/*
+ * 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 WIFICOND_CHIP_H_
+#define WIFICOND_CHIP_H_
+
+#include <vector>
+
+#include <android-base/macros.h>
+
+#include "android/net/wifi/BnChip.h"
+#include "client_interface.h"
+
+namespace android {
+namespace wificond {
+
+class Chip : public android::net::wifi::BnChip {
+ public:
+ explicit Chip();
+ ~Chip() override = default;
+ android::binder::Status RegisterCallback(
+ const android::sp<android::net::wifi::IChipCallback>& callback) override;
+ android::binder::Status UnregisterCallback(
+ const android::sp<android::net::wifi::IChipCallback>& callback) override;
+ android::binder::Status ConfigureClientInterface(
+ int32_t* _aidl_return) override;
+ android::binder::Status ConfigureApInterface(int32_t* _aidl_return) override;
+ android::binder::Status GetClientInterfaces(
+ std::vector<android::sp<android::IBinder>>* _aidl_return) override;
+ android::binder::Status GetApInterfaces(
+ std::vector<android::sp<android::IBinder>>* _aidl_return) override;
+
+ private:
+ android::sp<android::net::wifi::IChipCallback> ichip_callback_;
+ std::vector<android::sp<android::IBinder>> client_interfaces_;
+ int32_t client_interface_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(Chip);
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_CHIP_H_
--- /dev/null
+/*
+ * 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 "client_interface.h"
+
+namespace android {
+namespace wificond {
+
+} // namespace wificond
+} // namespace android
--- /dev/null
+/*
+ * 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 WIFICOND_CLIENT_INTERFACE_H_
+#define WIFICOND_CLIENT_INTERFACE_H_
+
+#include <android-base/macros.h>
+
+#include "android/net/wifi/BnClientInterface.h"
+
+namespace android {
+namespace wificond {
+
+class ClientInterface : public android::net::wifi::BnClientInterface {
+ public:
+ ClientInterface() = default;
+ ~ClientInterface() override = default;
+ // TODO: Add functions configuring an interface.
+
+ private:
+ // TODO: Add fields decribing an interface.
+
+ DISALLOW_COPY_AND_ASSIGN(ClientInterface);
+};
+
+} // namespace wificond
+} // namespace android
+
+#endif // WIFICOND_CLIENT_INTERFACE_H_
namespace android {
namespace wificond {
+Server::Server() {
+ // TODO: Get chip information from HAL.
+ android::wificond::Chip* chip = new android::wificond::Chip();
+ chips_.push_back(chip);
+}
+
android::binder::Status Server::GetChips(std::vector<sp<IBinder>>* chips) {
- // TODO: Enumerate chips and return the ones we know about.
- chips->clear();
+ *chips = chips_;
return binder::Status::ok();
}
#include <android-base/macros.h>
#include "android/net/wifi/BnWificond.h"
+#include "chip.h"
namespace android {
namespace wificond {
class Server : public android::net::wifi::BnWificond {
public:
- Server() = default;
+ Server();
~Server() override = default;
- android::binder::Status GetChips(std::vector<sp<IBinder>>* chips);
+ android::binder::Status GetChips(std::vector<sp<IBinder>>* chips) override;
private:
+ std::vector<sp<IBinder>> chips_;
+
DISALLOW_COPY_AND_ASSIGN(Server);
};
#include <utils/StrongPointer.h>
#include "android/net/wifi/IWificond.h"
+#include "android/net/wifi/IChip.h"
#include "tests/shell_utils.h"
using android::String16;
using android::base::Trim;
+using android::net::wifi::IChip;
using android::net::wifi::IWificond;
using android::wificond::tests::integration::RunShellCommand;
EXPECT_TRUE(WaitForTrue(IsRegistered, kWificondStartTimeoutSeconds));
}
+TEST(LifeCycleTest, ExposeChipAndInterfaceTest) {
+ sp<IWificond> service;
+ EXPECT_EQ(getService(String16(kWificondServiceName), &service), NO_ERROR);
+ std::vector<sp<IBinder>> chips;
+ service->GetChips(&chips);
+ EXPECT_TRUE(chips.size() == 1);
+
+ sp<IChip> chip = IChip::asInterface(chips[0]);
+ int32_t request_id;
+ chip->ConfigureClientInterface(&request_id);
+ EXPECT_EQ(request_id, 0);
+
+ std::vector<sp<IBinder>> interfaces;
+ chip->GetClientInterfaces(&interfaces);
+ EXPECT_TRUE(interfaces.size() == 1);
+}
+
+
} // namespace wificond
} // namespace android