SSB-8693 wifi_hal changes for google scan
authorVijaykumar G D <v.dadmode@samsung.com>
Wed, 25 Nov 2015 08:10:42 +0000 (13:40 +0530)
committerTarun Karela <t.karela@samsung.com>
Mon, 4 Jun 2018 09:40:47 +0000 (10:40 +0100)
added support for enable full scan result, review comments incorporated.

SCSC-Bug-Id: SSB-8693

Change-Id: I502d42783634600074e7d1391482dcc53fe40b5f
Signed-off-by: Vijaykumar G D <v.dadmode@samsung.com>
gscan.cpp

index 4c6eccc09f99e8bad6f215bcc61c2288c3933e8e..3da86961115e83c33b5a016122ee94b1347dd6a7 100755 (executable)
--- a/gscan.cpp
+++ b/gscan.cpp
@@ -38,13 +38,10 @@ typedef enum {
     GSCAN_ATTRIBUTE_NUM_AP_PER_SCAN,\r
     GSCAN_ATTRIBUTE_REPORT_THRESHOLD,\r
     GSCAN_ATTRIBUTE_NUM_SCANS_TO_CACHE,\r
-    GSCAN_ATTRIBUTE_DWELL_TIME,\r
-    GSCAN_ATTRIBUTE_SCAN_TYPE,\r
     GSCAN_ATTRIBUTE_BAND = GSCAN_ATTRIBUTE_BUCKETS_BAND,\r
 \r
     GSCAN_ATTRIBUTE_ENABLE_FEATURE = 20,\r
     GSCAN_ATTRIBUTE_SCAN_RESULTS_COMPLETE,              /* indicates no more results */\r
-    GSCAN_ENABLE_FULL_SCAN_RESULTS,\r
     GSCAN_ATTRIBUTE_REPORT_EVENTS,\r
 \r
     /* remaining reserved for additional attributes */\r
@@ -369,47 +366,6 @@ public:
         return createFeatureRequest(request, SLSI_NL80211_VENDOR_SUBCMD_DEL_GSCAN);\r
     }\r
 \r
-    int enableFullScanResultsIfRequired() {\r
-        /* temporary workaround till we have full support for per bucket scans */\r
-\r
-        ALOGI("enabling full scan results if needed");\r
-        int nBuckets = 0;\r
-        for (int i = 0; i < mParams->num_buckets; i++) {\r
-            if (mParams->buckets[i].report_events == 2) {\r
-                nBuckets++;\r
-            }\r
-        }\r
-\r
-        if (mGlobalFullScanBuckets == 0 && nBuckets != 0) {\r
-            \r
-           ALOGI("full scan results were requested ");\r
-           ALOGI("mGlobalFullScanBuckets = %d, nBuckets = %d", mGlobalFullScanBuckets, nBuckets);\r
-                   mLocalFullScanBuckets = nBuckets;\r
-        mGlobalFullScanBuckets += nBuckets;\r
-               registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);\r
-\r
-        } else {\r
-            ALOGI("mGlobalFullScanBuckets = %d, nBuckets = %d", mGlobalFullScanBuckets, nBuckets);\r
-\r
-        }\r
-\r
-        return WIFI_SUCCESS;       \r
-    }\r
-    int disableFullScanResultsIfRequired() {\r
-        /* temporary workaround till we have full support for per bucket scans */\r
-\r
-        if (mLocalFullScanBuckets == 0) {\r
-            return WIFI_SUCCESS;\r
-        }\r
-\r
-        mGlobalFullScanBuckets -= mLocalFullScanBuckets;\r
-        if (mGlobalFullScanBuckets == 0) {\r
-            \r
-            unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);\r
-        }\r
-\r
-        return WIFI_SUCCESS;\r
-    }\r
     int start() {\r
         ALOGD(" sending scan req to driver");\r
         WifiRequest request(familyId(), ifaceId());\r
@@ -422,12 +378,18 @@ public:
 \r
         registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE);\r
         registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN);\r
-        result = enableFullScanResultsIfRequired();\r
-               if ( result == WIFI_SUCCESS)\r
-               {\r
-                  \r
-               }\r
 \r
+        int nBuckets = 0;\r
+        for (int i = 0; i < mParams->num_buckets; i++) {\r
+            if (mParams->buckets[i].report_events == 2) {\r
+                nBuckets++;\r
+            }\r
+        }\r
+\r
+        if (nBuckets != 0) {\r
+           ALOGI("Full scan requested with nBuckets = %d", nBuckets);\r
+           registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);\r
+        }\r
         result = requestResponse(request);\r
         if (result != WIFI_SUCCESS) {\r
             ALOGE("failed to start scan; result = %d", result);\r
@@ -456,7 +418,7 @@ public:
 \r
         unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_COMPLETE_SCAN);\r
         unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_SCAN_RESULTS_AVAILABLE);\r
-        disableFullScanResultsIfRequired();\r
+        unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_FULL_SCAN_RESULTS);\r
 \r
         return WIFI_SUCCESS;\r
     }\r
@@ -474,6 +436,7 @@ public:
         nlattr *vendor_data = event.get_attribute(NL80211_ATTR_VENDOR_DATA);\r
         int len = event.get_vendor_data_len();\r
         int event_id = event.get_vendor_subcmd();\r
+        ALOGD("handleEvent, event_id = %d", event_id);\r
 \r
         if(event_id == GSCAN_EVENT_COMPLETE_SCAN) {\r
             if (vendor_data == NULL || len != 4) {\r
@@ -643,13 +606,6 @@ public:
 \r
         ALOGD("Id = %0x, subcmd = %d", id, subcmd);\r
 \r
-        /*\r
-        if (subcmd != GSCAN_SUBCMD_SCAN_RESULTS) {\r
-            ALOGE("Invalid response to GetScanResultsCommand; ignoring it");\r
-            return NL_SKIP;\r
-        }\r
-        */\r
-\r
         nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA);\r
         int len = reply.get_vendor_data_len();\r
 \r
@@ -788,6 +744,7 @@ public:
         }\r
 \r
         ALOGD("Successfully set %d APs in the hotlist", mParams.num_ap);\r
+\r
         result = createFeatureRequest(request, SLSI_NL80211_VENDOR_SUBCMD_ADD_GSCAN);\r
         if (result < 0) {\r
             return result;\r
@@ -797,13 +754,15 @@ public:
         registerVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST);\r
 \r
         result = requestResponse(request);\r
-        if (result < 0) {\r
+        if (result != WIFI_SUCCESS) {\r
+            ALOGE("failed to start scan; result = %d", result);\r
             unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_FOUND);\r
             unregisterVendorHandler(GOOGLE_OUI, GSCAN_EVENT_HOTLIST_RESULTS_LOST);\r
             return result;\r
         }\r
 \r
         ALOGD("successfully restarted the scan");\r
+\r
         return result;\r
     }\r
 \r