OSDN Git Service

Add ANQP query binder interface to wificond
authorNingyuan Wang <nywang@google.com>
Thu, 29 Sep 2016 18:13:45 +0000 (11:13 -0700)
committerNingyuan Wang <nywang@google.com>
Mon, 3 Oct 2016 16:44:57 +0000 (09:44 -0700)
Bug: 31813700
Test: compile

Change-Id: I6d049a7e367f59ae71f52d24df70e3b038932ee2

Android.mk
aidl/android/net/wifi/IANQPDoneCallback.aidl [new file with mode: 0644]
aidl/android/net/wifi/IClientInterface.aidl
client_interface_binder.cpp
client_interface_binder.h
client_interface_impl.cpp
client_interface_impl.h

index f520e67..bb3f864 100644 (file)
@@ -94,6 +94,7 @@ LOCAL_CPPFLAGS := $(wificond_cpp_flags)
 LOCAL_SRC_FILES := \
     ipc_constants.cpp \
     aidl/android/net/wifi/IApInterface.aidl \
+    aidl/android/net/wifi/IANQPDoneCallback.aidl \
     aidl/android/net/wifi/IClientInterface.aidl \
     aidl/android/net/wifi/IInterfaceEventCallback.aidl \
     aidl/android/net/wifi/IWificond.aidl
diff --git a/aidl/android/net/wifi/IANQPDoneCallback.aidl b/aidl/android/net/wifi/IANQPDoneCallback.aidl
new file mode 100644 (file)
index 0000000..98646bd
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+package android.net.wifi;
+
+// A callback for receiving ANQP reply events.
+interface IANQPDoneCallback {
+  // |anqp_result| is null if we timed out waiting for response from the AP
+  // with bssid |bssid|.
+  oneway void OnANQPDone(in byte[] bssid, in byte[] anqp_result);
+}
index bdc00ec..9b3e5e7 100644 (file)
@@ -16,6 +16,8 @@
 
 package android.net.wifi;
 
+import android.net.wifi.IANQPDoneCallback;
+
 // IClientInterface represents a network interface that can be used to connect
 // to access points and obtain internet connectivity.
 interface IClientInterface {
@@ -50,4 +52,8 @@ interface IClientInterface {
   @utf8InCpp
   String getInterfaceName();
 
+  // Query specified ANQP elements from an AP (specified by BSSID)
+  // and provide a callback for ANQP response.
+  // Returns true if request is sent successfully, false otherwise.
+  boolean requestANQP(in byte[] bssid, IANQPDoneCallback callback);
 }
index e61787a..dd704db 100644 (file)
@@ -23,6 +23,7 @@
 #include "wificond/client_interface_impl.h"
 
 using android::binder::Status;
+using android::net::wifi::IANQPDoneCallback;
 using std::vector;
 
 namespace android {
@@ -79,5 +80,17 @@ Status ClientInterfaceBinder::getInterfaceName(std::string* out_name) {
   return Status::ok();
 }
 
+Status ClientInterfaceBinder::requestANQP(
+    const vector<uint8_t>& bssid,
+    const sp<IANQPDoneCallback>& callback,
+    bool* out_success) {
+  if (impl_ == nullptr) {
+    *out_success = false;
+    return Status::ok();
+  }
+  *out_success = impl_->requestANQP(bssid, callback);
+  return Status::ok();
+}
+
 }  // namespace wificond
 }  // namespace android
index f429698..3b92749 100644 (file)
@@ -46,6 +46,10 @@ class ClientInterfaceBinder : public android::net::wifi::BnClientInterface {
   ::android::binder::Status getMacAddress(
       std::vector<uint8_t>* out_mac_address) override;
   ::android::binder::Status getInterfaceName(std::string* out_name) override;
+  ::android::binder::Status requestANQP(
+      const ::std::vector<uint8_t>& bssid,
+      const ::android::sp<::android::net::wifi::IANQPDoneCallback>& callback,
+      bool* out_success) override;
 
  private:
   ClientInterfaceImpl* impl_;
index 6011b79..cb8c8ee 100644 (file)
@@ -132,5 +132,12 @@ void ClientInterfaceImpl::OnScanResultsReady(
   // TODO(nywang): Send these scan results back to java framework.
 }
 
+bool ClientInterfaceImpl::requestANQP(
+      const ::std::vector<uint8_t>& bssid,
+      const ::android::sp<::android::net::wifi::IANQPDoneCallback>& callback) {
+  // TODO(nywang): query ANQP information from wpa_supplicant.
+  return true;
+}
+
 }  // namespace wificond
 }  // namespace android
index efeccfe..f4371dd 100644 (file)
@@ -59,7 +59,10 @@ class ClientInterfaceImpl {
   bool GetPacketCounters(std::vector<int32_t>* out_packet_counters);
   bool SignalPoll(std::vector<int32_t>* out_signal_poll_results);
   const std::vector<uint8_t>& GetMacAddress();
-  std::string GetInterfaceName() { return interface_name_; }
+  const std::string& GetInterfaceName() const { return interface_name_; }
+  bool requestANQP(
+      const ::std::vector<uint8_t>& bssid,
+      const ::android::sp<::android::net::wifi::IANQPDoneCallback>& callback);
 
  private:
   void OnScanResultsReady(uint32_t interface_index,