diff --git a/wifi/application/portal_login/build-profile.json5 b/wifi/application/portal_login/build-profile.json5 index 56eda4869ca87dd936169fd0ecfcd201535b1e8b..48b4d1422bedbd4e642e2d1e2ed745eb95ab4282 100644 --- a/wifi/application/portal_login/build-profile.json5 +++ b/wifi/application/portal_login/build-profile.json5 @@ -18,9 +18,8 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": 20, - "compatibleSdkVersion": 20, - "targetSdkVersion": 20, + "compileSdkVersion": 20, + "compatibleSdkVersion": 18, "runtimeOS": "OpenHarmony" } ] @@ -39,4 +38,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/wifi/application/portal_login/entry/src/main/ets/pages/Index.ets b/wifi/application/portal_login/entry/src/main/ets/pages/Index.ets index 14f4d7f0b195c937b9e08c241bf4d21138010276..feaf0363b2008bd3c297e14999b17ee1549bb0ee 100644 --- a/wifi/application/portal_login/entry/src/main/ets/pages/Index.ets +++ b/wifi/application/portal_login/entry/src/main/ets/pages/Index.ets @@ -324,7 +324,14 @@ struct Index { .onControllerAttached(() => { try { this.harmonyUA = this.webviewController.getUserAgent(); - this.selectedUA = this.harmonyUA; + const isPhone = /Phone/i.test(this.harmonyUA); + if (isPhone) { + this.selectedUA = this.mobileUA; + } else { + this.selectedUA = this.desktopUA; + } + this.webviewController.setCustomUserAgent(this.selectedUA); + hilog.info(DOMAIN, TAG, '%{public}s', 'UA isPhone: ' + isPhone); } catch (error) { hilog.error(DOMAIN, TAG, '%{public}s', `Failed to set UA. Code:${error.code}, message:${error.message}`); } diff --git a/wifi/application/portal_login/entry/src/main/resources/be/element/string.json b/wifi/application/portal_login/entry/src/main/resources/be/element/string.json deleted file mode 100644 index cf4c561c7b5e368c9dc5ec9719a5d163afd306fe..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/be/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA Браўзера", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Адмяніць", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Адкрыць у Браўзеры", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Тэрмін дзеяння SSL-сертыфіката гэтага сайта скончыўся або сертыфікат не з’яўляецца давераным. Калі вы працягнеце, можа ўзнікнуць рызыка для бяспекі.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Працягнуць", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/bg/element/string.json b/wifi/application/portal_login/entry/src/main/resources/bg/element/string.json deleted file mode 100644 index 12bdd5d1fa52f16e22745fcf805e3fcd2c0e29d1..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/bg/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA на „Браузър“", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Отказ", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Отваряне в Браузър", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"SSL сертификатът на сайта е изтекъл или не е доверен. Възможно е да има риск за сигурността, ако продължите.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Продължаване", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/bn/element/string.json b/wifi/application/portal_login/entry/src/main/resources/bn/element/string.json deleted file mode 100644 index b22edcfb6f028e1406242268d2a625cfa77d8b9a..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/bn/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"ব্রাউজার UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"বাতিল করুন", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"ব্রাউজারে খুলুন", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"এই সাইটটির SSL শংসাপত্রের মেয়াদ শেষ হয়ে গেছে বা অনির্ভরযোগ্য। আপনি অবিরত থাকলে একটি নিরাপত্তা ঝুঁকি থাকতে পারে।", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"অবিরত রাখুন", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/cs/element/string.json b/wifi/application/portal_login/entry/src/main/resources/cs/element/string.json deleted file mode 100644 index 92632dc32f602c822f962b95b3ba5085bd28a0f7..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/cs/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Smlouva s uživatelem prohlížeče", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Zrušit", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Otevřít v prohlížeči", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Platnost SSL certifikátu stránky vypršela nebo je stránka nedůvěryhodná. Pokud budete pokračovat, může to být bezpečnostní riziko.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Pokračovat", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/da/element/string.json b/wifi/application/portal_login/entry/src/main/resources/da/element/string.json deleted file mode 100644 index bec452fc4f5f4e16c1dc8fdaa9e59eee2b826105..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/da/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Browserbrugeraftale", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Annuller", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Åbn i Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Sidens SSL-certifikat er udløbet, eller der er ikke tillid til det. Det kan udgøre en sikkerhedsrisiko, hvis du fortsætter.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Fortsæt", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/de/element/string.json b/wifi/application/portal_login/entry/src/main/resources/de/element/string.json deleted file mode 100644 index 943bb17d8ba1e68e6f04e127961605da8af498e3..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/de/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Browser-UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Abbrechen", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Im Browser öffnen", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Das SSL-Zertifikat dieser Website ist abgelaufen oder nicht vertrauenswürdig. Es können Sicherheitsrisiken entstehen, wenn Sie fortfahren.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Fortfahren", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/el/element/string.json b/wifi/application/portal_login/entry/src/main/resources/el/element/string.json deleted file mode 100644 index 1e1d1b5bcc25a63c7348843fa72c6e95aa187f46..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/el/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA Προγράμματος περιήγησης", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Ακύρωση", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Άνοιγμα σε πρόγραμμα περιήγησης", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Το πιστοποιητικό SSL αυτού του ιστοτόπου έχει λήξει ή δεν είναι αξιόπιστο. Εάν συνεχίσετε, ενδέχεται να προκύψουν κίνδυνοι ασφαλείας.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Συνέχεια", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/en_GB/element/string.json b/wifi/application/portal_login/entry/src/main/resources/en_GB/element/string.json deleted file mode 100644 index b33d54e45ab19f81a3208f82c420aec27376fc83..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/en_GB/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Browser UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Cancel", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Open in Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"This site's SSL certificate has expired or is untrusted. There may be a security risk if you continue.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Continue", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/es_US/element/string.json b/wifi/application/portal_login/entry/src/main/resources/es_US/element/string.json deleted file mode 100644 index 342470ac260fd4863b7cb646520253b76b8feb6c..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/es_US/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Agente de usuario del navegador", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Cancelar", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Abrir con Navegador", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"El certificado SSL de este sitio ha expirado o no es confiable. Es posible que haya un riesgo de seguridad si continúa.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Continuar", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/et/element/string.json b/wifi/application/portal_login/entry/src/main/resources/et/element/string.json deleted file mode 100644 index e8388f0e52e332d30705ddf0d107e14fd9d6ca68..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/et/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Brauseri kl", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Tühista", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Ava Brauseris", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Selle saidi SSL-sert on aegunud või ebausaldusväärne. Kui jätkate, võib esineda turvarisk.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Jätka", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/fa/element/string.json b/wifi/application/portal_login/entry/src/main/resources/fa/element/string.json deleted file mode 100644 index 392499a5e59ea750b5f02981aae74b4548bb3bb2..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/fa/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA مرورگر", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"لغو", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"باز کردن در مرورگر", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"گواهی SSL این سایت منقضی شده یا غیر قابل اعتماد است. در صورت ادامه، ریسک امنیتی وجود دارد.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"ادامه", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"‏HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/fi/element/string.json b/wifi/application/portal_login/entry/src/main/resources/fi/element/string.json deleted file mode 100644 index 985580ebb1cdfa945f72e86d9f4665259201127f..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/fi/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Selaimen käyttösopimus", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Peruuta", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Avaa selaimessa", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Tämän sivuston SSL-varmenne on vanhentunut tai epäluotettava. Jatkaminen saattaa sisältää turvallisuusriskin.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Jatka", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/fil/element/string.json b/wifi/application/portal_login/entry/src/main/resources/fil/element/string.json deleted file mode 100644 index f97bad3f1958e169d0cc10badfd430146d27aa6d..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/fil/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Browser UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Kanselahin", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Buksan sa Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Nag-expire o hindi pinagkakatiwalaan ang SSL certificate ng site. Maaaring magkaroon ng panganib sa seguridad kung magpatuloy ka.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Magpatuloy", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/he/element/string.json b/wifi/application/portal_login/entry/src/main/resources/he/element/string.json deleted file mode 100644 index 7ed2e3edf3641e6ab7b23dd1965ee5c452f5c183..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/he/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Browser UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"ביטול", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"פתח ב'דפדפן'", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"פג תוקף אישור ה-SSL של האתר או שהוא אינו מהימן. ייתכן סיכון אבטחה אם תמשיך.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"המשך", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/hi/element/string.json b/wifi/application/portal_login/entry/src/main/resources/hi/element/string.json deleted file mode 100644 index 1dd4e0e9221f886bd1a82a5516443c5fa3500171..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/hi/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"ब्राउज़र UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"रद्द करें", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"ब्राउज़र में खोलें", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"इस साइट के SSL प्रमाण-पत्र की समय सीमा समाप्त हो गई है या यह अविश्वसनीय है। अगर आप जारी रखते हैं, तो सुरक्षा जोखिम हो सकता है।", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"जारी रखें", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/hr/element/string.json b/wifi/application/portal_login/entry/src/main/resources/hr/element/string.json deleted file mode 100644 index aeb02551748141aa9cb2419043255137a590e12e..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/hr/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Preglednik UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Odustani", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Otvori u aplikaciji Preglednik", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Certifikat SSL mrežnog mjesta istekao je ili nije pouzdan. Ako nastavite, možete se izložiti sigurnosnom riziku.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Nastavi", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/hu/element/string.json b/wifi/application/portal_login/entry/src/main/resources/hu/element/string.json deleted file mode 100644 index 9465135668fc3b924dde3550d55bcb721f71ff4a..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/hu/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Böngésző felhasználói felület", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Mégse", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Megnyitás a Böngészőben", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"A weboldal SSL tanúsítványa lejárt vagy nem megbízható. Biztonsági kockázatot jelenthet, ha folytatja.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Folytatás", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/id/element/string.json b/wifi/application/portal_login/entry/src/main/resources/id/element/string.json deleted file mode 100644 index 95dfb2cbf28e59e34ccecc388f534500b56295ad..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/id/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Batal", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Buka di Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Sertifikat SSL situs ini telah kedaluwarsa atau tidak tepercaya. Kemungkinan ada risiko keamanan jika Anda melanjutkan.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Lanjut", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/it/element/string.json b/wifi/application/portal_login/entry/src/main/resources/it/element/string.json deleted file mode 100644 index 5697e18417feea548696ed45f227dfbaa461b020..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/it/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Browser UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Annulla", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Apri nel Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Il certificato SSL del sito è scaduto o non è affidabile. Proseguendo, potrebbero verificarsi rischi per la sicurezza.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Continua", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/ka/element/string.json b/wifi/application/portal_login/entry/src/main/resources/ka/element/string.json deleted file mode 100644 index b1fcdd81d297e0963c5e261eea4611ea9488672a..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/ka/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"ბრაუზერის UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"გაუქმება", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"ბრაუზერში გახსნა", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"ამ საიტის SSL სერტიფიკატს ვადა ამოეწურა ან სანდო არ არის. თუ გააგრძელებთ, შესაძლოა უსაფრთხოების რისკი შეიქმნას.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"გაგრძელება", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/kk/element/string.json b/wifi/application/portal_login/entry/src/main/resources/kk/element/string.json deleted file mode 100644 index 20c66af2bf5225d8b23f144277073070ddac8ede..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/kk/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Шолғыш ПК", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Бас тарту", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Шолғыш ішінде ашу", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Бұл сайттың SSL сертификатының мерзімі бітті немесе сенімсіз. Жалғастырған жағдайда қауіпсіздік қаупі болуы мүмкін.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Жалғастыру", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/km/element/string.json b/wifi/application/portal_login/entry/src/main/resources/km/element/string.json deleted file mode 100644 index c7c3ba46c04cc97f27d39a8950e63d18590a96c6..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/km/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA កម្មវិធីរុករក", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"បោះបង់", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"បើកនៅ​ក្នុង​កម្មវិធីរុករក", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"វិញ្ញាបនប័ត្រ SSL នៃគេហទំព័រនេះបាន​ផុតសុពលភាព ឬ​មិនត្រូវបានទុកចិត្តទេ។ អាចមាន​ហានិភ័យផ្នែក​សន្តិសុខ ប្រសិនបើអ្នកបន្ត។", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"បន្ត", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/lt/element/string.json b/wifi/application/portal_login/entry/src/main/resources/lt/element/string.json deleted file mode 100644 index 7e6ce094b7cf737a91c2565dbe1d8c360ceb0797..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/lt/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Naršyklės UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Atšaukti", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Atverti Naršyklėje", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Šios svetainės SSL sertifikatas baigė galioti arba yra nepatikimas. Jei tęsite, gali kilti saugumo pavojų.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Tęsti", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/lv/element/string.json b/wifi/application/portal_login/entry/src/main/resources/lv/element/string.json deleted file mode 100644 index 9f8ead2f92240885dc3fe062fc51c1275301938d..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/lv/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Pārlūka UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Atcelt", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Atvērt lietotnē Pārlūks", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Šīs vietnes SSL sertifikāta derīgums ir beidzies, vai tas ir neuzticams. Ja turpināsiet, ir iespējams drošības risks.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Turpināt", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/mk/element/string.json b/wifi/application/portal_login/entry/src/main/resources/mk/element/string.json deleted file mode 100644 index f3ac13bc89fb2776c8a58c67db574f2227fb6f38..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/mk/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA на Прелистувач", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Откажи", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Отвори во Прелистувач", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"SSL-сертификатот на оваа веб-локација е застарен или е недоверлив. Може да постои ризик за безбедноста ако продолжите.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Продолжи", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/ms/element/string.json b/wifi/application/portal_login/entry/src/main/resources/ms/element/string.json deleted file mode 100644 index b6fb8ee2dfbb788a5d0be3e539ec6d4cce1daa1c..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/ms/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Pelayar UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Batalkan", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Buka dalam Pelayar", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Sijil SSL tapak ini telah tamat tempoh atau tidak dipercayai. Mungkin wujudnya risiko keselamatan jika anda meneruskan.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Teruskan", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/my/element/string.json b/wifi/application/portal_login/entry/src/main/resources/my/element/string.json deleted file mode 100644 index 3c8484b07b53b824b9311f3ed946ed598a21ca8e..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/my/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Browser UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"ပယ်ဖျက်မည်", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Browser တွင် ဖွင့်ရန်", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"ဤဆိုက်၏ SSL ဆာတီဖီကိတ်သည် သက်တမ်းကုန်နေပါသည် သို့မဟုတ် မယုံကြည်ရပါ။ ဆက်လက်လုပ်ဆောင်ပါက လုံခြုံရေး ပြဿနာ ရှိနိုင်ပါသည်။", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"ဆက်လုပ်မည်", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/nb/element/string.json b/wifi/application/portal_login/entry/src/main/resources/nb/element/string.json deleted file mode 100644 index cfe8e40eb13cd4fa6906a5b00d38bcec1826be58..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/nb/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Nettleser UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Avbryt", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Åpne i Nettleser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Dette nettstedets SSL-sertifikat har utløpt eller er uklarert. Det kan finnes en sikkerhetsrisiko hvis du fortsetter.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Fortsett", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/nl/element/string.json b/wifi/application/portal_login/entry/src/main/resources/nl/element/string.json deleted file mode 100644 index 77993c4a38032b452e605a642feaa3041139f471..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/nl/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Gebruikersagent Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Annuleren", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"In Browser openen", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Het SSL-certificaat van deze site is verlopen of niet betrouwbaar. Er kan een veiligheidsrisico optreden als u doorgaat.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Doorgaan", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/pl/element/string.json b/wifi/application/portal_login/entry/src/main/resources/pl/element/string.json deleted file mode 100644 index 126f5df773e420878c97c08e17906f26630d8b8e..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/pl/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA Przeglądarki", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Anuluj", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Otwórz w Przeglądarce", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Certyfikat SSL tej strony stracił ważność lub jest niezaufany. Dalsze korzystanie z tej strony może zagrażać bezpieczeństwu.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Kontynuuj", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/pt/element/string.json b/wifi/application/portal_login/entry/src/main/resources/pt/element/string.json deleted file mode 100644 index 54bacc83e53565a45ec124d1e57a7be9cf05fe96..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/pt/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA do navegador", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Cancelar", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Abrir no navegador", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"O certificado SSL deste site expirou ou não é confiável. Pode haver um risco de segurança se você continuar.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Continuar", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/pt_PT/element/string.json b/wifi/application/portal_login/entry/src/main/resources/pt_PT/element/string.json deleted file mode 100644 index 17c05f06f1e0fd8a94111a87d74eb9f2b2bb5285..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/pt_PT/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Agente de utilizador do navegador", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Cancelar", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Abrir no Navegador", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"O certificado SSL da página de Internet expirou ou não é de confiança. Poderá apresentar riscos de segurança se continuar.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Continuar", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/ro/element/string.json b/wifi/application/portal_login/entry/src/main/resources/ro/element/string.json deleted file mode 100644 index 6a939d861a079da1a583bb1c056fb904b68497d8..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/ro/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Anulare", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Deschideți în Browser", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Acest certificat SSL al site-ului a expirat sau nu este de încredere. Este posibil să existe un risc de securitate dacă veți continua.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Continuare", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/sk/element/string.json b/wifi/application/portal_login/entry/src/main/resources/sk/element/string.json deleted file mode 100644 index 2d0b2cdffa7f5e3733c7c9c63abe6d1f4d4e2a90..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/sk/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA prehliadača", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Zrušiť", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Otvoriť v prehliadači", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Platnosť certifikátu SSL tejto stránky skončila alebo nie je dôveryhodná. Ak budete pokračovať, môžete byť vystavení bezpečnostnému riziku.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Pokračovať", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/sl/element/string.json b/wifi/application/portal_login/entry/src/main/resources/sl/element/string.json deleted file mode 100644 index 11e6e1519676c04d1860ec97e4d5f3dfadbd76cc..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/sl/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Brskalnik UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Prekliči", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Odpri v brskalniku", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Potrdilo SSL tega spletnega mesta je poteklo ali ni zaupanja vredno. Če boste nadaljevali, lahko pride do varnostnega tveganja.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Nadaljuj", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/sr_Latn/element/string.json b/wifi/application/portal_login/entry/src/main/resources/sr_Latn/element/string.json deleted file mode 100644 index a94c296d51635f6f96509fba3cee197287b157fa..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/sr_Latn/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"UA Pretraživača", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Otkaži", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Otvori u Pretraživaču", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"SSL certifikat ovog sajta je istekao ili je nepouzdan. Može da se javi bezbednosni rizik ako nastavite.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Nastavi", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/sv/element/string.json b/wifi/application/portal_login/entry/src/main/resources/sv/element/string.json deleted file mode 100644 index 9fee7c19d6df41d9815ec627dd51027512643ea1..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/sv/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Användaragent för Webbläsare", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Avbryt", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Öppna i Webbläsare", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Den här platsens SSL-certifikat har gått ut eller är inte betrott. Det kan finnas en säkerhetsrisk om du fortsätter.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Fortsätt", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/th/element/string.json b/wifi/application/portal_login/entry/src/main/resources/th/element/string.json deleted file mode 100644 index f0ea884998eac4634134545b2c125c70533a1d66..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/th/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"เบราว์เซอร์ UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"ยกเลิก", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"เปิดในเบราว์เซอร์", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"ใบรับรอง SSL ของไซต์นี้หมดอายุหรือไม่น่าเชื่อถือ อาจมีความเสี่ยงด้านความปลอดภัยหากคุณดำเนินการต่อ", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"ดำเนินการต่อ", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/tr/element/string.json b/wifi/application/portal_login/entry/src/main/resources/tr/element/string.json deleted file mode 100644 index c795caa928fb126da4420c14915d1f7f08478e34..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/tr/element/string.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Kullanıcı cihazı seçimi", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"İptal", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Tarayıcıda aç", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Bu sitenin SSL sertifikasının süresi sona ermiş veya sertifika güvenilir değil. Devam ederseniz güvenlik riski olabilir.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Devam", - "attr":{ - "priority":"translate" - } - }, - { - "name":"user_agent_harmony", - "value":"HarmonyOS", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/uk/element/string.json b/wifi/application/portal_login/entry/src/main/resources/uk/element/string.json deleted file mode 100644 index c2d9cec129c9f6b271bcf537dfe968689ce14724..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/uk/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Браузер-агент користувача", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Скасувати", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Відкрити в Браузері", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Сертифікат SSL цього веб-сайту ненадійний, або термін його дії сплинув. Якщо продовжити, може виникнути загроза безпеці.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Продовжити", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/uz/element/string.json b/wifi/application/portal_login/entry/src/main/resources/uz/element/string.json deleted file mode 100644 index 259b541b31a77bafeef2f33de4e31b5b1584e564..0000000000000000000000000000000000000000 --- a/wifi/application/portal_login/entry/src/main/resources/uz/element/string.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "string":[ - { - "name":"actions_menu_user_agent", - "value":"Brauzer UA", - "attr":{ - "priority":"translate" - } - }, - { - "name":"confirm_dialog_cancel", - "value":"Bekor qilish", - "attr":{ - "priority":"translate" - } - }, - { - "name":"contextmenu_open_in_browser", - "value":"Brauzerda ochish", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_normal_error_msg", - "value":"Bu saytning SSL sertifikati eskirgan yoki ishonchsiz. Agar davom etsangiz, xavfsizlik muammosi yuzaga kelishi mumkin.", - "attr":{ - "priority":"translate" - } - }, - { - "name":"ssl_error_dialog_continue_btn", - "value":"Davom etish", - "attr":{ - "priority":"translate" - } - } - ] -} \ No newline at end of file diff --git a/wifi/application/portal_login/entry/src/main/resources/zz_ZX/element/string.json b/wifi/application/portal_login/entry/src/main/resources/zz_ZX/element/string.json index 04a303f30ec278c76c91bec1003d4863384d4773..4756f52a4b0ea72084704e940ad40f05f4d7de2e 100644 --- a/wifi/application/portal_login/entry/src/main/resources/zz_ZX/element/string.json +++ b/wifi/application/portal_login/entry/src/main/resources/zz_ZX/element/string.json @@ -39,18 +39,6 @@ { "name":"confirm_dialog_cancel", "value":"[TS_1080168]_Cancel" - }, - { - "name":"EntryAbility_label", - "value":"[TS_1079372]_portal login" - }, - { - "name":"EntryAbility_desc", - "value":"[TS_1079371]_description" - }, - { - "name":"module_desc", - "value":"[TS_1079370]_module description" } ] } \ No newline at end of file diff --git a/wifi/base/utils/wifi_app_parser.cpp b/wifi/base/utils/wifi_app_parser.cpp index 1dfc59251ef5eb017c88e3753267f4fb06889ee0..e859958b08f8c1708a7b079beab65378db2605cc 100644 --- a/wifi/base/utils/wifi_app_parser.cpp +++ b/wifi/base/utils/wifi_app_parser.cpp @@ -385,6 +385,7 @@ void AppParserInner::ParseAsyncLimitSpeedDelayTime(const xmlNodePtr &innode) WIFI_LOGE("%{public}s delay time is null, will set 0.", __FUNCTION__); result_.m_delayTime = "0"; } + xmlFree(value); } AppType AppParserInner::GetAppTypeAsInt(const xmlNodePtr &innode) diff --git a/wifi/bundle.json b/wifi/bundle.json index 54f80e7eb155225b74d4b92e9110fc6d9c715ee8..7c91ff736b2015195e7796edd74dd58d85a6a7c9 100644 --- a/wifi/bundle.json +++ b/wifi/bundle.json @@ -103,6 +103,7 @@ "eventhandler", "ffrt", "hdf_core", + "hiappevent", "hicollie", "hilog", "hisysevent", diff --git a/wifi/frameworks/ets/ani/wifi_manager/BUILD.gn b/wifi/frameworks/ets/ani/wifi_manager/BUILD.gn index 5e577096aa5a70448efacd95894a68c7c3d7dd68..a3706eb745784936752971d596addd984e051658 100644 --- a/wifi/frameworks/ets/ani/wifi_manager/BUILD.gn +++ b/wifi/frameworks/ets/ani/wifi_manager/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("wifimanager_ani") { "runtime_core:ani", "runtime_core:libarkruntime", "samgr:samgr_proxy", + "ipc:ipc_single", ] part_name = "wifi" subsystem_name = "communication" diff --git a/wifi/frameworks/ets/taihe/wifiManager/BUILD.gn b/wifi/frameworks/ets/taihe/wifiManager/BUILD.gn index f969a74764cbefb066f25073f86ccfe15649afe1..2abb4efd8fa8fd3b8548de1eb58f25532314c7c5 100644 --- a/wifi/frameworks/ets/taihe/wifiManager/BUILD.gn +++ b/wifi/frameworks/ets/taihe/wifiManager/BUILD.gn @@ -67,6 +67,7 @@ taihe_shared_library("wifiManager_taihe_native") { #调用taihe_shared_library "runtime_core:ani", "runtime_core:libarkruntime", "samgr:samgr_proxy", + "ipc:ipc_single", ] } diff --git a/wifi/frameworks/js/napi/BUILD.gn b/wifi/frameworks/js/napi/BUILD.gn index 9eabdf4ed2b33be5af92eee3f4f973a56f6213fd..bbbb03e491be7455394e86c342e3b0d74a1723d0 100644 --- a/wifi/frameworks/js/napi/BUILD.gn +++ b/wifi/frameworks/js/napi/BUILD.gn @@ -64,10 +64,16 @@ ohos_shared_library("wifi") { "bundle_framework:appexecfwk_base", "c_utils:utils", "hilog:libhilog", + "init:libbegetutil", "ipc:ipc_single", "napi:ace_napi", "samgr:samgr_proxy", ] + if (wifi_hiappevent_enable) { + external_deps += [ "hiappevent:hiappevent_innerapi" ] + defines += [ "WIFI_HIAPPEVENT_ENABLE" ] + sources += [ "src/wifi_hiappevent.cpp" ] + } cflags = memory_optimization_cflags cflags_cc = memory_optimization_cflags_cc ldflags = memory_optimization_ldflags @@ -102,15 +108,20 @@ ohos_shared_library("wifiext") { "src/wifi_napi_errcode.cpp", "src/wifi_napi_utils.cpp", ] - deps = [ "$WIFI_ROOT_DIR/frameworks/native:wifi_sdk" ] + deps = [ + "$WIFI_ROOT_DIR/frameworks/native:wifi_sdk", + "$WIFI_ROOT_DIR/utils:wifi_utils", + ] external_deps = [ "ability_runtime:app_context", "bundle_framework:appexecfwk_base", "c_utils:utils", "hilog:libhilog", + "init:libbegetutil", "napi:ace_napi", "samgr:samgr_proxy", + "ipc:ipc_single", ] defines = [] @@ -121,6 +132,13 @@ ohos_shared_library("wifiext") { if (wifi_feature_with_random_mac_addr) { defines += [ "SUPPORT_RANDOM_MAC_ADDR" ] } + + if (wifi_hiappevent_enable) { + external_deps += [ "hiappevent:hiappevent_innerapi" ] + defines += [ "WIFI_HIAPPEVENT_ENABLE" ] + sources += [ "src/wifi_hiappevent.cpp" ] + } + cflags = memory_optimization_cflags cflags_cc = memory_optimization_cflags_cc ldflags = memory_optimization_ldflags @@ -177,10 +195,18 @@ ohos_shared_library("wifimanager") { "bundle_framework:appexecfwk_base", "c_utils:utils", "hilog:libhilog", + "init:libbegetutil", "ipc:ipc_single", "napi:ace_napi", "samgr:samgr_proxy", ] + + if (wifi_hiappevent_enable) { + external_deps += [ "hiappevent:hiappevent_innerapi" ] + defines += [ "WIFI_HIAPPEVENT_ENABLE" ] + sources += [ "src/wifi_hiappevent.cpp" ] + } + cflags = memory_optimization_cflags cflags_cc = memory_optimization_cflags_cc ldflags = memory_optimization_ldflags @@ -215,7 +241,10 @@ ohos_shared_library("wifimanagerext") { "src/wifi_napi_errcode.cpp", "src/wifi_napi_utils.cpp", ] - deps = [ "$WIFI_ROOT_DIR/frameworks/native:wifi_sdk" ] + deps = [ + "$WIFI_ROOT_DIR/frameworks/native:wifi_sdk", + "$WIFI_ROOT_DIR/utils:wifi_utils", + ] defines = [ "ENABLE_NAPI_WIFI_MANAGER" ] if (wifi_feature_with_ap_extension) { defines += [ "FEATURE_AP_EXTENSION" ] @@ -228,9 +257,18 @@ ohos_shared_library("wifimanagerext") { "bundle_framework:appexecfwk_base", "c_utils:utils", "hilog:libhilog", + "init:libbegetutil", "napi:ace_napi", "samgr:samgr_proxy", + "ipc:ipc_single", ] + + if (wifi_hiappevent_enable) { + external_deps += [ "hiappevent:hiappevent_innerapi" ] + defines += [ "WIFI_HIAPPEVENT_ENABLE" ] + sources += [ "src/wifi_hiappevent.cpp" ] + } + cflags = memory_optimization_cflags cflags_cc = memory_optimization_cflags_cc ldflags = memory_optimization_ldflags diff --git a/wifi/frameworks/js/napi/inc/wifi_hiappevent.h b/wifi/frameworks/js/napi/inc/wifi_hiappevent.h new file mode 100644 index 0000000000000000000000000000000000000000..ae395001cb4fc1284f8be4ce080695f214f195cb --- /dev/null +++ b/wifi/frameworks/js/napi/inc/wifi_hiappevent.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * 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 WIFI_HIAPPEVENT_H_ +#define WIFI_HIAPPEVENT_H_ + +#include + +namespace OHOS { +namespace Wifi { +class WifiHiAppEvent { +public: + static WifiHiAppEvent* GetInstance(); + void WriteEndEvent(const int64_t beginTime, const int result, const int errCode, + const std::string& apiName); + int64_t GetCurrentMillis(); +private: + WifiHiAppEvent(); + ~WifiHiAppEvent(); + void AddProcessor(); + int64_t processorId_{-1}; +}; +} // namespace Wifi +} // namespace OHOS +#endif diff --git a/wifi/frameworks/js/napi/inc/wifi_napi_device.h b/wifi/frameworks/js/napi/inc/wifi_napi_device.h index 9137521b7922b14c29f2abe69e8ee5e5a66e372e..9e8e6ed11a833f2e5e9d9a818a27713ebcb829ff 100644 --- a/wifi/frameworks/js/napi/inc/wifi_napi_device.h +++ b/wifi/frameworks/js/napi/inc/wifi_napi_device.h @@ -71,6 +71,7 @@ napi_value StartPortalCertification(napi_env env, napi_callback_info info); napi_value GetWifiProtect(napi_env env, napi_callback_info info); napi_value PutWifiProtect(napi_env env, napi_callback_info info); napi_value FactoryReset(napi_env env, napi_callback_info info); +napi_value StartWifiDetection(napi_env env, napi_callback_info info); napi_value EnableHiLinkHandshake(napi_env env, napi_callback_info info); napi_value EnableSemiWifi(napi_env env, napi_callback_info info); napi_value GetWifiDetailState(napi_env env, napi_callback_info info); diff --git a/wifi/frameworks/js/napi/inc/wifi_napi_utils.h b/wifi/frameworks/js/napi/inc/wifi_napi_utils.h index a45738317738359a1e83940b3f18068d0055b8a4..11ac2b568a9367d2a3462070faacaef26de1e6d5 100644 --- a/wifi/frameworks/js/napi/inc/wifi_napi_utils.h +++ b/wifi/frameworks/js/napi/inc/wifi_napi_utils.h @@ -45,6 +45,9 @@ private: std::string m_funcName; std::chrono::steady_clock::time_point m_startTime; bool m_isTrace = true; +#ifdef WIFI_HIAPPEVENT_ENABLE + int64_t eventStartTime_; +#endif }; #define TRACE_FUNC_CALL TraceFuncCall func(__func__) diff --git a/wifi/frameworks/js/napi/src/wifi_hiappevent.cpp b/wifi/frameworks/js/napi/src/wifi_hiappevent.cpp new file mode 100644 index 0000000000000000000000000000000000000000..453f1e5a9e1fbaaca7c1cdfa59d64ed06454be70 --- /dev/null +++ b/wifi/frameworks/js/napi/src/wifi_hiappevent.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * 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 "wifi_hiappevent.h" + +#include +#include "app_event.h" +#include "app_event_processor_mgr.h" +#include "parameters.h" + +#include "wifi_logger.h" + +namespace OHOS { +namespace Wifi { +DEFINE_WIFILOG_LABEL("WifiHiAppEvent"); +constexpr int32_t HA_CONFIG_TIMEOUT = 90; // report every 90 second +constexpr int32_t HA_CONFIG_ROW = 30; // report every 30 data points +constexpr int32_t HA_NOT_SUPPORT = -200; // processId not hap +constexpr int64_t MAX_RAMDOM_VALUE = 999999; +constexpr const char *KIT_NAME = "ConnectivityKit"; +WifiHiAppEvent::WifiHiAppEvent() +{ +} + +WifiHiAppEvent::~WifiHiAppEvent() +{ +} + +WifiHiAppEvent* WifiHiAppEvent::GetInstance() +{ + static WifiHiAppEvent data; + return &data; +} + +void WifiHiAppEvent::AddProcessor() +{ + if (processorId_ != -1) { + return; + } + OHOS::HiviewDFX::HiAppEvent::ReportConfig config; + std::string appId = system::GetParameter("persist.wifi.ha_appid", ""); + if (appId.empty()) { + WIFI_LOGE("AddProcessor appId is empty"); + return; + } + config.name = "ha_app_event"; + config.appId = appId; + config.routeInfo = "AUTO"; + config.triggerCond.timeout = HA_CONFIG_TIMEOUT; + config.triggerCond.row = HA_CONFIG_ROW; + config.eventConfigs.clear(); + { + OHOS::HiviewDFX::HiAppEvent::EventConfig event1; + event1.domain = "api_diagnostic"; + event1.name = "api_exec_end"; + event1.isRealTime = false; + config.eventConfigs.push_back(event1); + } + { + OHOS::HiviewDFX::HiAppEvent::EventConfig event2; + event2.domain = "api_diagnostic"; + event2.name = "api_called_stat"; + event2.isRealTime = true; + config.eventConfigs.push_back(event2); + } + { + OHOS::HiviewDFX::HiAppEvent::EventConfig event3; + event3.domain = "api_diagnostic"; + event3.name = "api_called_stat_cnt"; + event3.isRealTime = true; + config.eventConfigs.push_back(event3); + } + processorId_ = HiviewDFX::HiAppEvent::AppEventProcessorMgr::AddProcessor(config); +} + +void WifiHiAppEvent::WriteEndEvent(const int64_t beginTime, const int result, const int errCode, + const std::string& apiName) +{ + AddProcessor(); + if (processorId_ == HA_NOT_SUPPORT) { + return; + } + HiviewDFX::HiAppEvent::Event event("api_diagnostic", "api_exec_end", HiviewDFX::HiAppEvent::BEHAVIOR); + std::random_device randSeed; + std::mt19937 gen(randSeed()); + std::uniform_int_distribution<> dis(0, MAX_RAMDOM_VALUE); + auto transId = std::string("transId_") + std::to_string(dis(gen)); + event.AddParam("trans_id", transId); + event.AddParam("api_name", apiName); + event.AddParam("sdk_name", std::string(KIT_NAME)); + event.AddParam("begin_time", beginTime); + event.AddParam("end_time", GetCurrentMillis()); + event.AddParam("result", result); + event.AddParam("error_code", errCode); + HiviewDFX::HiAppEvent::Write(event); +} + +int64_t WifiHiAppEvent::GetCurrentMillis() +{ + return std::chrono::time_point_cast(std::chrono::system_clock::now()). + time_since_epoch().count(); +} +} // namespace Wifi +} // namespace OHOS \ No newline at end of file diff --git a/wifi/frameworks/js/napi/src/wifi_napi_device.cpp b/wifi/frameworks/js/napi/src/wifi_napi_device.cpp index 402c4c003f2ec4d67d85ed74eaae1ab6289f709d..e6976f715508fb3a1896ff2c632b3d74066ed678 100644 --- a/wifi/frameworks/js/napi/src/wifi_napi_device.cpp +++ b/wifi/frameworks/js/napi/src/wifi_napi_device.cpp @@ -431,19 +431,17 @@ napi_value ConfigStaticIp(const napi_env& env, const napi_value& object, WifiDev NAPI_CALL(env, napi_has_named_property(env, object, "family", &hasProperty)); if (!hasProperty) { WIFI_LOGE("ConfigStaticIp, Js has no property: family."); - cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.family = IPV4_ADDRESS_TYPE; return ConfigStaticIpv4(env, object, cppConfig); } napi_value family; napi_get_named_property(env, object, "family", &family); JsObjectToInt(env, object, "family", cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.family); - if (cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.family == IPV4_ADDRESS_TYPE) { - ConfigStaticIpv4(env, object, cppConfig); - } else if (cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.family == IPV6_ADDRESS_TYPE) { - ConfigStaticIpv6(env, object, cppConfig); + if (cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.family == IPV6_ADDRESS_TYPE) { + return ConfigStaticIpv6(env, object, cppConfig); + } else { + return ConfigStaticIpv4(env, object, cppConfig); } - return CreateInt32(env); } @@ -461,6 +459,7 @@ napi_value ConfigStaticIpv4(const napi_env& env, const napi_value& object, WifiD } napi_get_named_property(env, object, "staticIp", &staticIp); JsObjectToUint(env, staticIp, "ipAddress", cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.addressIpv4); + cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.family = IPV4_ADDRESS_TYPE; JsObjectToUint(env, staticIp, "gateway", cppConfig.wifiIpConfig.staticIpAddress.gateway.addressIpv4); JsObjectToInt(env, staticIp, "prefixLength", cppConfig.wifiIpConfig.staticIpAddress.ipAddress.prefixLength); NAPI_CALL(env, napi_has_named_property(env, staticIp, "dnsServers", &hasProperty)); @@ -500,6 +499,7 @@ napi_value ConfigStaticIpv6(const napi_env& env, const napi_value& object, WifiD JsObjectToString(env, staticIp, "ipAddress", NAPI_MAX_STR_LENT, ipv6Temp); cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.SetIpv6Address( IpTools::ConvertIpv6AddressToCompleted(ipv6Temp)); + cppConfig.wifiIpConfig.staticIpAddress.ipAddress.address.family = IPV6_ADDRESS_TYPE; std::string gatewayTemp; JsObjectToString(env, staticIp, "gateway", NAPI_MAX_STR_LENT, gatewayTemp); cppConfig.wifiIpConfig.staticIpAddress.gateway.SetIpv6Address( @@ -621,6 +621,7 @@ static napi_value JsObjToDeviceConfig(const napi_env& env, const napi_value& obj /* "randomMacAddr" is not supported currently */ int ipType = static_cast(AssignIpMethod::UNASSIGNED); JsObjectToInt(env, object, "ipType", ipType); + JsObjectToBool(env, object, "isAutoConnectAllowed", cppConfig.isAllowAutoConnect); WIFI_LOGI("JsObjToDeviceConfig, ipType: %{public}d, type: %{public}d.", ipType, type); if (IpTypeJs(ipType) == IpTypeJs::IP_TYPE_DHCP) { cppConfig.wifiIpConfig.assignMethod = AssignIpMethod::DHCP; @@ -1447,10 +1448,10 @@ static SecTypeJs ConvertKeyMgmtToSecType(const std::string& keyMgmt) static void IpConfigToJs(const napi_env& env, const WifiIpConfig& wifiIpConfig, napi_value& result) { - if (wifiIpConfig.staticIpAddress.ipAddress.address.family == IPV4_ADDRESS_TYPE) { - Ipv4ConfigToJs(env, wifiIpConfig, result); - } else if (wifiIpConfig.staticIpAddress.ipAddress.address.family == IPV6_ADDRESS_TYPE) { + if (wifiIpConfig.staticIpAddress.ipAddress.address.family == IPV6_ADDRESS_TYPE) { Ipv6ConfigToJs(env, wifiIpConfig, result); + } else { + Ipv4ConfigToJs(env, wifiIpConfig, result); } } @@ -1469,9 +1470,11 @@ void Ipv4ConfigToJs(const napi_env& env, const WifiIpConfig& wifiIpConfig, napi_ napi_value value; if (napi_create_int32(env, vecDns[i], &value) != napi_ok) { WIFI_LOGE("Ipv4ConfigToJs, Ip config to js create int32 error!"); + return; } if (napi_set_element(env, dnsArray, i, value) != napi_ok) { WIFI_LOGE("Ipv4ConfigToJs, Ip config to js set element error!"); + return; } } if (napi_set_named_property(env, ipCfgObj, "dnsServers", dnsArray) != napi_ok) { @@ -1485,6 +1488,7 @@ void Ipv4ConfigToJs(const napi_env& env, const WifiIpConfig& wifiIpConfig, napi_ napi_value value; if (napi_create_string_utf8(env, vecDomains[i].c_str(), NAPI_AUTO_LENGTH, &value) != napi_ok) { WIFI_LOGE("Ipv4ConfigToJs, Ip config to js create utf8 string error!"); + return; } if (napi_set_element(env, domainsArray, i, value) != napi_ok) { WIFI_LOGE("Ipv4ConfigToJs, Ip config to js set element error!"); @@ -1516,6 +1520,7 @@ void Ipv6ConfigToJs(const napi_env& env, const WifiIpConfig& wifiIpConfig, napi_ napi_value value; if (napi_create_string_utf8(env, vecDns[i].c_str(), NAPI_AUTO_LENGTH, &value) != napi_ok) { WIFI_LOGE("Ipv6ConfigToJs, Ipv6 config to js create utf8 string error!"); + return; } if (napi_set_element(env, dnsArray, i, value) != napi_ok) { WIFI_LOGE("Ipv6ConfigToJs, Ipv6 config to js set element error!"); @@ -1947,6 +1952,14 @@ NO_SANITIZE("cfi") napi_value FactoryReset(napi_env env, napi_callback_info info WIFI_NAPI_RETURN(env, ret == WIFI_OPT_SUCCESS, ret, SYSCAP_WIFI_STA); } +NO_SANITIZE("cfi") napi_value StartWifiDetection(napi_env env, napi_callback_info info) +{ + TRACE_FUNC_CALL; + WIFI_NAPI_ASSERT(env, wifiDevicePtr != nullptr, WIFI_OPT_FAILED, SYSCAP_WIFI_STA); + ErrCode ret = wifiDevicePtr->StartWifiDetection(); + WIFI_NAPI_RETURN(env, ret == WIFI_OPT_SUCCESS, ret, SYSCAP_WIFI_STA); +} + NO_SANITIZE("cfi") napi_value EnableHiLinkHandshake(napi_env env, napi_callback_info info) { TRACE_FUNC_CALL; diff --git a/wifi/frameworks/js/napi/src/wifi_napi_entry.cpp b/wifi/frameworks/js/napi/src/wifi_napi_entry.cpp index 788f686bca05d34d07f8fe0b8584f870956246ab..6ee87db518917a7b902cd8b5cc70db65c9b0edfb 100644 --- a/wifi/frameworks/js/napi/src/wifi_napi_entry.cpp +++ b/wifi/frameworks/js/napi/src/wifi_napi_entry.cpp @@ -437,6 +437,7 @@ static napi_value Init(napi_env env, napi_value exports) { DECLARE_NAPI_FUNCTION("getWifiProtect", GetWifiProtect), DECLARE_NAPI_FUNCTION("putWifiProtect", PutWifiProtect), DECLARE_NAPI_FUNCTION("factoryReset", FactoryReset), + DECLARE_NAPI_FUNCTION("startWifiDetection", StartWifiDetection), DECLARE_NAPI_FUNCTION("enableHiLinkHandshake", EnableHiLinkHandshake), }; diff --git a/wifi/frameworks/js/napi/src/wifi_napi_event.cpp b/wifi/frameworks/js/napi/src/wifi_napi_event.cpp index 4bcf6242eb0052db2b8e4fe4b8ea34db1bc81e05..9e5c917225d5a1143e7b6151b177c4073777bb5d 100644 --- a/wifi/frameworks/js/napi/src/wifi_napi_event.cpp +++ b/wifi/frameworks/js/napi/src/wifi_napi_event.cpp @@ -453,7 +453,7 @@ public: void OnP2pGcLeaveGroup(const OHOS::Wifi::GcInfo &info) override { - WIFI_LOGI("received OnP2pGcLease event"); + WIFI_LOGI("received OnP2pGcLeave event"); } void OnP2pPrivatePeersChanged(const std::string &priWfdInfo) override diff --git a/wifi/frameworks/js/napi/src/wifi_napi_utils.cpp b/wifi/frameworks/js/napi/src/wifi_napi_utils.cpp index d2d490c5a18023a3c1f836f1d3ffda4e27177977..bc62a7d11bdf919c3cb04aee9fe82faab8c8f5d6 100644 --- a/wifi/frameworks/js/napi/src/wifi_napi_utils.cpp +++ b/wifi/frameworks/js/napi/src/wifi_napi_utils.cpp @@ -19,6 +19,9 @@ #include "context.h" #include "wifi_napi_errcode.h" #include +#ifdef WIFI_HIAPPEVENT_ENABLE +#include "wifi_hiappevent.h" +#endif namespace OHOS { namespace Wifi { @@ -30,6 +33,9 @@ TraceFuncCall::TraceFuncCall(std::string funcName): m_funcName(funcName) m_startTime = std::chrono::steady_clock::now(); WIFI_LOGI("Call wifi func: %{public}s (start)", m_funcName.c_str()); } +#ifdef WIFI_HIAPPEVENT_ENABLE + eventStartTime_ = WifiHiAppEvent::GetInstance()->GetCurrentMillis(); +#endif } TraceFuncCall::~TraceFuncCall() @@ -41,6 +47,9 @@ TraceFuncCall::~TraceFuncCall() WIFI_LOGI("Call wifi func: %{public}s (end), time cost:%{public}lldus, %{public}lldms", m_funcName.c_str(), us, us / usForPerMs); } +#ifdef WIFI_HIAPPEVENT_ENABLE + WifiHiAppEvent::GetInstance()->WriteEndEvent(eventStartTime_, 1, 0, m_funcName); +#endif } napi_value UndefinedNapiValue(const napi_env& env) diff --git a/wifi/frameworks/native/interfaces/i_wifi_device.h b/wifi/frameworks/native/interfaces/i_wifi_device.h index fb1c19b464cbb4104a75df07e547d3ea844ecad1..bfa6f196ff032ad71cf321a6384b6d6bfe70cd90 100644 --- a/wifi/frameworks/native/interfaces/i_wifi_device.h +++ b/wifi/frameworks/native/interfaces/i_wifi_device.h @@ -515,6 +515,13 @@ public: */ virtual ErrCode FactoryReset() = 0; + /** + * @Description start wifi detection + * + * @return ErrCode - operation result + */ + virtual ErrCode StartWifiDetection() = 0; + /** * @Description Accept network control information from RSS. * diff --git a/wifi/frameworks/native/interfaces/i_wifi_p2p.h b/wifi/frameworks/native/interfaces/i_wifi_p2p.h index b4e1b8ca45466307103aeff52bf467218851a329..7577e6c2d001ec2bd20c05d20c168293e598a872 100644 --- a/wifi/frameworks/native/interfaces/i_wifi_p2p.h +++ b/wifi/frameworks/native/interfaces/i_wifi_p2p.h @@ -131,7 +131,7 @@ public: /** * @Description Remove a P2P client of current group. * - * @param deviceMac - client deviceMac address + * @param info - WifiP2pGroupClient object * @return ErrCode - operation result */ virtual ErrCode RemoveGroupClient(const GcInfo &info) = 0; @@ -436,7 +436,6 @@ public: * @return ErrCode - operation result */ virtual ErrCode SetP2pHighPerf(bool isEnable) = 0; - public: DECLARE_INTERFACE_DESCRIPTOR(u"ohos.wifi.IWifiP2pService"); }; diff --git a/wifi/frameworks/native/interfaces/wifi_manager_service_ipc_interface_code.h b/wifi/frameworks/native/interfaces/wifi_manager_service_ipc_interface_code.h index 16bed0786ce1ca962c420d453ecb6149e0e32a6d..d7fcc695c810ae6ee509da4598d3807d008245dc 100644 --- a/wifi/frameworks/native/interfaces/wifi_manager_service_ipc_interface_code.h +++ b/wifi/frameworks/native/interfaces/wifi_manager_service_ipc_interface_code.h @@ -92,6 +92,9 @@ enum class DevInterfaceCode { WIFI_SVR_CMD_GET_SIGNALPOLL_INFO_ARRAY = 0x1050, /* get signalpool info */ WIFI_SVR_CMD_SET_WIFI_ACCESS_LIST = 0x1051, /* set wifi block white list */ + + /* WiFi Detection */ + WIFI_SVR_CMD_START_WIFI_DETECTION = 0x1052, /* start wifi detection */ /* 以下CALL BACK类code,不需要进行权限校验 */ WIFI_CBK_CMD_STATE_CHANGE = 0x3000, /* STA state change event */ diff --git a/wifi/frameworks/native/libwifi_sdk.map b/wifi/frameworks/native/libwifi_sdk.map index df50fa66bf872cb158095559be9e34a0c305e611..b2bb0a914fb2a331c5166d39ac1e5d1f515f1f55 100644 --- a/wifi/frameworks/native/libwifi_sdk.map +++ b/wifi/frameworks/native/libwifi_sdk.map @@ -75,6 +75,7 @@ EnableSemiWifi; GetWifiDetailState; UpdateNetworkLagInfo; + StartWifiDetection; FetchWifiSignalInfoForVoWiFi; IsSupportVoWifiDetect; SetVoWifiDetectMode; diff --git a/wifi/frameworks/native/src/wifi_device_impl.cpp b/wifi/frameworks/native/src/wifi_device_impl.cpp index b99e4feca5973ad855ee07313194198b28387cb8..0d99fbeda679c5c536ff4072837415a52975805c 100644 --- a/wifi/frameworks/native/src/wifi_device_impl.cpp +++ b/wifi/frameworks/native/src/wifi_device_impl.cpp @@ -94,6 +94,7 @@ bool WifiDeviceImpl::GetWifiDeviceProxy() WIFI_LOGE("failed to get DEVICE_SERVICE again!"); return false; } + return false; } sptr deviceMgr = iface_cast(object); @@ -572,6 +573,13 @@ ErrCode WifiDeviceImpl::FactoryReset() return client_->FactoryReset(); } +ErrCode WifiDeviceImpl::StartWifiDetection() +{ + std::lock_guard lock(mutex_); + RETURN_IF_FAIL(GetWifiDeviceProxy()); + return client_->StartWifiDetection(); +} + ErrCode WifiDeviceImpl::ReceiveNetworkControlInfo(const WifiNetworkControlInfo& networkControlInfo) { std::lock_guard lock(mutex_); diff --git a/wifi/frameworks/native/src/wifi_device_impl.h b/wifi/frameworks/native/src/wifi_device_impl.h index c7dfd8666741ec38173c49919f840dcb030ebb42..4c3816a2200cc44461481ed143b8cd15c3780cf1 100644 --- a/wifi/frameworks/native/src/wifi_device_impl.h +++ b/wifi/frameworks/native/src/wifi_device_impl.h @@ -125,7 +125,7 @@ public: ErrCode AddDeviceConfig(const WifiDeviceConfig &config, int &result, bool isCandidate) override; /** - * @Description set tx power for sar. + * @Description set tx power for sar * @param power - 1001 1002 1003······ * @return ErrCode - operation result */ @@ -512,6 +512,13 @@ public: */ ErrCode FactoryReset() override; + /** + * @Description start wifi detection + * + * @return ErrCode - operation result + */ + ErrCode StartWifiDetection() override; + /** * @Description Accept network control information from RSS. * diff --git a/wifi/frameworks/native/src/wifi_device_proxy.cpp b/wifi/frameworks/native/src/wifi_device_proxy.cpp index f785e7dc8c19cc661480c677749eaed7e3266991..129e7f938ed03f195401374e387dcd2d79578ea8 100644 --- a/wifi/frameworks/native/src/wifi_device_proxy.cpp +++ b/wifi/frameworks/native/src/wifi_device_proxy.cpp @@ -371,6 +371,7 @@ void WifiDeviceProxy::WriteDeviceConfig(const WifiDeviceConfig &config, MessageP data.WriteInt32(config.wifiWapiConfig.wapiPskType); data.WriteString(config.wifiWapiConfig.wapiAsCertData); data.WriteString(config.wifiWapiConfig.wapiUserCertData); + data.WriteBool(config.isAllowAutoConnect); } ErrCode WifiDeviceProxy::RemoveCandidateConfig(const WifiDeviceConfig &config) @@ -2238,6 +2239,42 @@ ErrCode WifiDeviceProxy::FactoryReset() return WIFI_OPT_SUCCESS; } +ErrCode WifiDeviceProxy::StartWifiDetection() +{ + if (mRemoteDied) { + WIFI_LOGE("failed to `%{public}s`, remote service is died.", __func__); + return WIFI_OPT_FAILED; + } + MessageOption option; + MessageParcel data; + MessageParcel reply; + if (!data.WriteInterfaceToken(GetDescriptor())) { + WIFI_LOGE("Write interface token error, func:%{public}s", __func__); + return WIFI_OPT_FAILED; + } + + data.WriteInt32(0); + int error = Remote()->SendRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_START_WIFI_DETECTION), data, + reply, option); + if (error != ERR_NONE) { + WIFI_LOGE("StartWifiDetection(%{public}d) failed, error code is %{public}d", + static_cast(DevInterfaceCode::WIFI_SVR_CMD_START_WIFI_DETECTION), error); + return WIFI_OPT_FAILED; + } + + int exception = reply.ReadInt32(); + if (exception) { + WIFI_LOGE("Reply Read failed, exception:%{public}d", exception); + return WIFI_OPT_FAILED; + } + int ret = reply.ReadInt32(); + if (ret != WIFI_OPT_SUCCESS) { + WIFI_LOGE("Reply Read failed, ret:%{public}d", ret); + return ErrCode(ret); + } + return WIFI_OPT_SUCCESS; +} + ErrCode WifiDeviceProxy::ReceiveNetworkControlInfo(const WifiNetworkControlInfo& networkControlInfo) { if (mRemoteDied) { diff --git a/wifi/frameworks/native/src/wifi_device_proxy.h b/wifi/frameworks/native/src/wifi_device_proxy.h index 0c7cdd931df99a75d96bc4a7545931262d0c2644..111cc51263c571813d45143e28edd841a288c13d 100644 --- a/wifi/frameworks/native/src/wifi_device_proxy.h +++ b/wifi/frameworks/native/src/wifi_device_proxy.h @@ -518,6 +518,13 @@ public: */ ErrCode FactoryReset() override; + /** + * @Description start wifi detection + * + * @return ErrCode - operation result + */ + ErrCode StartWifiDetection() override; + /** * @Description Accept network control information from RSS. * diff --git a/wifi/frameworks/native/src/wifi_hotspot_impl.cpp b/wifi/frameworks/native/src/wifi_hotspot_impl.cpp index 7d2cd0c6b843f19363d90e096df047bc167f30b9..32081935e3d498d81c4df793f5f29cf40f97557d 100644 --- a/wifi/frameworks/native/src/wifi_hotspot_impl.cpp +++ b/wifi/frameworks/native/src/wifi_hotspot_impl.cpp @@ -267,14 +267,14 @@ ErrCode WifiHotspotImpl::EnableLocalOnlyHotspot(const ServiceType type) { std::lock_guard lock(mutex_); RETURN_IF_FAIL(GetWifiHotspotProxy()); - return client_->EnableLocalOnlyHotspot(); + return client_->EnableLocalOnlyHotspot(type); } ErrCode WifiHotspotImpl::DisableLocalOnlyHotspot(const ServiceType type) { std::lock_guard lock(mutex_); RETURN_IF_FAIL(GetWifiHotspotProxy()); - return client_->DisableLocalOnlyHotspot(); + return client_->DisableLocalOnlyHotspot(type); } ErrCode WifiHotspotImpl::GetHotspotMode(HotspotMode &mode) diff --git a/wifi/frameworks/native/src/wifi_p2p_proxy.cpp b/wifi/frameworks/native/src/wifi_p2p_proxy.cpp index 447968bec4c207055fcd6e99ac8e06a47e810fb0..c338c9dfd58db0bb33ea9a935e2aecf7139ba8ca 100644 --- a/wifi/frameworks/native/src/wifi_p2p_proxy.cpp +++ b/wifi/frameworks/native/src/wifi_p2p_proxy.cpp @@ -1930,6 +1930,5 @@ ErrCode WifiP2pProxy::SetP2pHighPerf(bool isEnable) return WIFI_OPT_SUCCESS; } - } // namespace Wifi } // namespace OHOS diff --git a/wifi/interfaces/inner_api/wifi_device.h b/wifi/interfaces/inner_api/wifi_device.h index 28e097c3f58307a2639d4576fa0ea5da96ea2f02..7d072c47c153abda017656ca725f876bd72bb055 100644 --- a/wifi/interfaces/inner_api/wifi_device.h +++ b/wifi/interfaces/inner_api/wifi_device.h @@ -485,6 +485,13 @@ public: */ virtual ErrCode FactoryReset() = 0; + /** + * @Description strat wifi detection + * + * @return ErrCode - operation result + */ + virtual ErrCode StartWifiDetection() = 0; + /** * @Description limit speed * diff --git a/wifi/interfaces/inner_api/wifi_msg.h b/wifi/interfaces/inner_api/wifi_msg.h index 6c005c50177cd9a6fad130861ff289a08fd70e75..a5e2e9bd763fc9aa99d309cd004ff3014be18731 100644 --- a/wifi/interfaces/inner_api/wifi_msg.h +++ b/wifi/interfaces/inner_api/wifi_msg.h @@ -933,7 +933,6 @@ enum class WifiProtectType { /* WifiProtectMode */ enum class WifiProtectMode { - WIFI_PROTECT_DEFAULT = -1, WIFI_PROTECT_FULL = 0, WIFI_PROTECT_SCAN_ONLY = 1, WIFI_PROTECT_FULL_HIGH_PERF = 2, @@ -1074,14 +1073,11 @@ enum class WifiSelfcureType { TCP_RX_ABNORMAL, ROAMING_ABNORMAL, GATEWAY_ABNORMAL, - RAND_MAC_REASSOC_SELFCURE, - MULTI_GATEWAY_SELFCURE, DNS_SELFCURE_SUCC, STATIC_IP_SELFCURE_SUCC, REASSOC_SELFCURE_SUCC, RESET_SELFCURE_SUCC, - RAND_MAC_REASSOC_SELFCURE_SUCC, - MULTI_GATEWAY_SELFCURE_SUCC, + REDHCP_SELFCURE_SUCC, }; enum class Wifi3VapConflictType { diff --git a/wifi/interfaces/inner_api/wifi_p2p_msg.h b/wifi/interfaces/inner_api/wifi_p2p_msg.h index 85b577ec4403b6d045d75efb895ce79570bba803..ea1b3bdffaee16097dc8236291bb14df4ee6b033 100644 --- a/wifi/interfaces/inner_api/wifi_p2p_msg.h +++ b/wifi/interfaces/inner_api/wifi_p2p_msg.h @@ -228,10 +228,10 @@ public: bool WpsPbcSupported() const; bool WpsDisplaySupported() const; bool WpKeypadSupported() const; - void SetGroupAddress(const std::string &groupAddress); - const std::string &GetGroupAddress() const; void SetChrErrCode(P2pChrEvent errCode); P2pChrEvent GetChrErrCode() const; + void SetGroupAddress(const std::string &groupAddress); + const std::string &GetGroupAddress() const; private: std::string deviceName; /* the value range is 0 to 32 characters. */ diff --git a/wifi/interfaces/kits/c/wifi_hotspot.h b/wifi/interfaces/kits/c/wifi_hotspot.h index 1e2c46c1b426688352d14a0137737f4042d789ed..b07a8b8450ad7bc8c35db206776bfe3ff7956c74 100644 --- a/wifi/interfaces/kits/c/wifi_hotspot.h +++ b/wifi/interfaces/kits/c/wifi_hotspot.h @@ -168,7 +168,6 @@ WifiErrorCode GetApIfaceName(char *ifaceName, int nameLen); /** * @Description Enable local only Hotspot * - * @param type - service type * @return ErrCode - operation result */ WifiErrorCode EnableLocalOnlyHotspot(void); @@ -176,7 +175,6 @@ WifiErrorCode EnableLocalOnlyHotspot(void); /** * @Description Disable local only Hotspot * - * @param type - service type * @return ErrCode - operation result */ WifiErrorCode DisableLocalOnlyHotspot(void); @@ -184,7 +182,7 @@ WifiErrorCode DisableLocalOnlyHotspot(void); /** * @Description Get local only Hotspot mode * - * @param mode - hotspot mode + * @param hotspotMode - hotspot mode * @return ErrCode - operation result */ WifiErrorCode GetHotspotMode(int *hotspotMode); diff --git a/wifi/relation_services/BUILD.gn b/wifi/relation_services/BUILD.gn index be417f4836e39d2d595cd1efaea19872f3909dda..2c055ee6a2e9f8196f78970e33dd45eaa57ebff9 100644 --- a/wifi/relation_services/BUILD.gn +++ b/wifi/relation_services/BUILD.gn @@ -111,4 +111,4 @@ if (defined(ohos_lite)) { group("relation_services") { deps = [ ":wifi_hal_service" ] -} +} \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn index dba359ce7156671ef2fdcbaac309118c962c2c53..84a9ffe2a13da6420cc65efb98f71bba796c9ac5 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/BUILD.gn @@ -429,6 +429,7 @@ if (defined(ohos_lite)) { "hilog:libhilog", "huks:libhukssdk", "ipc:ipc_single", + "libxml2:libxml2", "safwk:system_ability_fwk", "samgr:samgr_proxy", "window_manager:libdm_lite", diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/libwifi_manager.map b/wifi/services/wifi_standard/wifi_framework/wifi_manage/libwifi_manager.map index 9cda632a152af13733a2549d3ce30b33a169cebf..a46dc19ebfdc331c3f2a8ee568ca892dbb3d2965 100755 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/libwifi_manager.map +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/libwifi_manager.map @@ -347,7 +347,6 @@ "OHOS::Wifi::WifiAppStateAware::IsForegroundApp(std::__h::basic_string, std::__h::allocator> const&)"; "OHOS::Wifi::WifiChannelHelper::GetInstance()"; "OHOS::Wifi::WifiChannelHelper::GetValidBands(std::__h::vector>&)"; - "OHOS::Wifi::WifiChannelHelper::SetValidChannels(std::__h::map>, std::__h::less, std::__h::allocator>>>> const&)"; "OHOS::Wifi::WifiChannelHelper::GetValidChannels(std::__h::map>, std::__h::less, std::__h::allocator>>>>&)"; "OHOS::Wifi::WifiCountryCodeManager::GetInstance()"; "OHOS::Wifi::WifiCountryCodeManager::Init()"; @@ -459,7 +458,6 @@ "OHOS::Wifi::WifiTogglerManager::StartSemiWifiToggledTimer()"; "OHOS::Wifi::WifiTogglerManager::IsSatelliteStateStart()"; "OHOS::Wifi::WifiTogglerManager::SatelliteToggled(int)"; - "OHOS::Wifi::WifiChannelHelper::UpdateValidChannels(std::__h::basic_string, std::__h::allocator>, int)"; "OHOS::Wifi::WifiP2pManager::HasP2pActivatedBefore()"; "OHOS::Wifi::WifiSettings::GetPackageInfoByName(std::__h::basic_string, std::__h::allocator>, std::__h::vector>&)"; "OHOS::Wifi::WifiSecurityDetect::GetInstance()"; @@ -467,6 +465,12 @@ "OHOS::Wifi::WifiSecurityDetect::SecurityDetectThread_"; "OHOS::Wifi::WifiSecurityDetect::SettingDataOnOff()"; "OHOS::Wifi::WifiSecurityDetect::SecurityDetect(OHOS::Wifi::WifiDeviceConfig const&, int)"; + "OHOS::Wifi::WifiChannelHelper::GetAvailableScanFreqs(OHOS::Wifi::ScanBandType, std::__h::vector>&)"; + "OHOS::Wifi::WifiChannelHelper::UpdateValidFreqs()"; + "OHOS::Wifi::ApConfigUse::GetInstance()"; + "OHOS::Wifi::ApConfigUse::GetApVaildBands(std::__h::vector>&) const"; + "OHOS::Wifi::ApConfigUse::GetApVaildChannel(OHOS::Wifi::BandType, std::__h::vector>&) const"; + "OHOS::Wifi::ApConfigUse::UpdateApChannelConfig(OHOS::Wifi::HotspotConfig&) const"; }; local: *; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/BUILD.gn index a99f3a976b3d3b1613568da2b418a02cd5b75aa5..cf56bed77e11718ed9e13eff4e982b9c451ee418 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/BUILD.gn @@ -79,6 +79,7 @@ if (defined(ohos_lite)) { "bounds_checking_function:libsec_shared", "init:libbegetutil", "samgr:samgr_proxy", + "ipc:ipc_single", ] configs -= [ "//build/lite/config:language_cpp" ] @@ -139,6 +140,7 @@ if (defined(ohos_lite)) { "hilog:libhilog", "init:libbegetutil", "samgr:samgr_proxy", + "ipc:ipc_single", ] part_name = "wifi" subsystem_name = "communication" diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/network_selection_manager.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/network_selection_manager.cpp index 8e7a0bccfc27ae007e783b73948070c5988f6e96..cd9a74c1a506ae86f6af8df1fbe15976d503945b 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/network_selection_manager.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/network_selection_manager.cpp @@ -238,8 +238,8 @@ std::string NetworkSelectionManager::GetFilteredReasonForChr( continue; } std::map>> filtedReason; - filtedReason = networkCandidates.at(i).filtedReason; + NetworkSelection::FiltedReasonComparator, std::allocator>> filtedReason + = networkCandidates.at(i).filtedReason; if (filtedReason.size() == 0) { continue; } @@ -262,8 +262,7 @@ std::string NetworkSelectionManager::GetFilteredReasonForChr( std::string NetworkSelectionManager::GetSelectedInfoForChr(NetworkSelection::NetworkCandidate *networkCandidate) { std::string selectedInfo; - WifiDeviceConfig selectedConfig; - selectedConfig = networkCandidate->wifiDeviceConfig; + WifiDeviceConfig selectedConfig = networkCandidate->wifiDeviceConfig; selectedInfo += std::to_string(selectedConfig.networkId); selectedInfo += "_"; selectedInfo += SsidAnonymize(selectedConfig.ssid); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/wifi_filter_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/wifi_filter_impl.cpp index 189742814081a547904a128d50a754ff924827f0..91f600ed07d0819664b6c2dd2fb245be12d2db35 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/wifi_filter_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/network_select/wifi_filter_impl.cpp @@ -288,7 +288,7 @@ bool PoorPortalWifiFilter::Filter(NetworkCandidate &networkCandidate) if (networkCandidate.wifiDeviceConfig.isPortal && networkCandidate.wifiDeviceConfig.noInternetAccess && !NetworkStatusHistoryManager::IsAllowRecoveryByHistory( - networkCandidate.wifiDeviceConfig.networkStatusHistory)) { + networkCandidate.wifiDeviceConfig.networkStatusHistory) && !WifiConfigCenter::GetInstance().IsWlanPage()) { networkCandidate.filtedReason[filterName].insert({FiltedReason::PORTAL_NETWORK, FiltedReason::NO_INTERNET, FiltedReason::UNRECOVERABLE_NETWORK}); return false; @@ -331,7 +331,7 @@ bool PortalWifiFilter::Filter(NetworkCandidate &networkCandidate) if (networkCandidate.wifiDeviceConfig.isPortal && networkCandidate.wifiDeviceConfig.noInternetAccess && !NetworkStatusHistoryManager::IsAllowRecoveryByHistory( - networkCandidate.wifiDeviceConfig.networkStatusHistory)) { + networkCandidate.wifiDeviceConfig.networkStatusHistory) && !WifiConfigCenter::GetInstance().IsWlanPage()) { networkCandidate.filtedReason[filterName].insert({FiltedReason::PORTAL_NETWORK, FiltedReason::NO_INTERNET, FiltedReason::UNRECOVERABLE_NETWORK}); return false; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn index 1269ac211bfb4fc74bd0d471089134038c41334c..a6bc3a0a2c29ed2fdc80193b31855492363796f0 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn @@ -28,7 +28,6 @@ ohos_shared_library("wifi_ap_service") { } install_enable = true sources = [ - "ap_config_use.cpp", "ap_idle_state.cpp", "ap_interface.cpp", "ap_monitor.cpp", diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_define.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_define.h index 5cdefb9445a870a89f9db49d95317cae1bb995b2..516833941ee5030cd2ad3c1e90b5baf6b70f9c2c 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_define.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_define.h @@ -54,6 +54,7 @@ enum class ApStatemachineEvent { CMD_UPDATE_COUNTRY_CODE, /* update wifi conuntry code */ CMD_HOTSPOT_CHANNEL_CHANGED, /* hotspot channel changed */ CMD_ASSOCIATED_STATIONS_CHANGED, /* associated stations changed */ + CMD_START_HOTSPOT_TIMEOUT, /* start timeout */ /* (asynchronous result) */ }; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.cpp index e1db7668708f86867eb52848ff01c52b0d867e18..3e46100fb96a15716b783de6d0686b8c4d2b4db3 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.cpp @@ -19,13 +19,12 @@ namespace OHOS { namespace Wifi { ApInterface::ApInterface(int id) : m_ApRootState(id), - m_ApStartedState(m_ApStateMachine, m_ApConfigUse, m_ApMonitor, id), + m_ApStartedState(m_ApStateMachine, m_ApMonitor, id), m_ApIdleState(m_ApStateMachine, id), m_ApMonitor(id), m_ApStateMachine(m_ApStationsManager, m_ApRootState, m_ApIdleState, m_ApStartedState, m_ApMonitor, id), m_ApService(m_ApStateMachine, m_ApStartedState, id), - m_ApStationsManager(id), - m_ApConfigUse(id) + m_ApStationsManager(id) {} ApInterface::~ApInterface() @@ -85,16 +84,6 @@ ErrCode ApInterface::GetStationList(std::vector &result) return m_ApService.GetStationList(result); } -ErrCode ApInterface::GetValidBands(std::vector &bands) -{ - return m_ApService.GetValidBands(bands); -} - -ErrCode ApInterface::GetValidChannels(BandType band, std::vector &validChannel) -{ - return m_ApService.GetValidChannels(band, validChannel); -} - ErrCode ApInterface::RegisterApServiceCallbacks(const IApServiceCallbacks &callbacks) { return m_ApService.RegisterApServiceCallbacks(callbacks); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.h index 1453711a9101ef0ae239b68071c813aebd5a7d70..bd0c6cce703ea16a9bf2b72d3cab29aedf66fe0a 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.h @@ -103,23 +103,6 @@ public: */ virtual ErrCode RegisterApServiceCallbacks(const IApServiceCallbacks &callbacks) override; - /** - * @Description Get valid bands. - * - * @param bands - return valid bands - * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE - */ - virtual ErrCode GetValidBands(std::vector &bands) override; - - /** - * @Description Get valid channels. - * - * @param band - input band - * @param validchannel - band's valid channel - * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE - */ - virtual ErrCode GetValidChannels(BandType band, std::vector &validChannel) override; - /** * @Description Get supported power model list * @@ -184,7 +167,6 @@ private: ApService m_ApService; ApStationsManager m_ApStationsManager; - ApConfigUse m_ApConfigUse; }; } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.cpp index ea7eb22d86528b1ab808d6b9fa62fc7bd657adbd..e36566117ab59dd8b6a40288ab47ffc6e926a18a 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.cpp @@ -199,94 +199,6 @@ ErrCode ApService::GetStationList(std::vector &result) const return ErrCode::WIFI_OPT_SUCCESS; } -ErrCode ApService::GetValidBands(std::vector &bands) -{ - WIFI_LOGI("Instance %{public}d %{public}s", m_id, __func__); - std::vector allowed5GFreq; - std::vector allowed2GFreq; - if (WifiChannelHelper::GetInstance().GetValidBands(bands) != 0) { - WIFI_LOGE("%{public}s, GetValidBands failed!", __func__); - return ErrCode::WIFI_OPT_FAILED; - } - if (bands.size() > 0) { - return ErrCode::WIFI_OPT_SUCCESS; - } - - /* Get freqs from hal */ - if (WifiApHalInterface::GetInstance().GetFrequenciesByBand( - WifiConfigCenter::GetInstance().GetApIfaceName(), static_cast(BandType::BAND_2GHZ), allowed2GFreq)) { - WIFI_LOGW("%{public}s, fail to get 2.4G channel", __func__); - } - if (WifiApHalInterface::GetInstance().GetFrequenciesByBand( - WifiConfigCenter::GetInstance().GetApIfaceName(), static_cast(BandType::BAND_5GHZ), allowed5GFreq)) { - WIFI_LOGW("%{public}s, fail to get 5G channel", __func__); - } - if (allowed2GFreq.size() > 0) { - bands.push_back(BandType::BAND_2GHZ); - } - if (allowed5GFreq.size() > 0) { - bands.push_back(BandType::BAND_5GHZ); - } - if (bands.size() == 0) { - WIFI_LOGW("%{public}s, GetValidBands failed!", __func__); - return ErrCode::WIFI_OPT_FAILED; - } - return ErrCode::WIFI_OPT_SUCCESS; -} - -ErrCode ApService::GetValidChannels(BandType band, std::vector &validChannel) -{ - WIFI_LOGI("Instance %{public}d %{public}s", m_id, __func__); - ChannelsTable channelsInfo; - if (WifiChannelHelper::GetInstance().GetValidChannels(channelsInfo) != 0) { - WIFI_LOGE("Failed to obtain channels from the WifiSettings."); - return ErrCode::WIFI_OPT_FAILED; - } - - if (channelsInfo.size() > 0) { - auto it = channelsInfo.find(band); - if (it != channelsInfo.end()) { - validChannel = channelsInfo[band]; - WIFI_LOGI("%{public}s, get valid channel size:%{public}d, band:%{public}d from WifiSettings.", - __func__, (int)validChannel.size(), band); - return ErrCode::WIFI_OPT_SUCCESS; - } - } - - /* get freqs from hal service */ - std::vector allowed5GFreq, allowed2GFreq; - std::vector allowed5GChan, allowed2GChan; - if (WifiApHalInterface::GetInstance().GetFrequenciesByBand( - WifiConfigCenter::GetInstance().GetApIfaceName(), static_cast(BandType::BAND_2GHZ), allowed2GFreq)) { - WIFI_LOGW("%{public}s, fail to get 2.4G channel", __func__); - } - if (WifiApHalInterface::GetInstance().GetFrequenciesByBand( - WifiConfigCenter::GetInstance().GetApIfaceName(), static_cast(BandType::BAND_5GHZ), allowed5GFreq)) { - WIFI_LOGW("%{public}s, fail to get 5G channel", __func__); - } - if (allowed2GFreq.size() == 0) { - WifiSettings::GetInstance().SetDefaultFrequenciesByCountryBand(BandType::BAND_2GHZ, allowed2GFreq); - } - TransformFrequencyIntoChannel(allowed2GFreq, allowed2GChan); - TransformFrequencyIntoChannel(allowed5GFreq, allowed5GChan); - - ChannelsTable ChanTbs; - ChanTbs[BandType::BAND_2GHZ] = allowed2GChan; - ChanTbs[BandType::BAND_5GHZ] = allowed5GChan; - if (WifiChannelHelper::GetInstance().SetValidChannels(ChanTbs)) { - WIFI_LOGE("%{public}s, fail to SetValidChannels", __func__); - } - if (band == BandType::BAND_2GHZ || band == BandType::BAND_5GHZ) { - validChannel = ChanTbs[band]; - } else { - WIFI_LOGE("%{public}s, invalid band: %{public}d", __func__, band); - return ErrCode::WIFI_OPT_INVALID_PARAM; - } - WIFI_LOGI("%{public}s, get valid channel size:%{public}d, band:%{public}d from hal service.", - __func__, (int)validChannel.size(), band); - return ErrCode::WIFI_OPT_SUCCESS; -} - ErrCode ApService::RegisterApServiceCallbacks(const IApServiceCallbacks &callbacks) { WIFI_LOGI("%{public}s, Instance %{public}d ", __func__, m_id); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.h index 2acb02caa681ce1c76d0d7fc66405289d8288c86..8baac2ff7185d8dff53cda787d9ef8bcd09f26bb 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service.h @@ -105,23 +105,6 @@ public: */ ErrCode GetStationList(std::vector &result) const; - /** - * @Description Get valid bands. - * - * @param bands - return valid bands - * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE - */ - ErrCode GetValidBands(std::vector &bands); - - /** - * @Description Get valid channels. - * - * @param band - input band - * @param validchannel - band's valid channel - * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE - */ - ErrCode GetValidChannels(BandType band, std::vector &validChannel); - /** * @Description Sets the callback function for the state machine. * @@ -157,7 +140,7 @@ public: /** * @Description get hotspot mode * - * @param model - the model to be set + * @param mode - the mode to be get * @return ErrCode - operation result */ ErrCode GetHotspotMode(HotspotMode &mode); @@ -165,7 +148,7 @@ public: /** * @Description set hotspot mode * - * @param model - the model to be set + * @param mode - the mode to be set * @return ErrCode - operation result */ ErrCode SetHotspotMode(const HotspotMode &mode); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp index 8969b0078721798f29374f63b6fdab4733a711e3..f5e94cbd366c602bb045ffefb1741adbfd15a08e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.cpp @@ -48,11 +48,11 @@ DEFINE_WIFILOG_HOTSPOT_LABEL("WifiApStartedState"); namespace OHOS { namespace Wifi { const int STA_JOIN_HANDLE_DELAY = 5 * 1000; -ApStartedState::ApStartedState(ApStateMachine &apStateMachine, ApConfigUse &apConfigUse, ApMonitor &apMonitor, int id) +const int START_HOTSPOT_TIMEOUT = 3 * 1000; +ApStartedState::ApStartedState(ApStateMachine &apStateMachine, ApMonitor &apMonitor, int id) : State("ApStartedState"), m_hotspotConfig(HotspotConfig()), m_ApStateMachine(apStateMachine), - m_ApConfigUse(apConfigUse), m_ApMonitor(apMonitor), m_id(id) { @@ -65,11 +65,14 @@ ApStartedState::~ApStartedState() void ApStartedState::GoInState() { WIFI_LOGI("Instance %{public}d %{public}s GoInState.", m_id, GetStateName().c_str()); + m_ApStateMachine.StartTimer(static_cast(ApStatemachineEvent::CMD_START_HOTSPOT_TIMEOUT), + START_HOTSPOT_TIMEOUT); } void ApStartedState::GoOutState() { WIFI_LOGI("Instance %{public}d %{public}s", m_id, __func__); + m_ApStateMachine.StopTimer(static_cast(ApStatemachineEvent::CMD_START_HOTSPOT_TIMEOUT)); m_ApStateMachine.OnApStateChange(ApState::AP_STATE_CLOSING); DisableInterfaceNat(); m_ApStateMachine.StopDhcpServer(); @@ -90,8 +93,8 @@ void ApStartedState::GoOutState() void ApStartedState::Init() { - mProcessFunMap.insert( - std::make_pair(ApStatemachineEvent::CMD_FAIL, [this](InternalMessagePtr msg) { this->ProcessCmdFail(msg); })); + mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_FAIL, + [this](InternalMessagePtr msg) { this->ProcessCmdFail(msg); })); mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_STATION_JOIN, [this](InternalMessagePtr msg) { this->ProcessCmdStationJoin(msg); })); mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_STATION_LEAVE, @@ -106,8 +109,7 @@ void ApStartedState::Init() [this](InternalMessagePtr msg) { this->ProcessCmdStopHotspot(msg); })); mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_DISCONNECT_STATION, [this](InternalMessagePtr msg) { this->ProcessCmdDisconnectStation(msg); })); - mProcessFunMap.insert(std::make_pair( - ApStatemachineEvent::CMD_SET_IDLE_TIMEOUT, + mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_SET_IDLE_TIMEOUT, (ProcessFun)[this](InternalMessagePtr msg) { this->ProcessCmdSetHotspotIdleTimeout(msg); })); mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_UPDATE_COUNTRY_CODE, [this](InternalMessagePtr msg) { this->ProcessCmdUpdateCountryCode(msg); })); @@ -117,6 +119,8 @@ void ApStartedState::Init() [this](InternalMessagePtr msg) { this->ProcessCmdAssociatedStaChanged(msg); })); mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_START_HOTSPOT, [this](InternalMessagePtr msg) { this->ProcessCmdEnableAp(msg); })); + mProcessFunMap.insert(std::make_pair(ApStatemachineEvent::CMD_START_HOTSPOT_TIMEOUT, + [this](InternalMessagePtr msg) { this->ProcessCmdEnableApTimeout(msg); })); } bool ApStartedState::ExecuteStateMsg(InternalMessagePtr msg) @@ -140,7 +144,7 @@ bool ApStartedState::ExecuteStateMsg(InternalMessagePtr msg) bool ApStartedState::SetConfig(HotspotConfig &apConfig, bool isControl160M) { WIFI_LOGI("set softap config with param, id=%{public}d", m_id); - m_ApConfigUse.UpdateApChannelConfig(apConfig); + ApConfigUse::GetInstance().UpdateApChannelConfig(apConfig); std::string ifName = WifiConfigCenter::GetInstance().GetApIfaceName(); WifiErrorNo setSoftApConfigResult = WifiErrorNo::WIFI_HAL_OPT_OK; WifiErrorNo setApPasswdResult = WifiErrorNo::WIFI_HAL_OPT_OK; @@ -307,6 +311,7 @@ void ApStartedState::ProcessCmdUpdateConfigResult(InternalMessagePtr msg) const m_ApStateMachine.StopDhcpServer(); if (m_ApStateMachine.StartDhcpServer(m_hotspotConfig.GetIpAddress(), m_hotspotConfig.GetLeaseTime())) { m_ApStateMachine.OnApStateChange(ApState::AP_STATE_STARTED); + m_ApStateMachine.StopTimer(static_cast(ApStatemachineEvent::CMD_START_HOTSPOT_TIMEOUT)); } #else m_ApStateMachine.OnApStateChange(ApState::AP_STATE_STARTED); @@ -319,6 +324,13 @@ void ApStartedState::ProcessCmdUpdateConfigResult(InternalMessagePtr msg) const } } +void ApStartedState::ProcessCmdEnableApTimeout(InternalMessagePtr msg) const +{ + WIFI_LOGI("Ap enable timeout, set softap toggled false."); + WifiConfigCenter::GetInstance().SetSoftapToggledState(false); + m_ApStateMachine.SwitchState(&m_ApStateMachine.m_ApIdleState); +} + void ApStartedState::ProcessCmdAddBlockList(InternalMessagePtr msg) const { WIFI_LOGI("Instance %{public}d %{public}s", m_id, __func__); @@ -372,8 +384,7 @@ void ApStartedState::ProcessCmdUpdateCountryCode(InternalMessagePtr msg) const if (ret == WifiErrorNo::WIFI_HAL_OPT_OK) { m_wifiCountryCode = wifiCountryCode; WIFI_LOGI("update wifi country code success, wifiCountryCode=%{public}s", wifiCountryCode.c_str()); - WifiChannelHelper::GetInstance().UpdateValidChannels( - WifiConfigCenter::GetInstance().GetApIfaceName(), m_id); + WifiChannelHelper::GetInstance().UpdateValidFreqs(); return; } WIFI_LOGE("update wifi country code fail, wifiCountryCode=%{public}s, ret=%{public}d", diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h index 16397480bcb0a80e62808873bbaa2c400575104a..4dbde771e5472bcad251e373b1fe5b993f5db4e7 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state.h @@ -24,7 +24,6 @@ namespace OHOS { namespace Wifi { class ApStateMachine; -class ApConfigUse; class ApMonitor; class ApStartedState : public State { FRIEND_GTEST(ApStartedState); @@ -34,7 +33,7 @@ public: * @param None * @return None */ - ApStartedState(ApStateMachine &apStateMachine, ApConfigUse &apConfigUse, ApMonitor &apMonitor, int id = 0); + ApStartedState(ApStateMachine &apStateMachine, ApMonitor &apMonitor, int id = 0); /** * @Description destructor method. * @param None @@ -232,6 +231,7 @@ private: void ProcessCmdHotspotChannelChanged(InternalMessagePtr msg); void ProcessCmdAssociatedStaChanged(InternalMessagePtr msg); void ProcessCmdEnableAp(InternalMessagePtr msg); + void ProcessCmdEnableApTimeout(InternalMessagePtr msg) const; private: // Store the configuration when set to hostapd, hostapd will asynchronously notify the setting result @@ -242,7 +242,6 @@ private: // Message processing function map of the state machine std::map mProcessFunMap; ApStateMachine &m_ApStateMachine; - ApConfigUse &m_ApConfigUse; ApMonitor &m_ApMonitor; int m_id; bool idleTimerExist = false; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h index 7862fbefe74b333d742d3f7acfc4039167254e68..d58d1908d08cc61a76796215f6be03c8aee4e730 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_state_machine.h @@ -26,7 +26,6 @@ namespace OHOS { namespace Wifi { -class ApConfigUse; class ApStationsManager; class ApMonitor; class ApStateMachine : public StateMachine { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/i_ap_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/i_ap_service.h index c1bebbe8e623c8a406722d6b9cc9abde13652dc1..53b43072ecfa97cc96ad0ccc6c716d8739ee7d65 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/i_ap_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/i_ap_service.h @@ -37,8 +37,6 @@ public: virtual ErrCode SetHotspotConfig(const HotspotConfig &hotspotConfig) = 0; virtual ErrCode DisconnetStation(const StationInfo &stationInfo) = 0; virtual ErrCode GetStationList(std::vector &result) = 0; - virtual ErrCode GetValidBands(std::vector &bands) = 0; - virtual ErrCode GetValidChannels(BandType band, std::vector &validChannel) = 0; virtual ErrCode GetSupportedPowerModel(std::set& setPowerModelList) = 0; virtual ErrCode GetPowerModel(PowerModel& model) = 0; virtual ErrCode SetPowerModel(const PowerModel& model) = 0; @@ -58,7 +56,7 @@ public: /** * @Description get hotspot mode * - * @param model - the model to be set + * @param mode - the mode to be get * @return ErrCode - operation result */ virtual ErrCode GetHotspotMode(HotspotMode &mode); @@ -66,7 +64,7 @@ public: /** * @Description set hotspot mode * - * @param model - the model to be set + * @param mode - the mode to be set * @return ErrCode - operation result */ virtual ErrCode SetHotspotMode(const HotspotMode &mode); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_mgr_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_mgr_service_impl.cpp index cc0a3e14b0a1cbf5f53523dd102aea26784cc8f7..a00ff34d1ac6f368f40ed94ed24845114074624e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_mgr_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_mgr_service_impl.cpp @@ -76,6 +76,7 @@ void WifiHotspotMgrServiceImpl::OnStart() void WifiHotspotMgrServiceImpl::OnStop() { + std::lock_guard lock(g_hotspotMutex); mState = ServiceRunningState::STATE_NOT_START; mPublishFlag = false; WIFI_LOGI("Stop ap service!"); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.cpp index f026af66f08f392f20db9880965da0de0c9f1bc2..7660110e7abb3c8214c5facb803e64a2f5051801 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.cpp @@ -29,6 +29,7 @@ #include "wifi_country_code_manager.h" #include "mac_address.h" #include "wifi_randommac_helper.h" +#include "ap_config_use.h" DEFINE_WIFILOG_HOTSPOT_LABEL("WifiHotspotServiceImpl"); @@ -72,10 +73,7 @@ ErrCode WifiHotspotServiceImpl::IsHotspotDualBandSupported(bool &isSupported) } std::vector bands; - if (WifiChannelHelper::GetInstance().GetValidBands(bands) < 0) { - WIFI_LOGE("IsHotspotDualBandSupported:GetValidBands return failed!"); - return WIFI_OPT_FAILED; - } + ApConfigUse::GetInstance().GetApVaildBands(bands); bool is2GSupported = false; bool is5GSupported = false; @@ -247,29 +245,11 @@ ErrCode WifiHotspotServiceImpl::GetLocalOnlyHotspotConfig(HotspotConfig &result) ErrCode WifiHotspotServiceImpl::VerifyConfigValidity(const HotspotConfig &config) { - if (!mGetChannels) { - IApService *pService = WifiServiceManager::GetInstance().GetApServiceInst(m_id); - if (IsApServiceRunning() && pService != nullptr) { - std::vector valid2GChannel; - std::vector valid5GChannel; - (void)pService->GetValidChannels(BandType::BAND_2GHZ, valid2GChannel); - (void)pService->GetValidChannels(BandType::BAND_5GHZ, valid5GChannel); - if (valid2GChannel.size() + valid5GChannel.size() == 0) { - WIFI_LOGE("Failed to get supported band and channel!"); - } else { - mGetChannels = true; - } - } else { - WIFI_LOGE("Instance %{public}d, ap service is not started!", m_id); - } - } std::vector bandsFromCenter; - WifiChannelHelper::GetInstance().GetValidBands(bandsFromCenter); - ChannelsTable channInfoFromCenter; - WifiChannelHelper::GetInstance().GetValidChannels(channInfoFromCenter); + ApConfigUse::GetInstance().GetApVaildBands(bandsFromCenter); HotspotConfig configFromCenter; WifiSettings::GetInstance().GetHotspotConfig(configFromCenter, m_id); - ErrCode validRetval = IsValidHotspotConfig(config, configFromCenter, bandsFromCenter, channInfoFromCenter); + ErrCode validRetval = IsValidHotspotConfig(config, configFromCenter, bandsFromCenter); if (validRetval != ErrCode::WIFI_OPT_SUCCESS) { WIFI_LOGE("Instance %{public}d Hotspot config is invalid!", m_id); return validRetval; @@ -695,9 +675,7 @@ ErrCode WifiHotspotServiceImpl::GetValidBands(std::vector &bands) return WIFI_OPT_PERMISSION_DENIED; } - if (WifiChannelHelper::GetInstance().GetValidBands(bands) < 0) { - return WIFI_OPT_FAILED; - } + ApConfigUse::GetInstance().GetApVaildBands(bands); return WIFI_OPT_SUCCESS; } @@ -713,12 +691,7 @@ ErrCode WifiHotspotServiceImpl::GetValidChannels(BandType band, std::vectorsecond; - } + ApConfigUse::GetInstance().GetApVaildChannel(band, validchannels); return WIFI_OPT_SUCCESS; } @@ -1014,13 +987,6 @@ ErrCode WifiHotspotServiceImpl::CfgCheckBand(const HotspotConfig &cfg, std::vect return ErrCode::WIFI_OPT_INVALID_PARAM; } -ErrCode WifiHotspotServiceImpl::CfgCheckChannel(const HotspotConfig &cfg, ChannelsTable &channInfoFromCenter) -{ - std::vector channels = channInfoFromCenter[static_cast(cfg.GetBand())]; - auto it = find(channels.begin(), channels.end(), cfg.GetChannel()); - return ((it == channels.end()) ? ErrCode::WIFI_OPT_INVALID_PARAM : ErrCode::WIFI_OPT_SUCCESS); -} - static bool isNumber(std::string &str) { return !str.empty() && (str.find_first_not_of("0123456789") == std::string::npos); @@ -1057,7 +1023,7 @@ ErrCode WifiHotspotServiceImpl::CfgCheckIpAddress(const std::string &ipAddress) } ErrCode WifiHotspotServiceImpl::IsValidHotspotConfig(const HotspotConfig &cfg, const HotspotConfig &cfgFromCenter, - std::vector &bandsFromCenter, ChannelsTable &channInfoFromCenter) + std::vector &bandsFromCenter) { if (CfgCheckIpAddress(cfg.GetIpAddress()) == ErrCode::WIFI_OPT_INVALID_PARAM) { return ErrCode::WIFI_OPT_INVALID_PARAM; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.h index 5beff56ab71448499c9916c6a3e0c5ab9a3e7331..0b60ff1c90e5225cf1559c04b09a476764f9e50d 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.h @@ -272,15 +272,6 @@ public: */ ErrCode CfgCheckBand(const HotspotConfig &cfg, std::vector &bandsFromCenter); - /** - * @Description Check valid channel config - * - * @param cfg - HotspotConfig - * @param channInfoFromCenter - ChannelsTable object - * @return ErrCode - WIFI_OPT_SUCCESS or others - */ - ErrCode CfgCheckChannel(const HotspotConfig &cfg, ChannelsTable &channInfoFromCenter); - /** * @Description Check dhcp server ip address * @@ -295,11 +286,10 @@ public: * @param cfg - HotspotConfig * @param cfgFromCenter - Get HotspotConfig from config center * @param bandsFromCenter - vector of BandType - * @param channInfoFromCenter - ChannelsTable object * @return ErrCode - WIFI_OPT_SUCCESS or others */ ErrCode IsValidHotspotConfig(const HotspotConfig &cfg, const HotspotConfig &cfgFromCenter, - std::vector &bandsFromCenter, ChannelsTable &channInfoFromCenter); + std::vector &bandsFromCenter); /** * @Description Get ap iface name @@ -323,9 +313,6 @@ private: static void ConfigInfoDump(std::string& result); static void StationsInfoDump(std::string& result); ErrCode VerifyConfigValidity(const HotspotConfig &config); - -private: - bool mGetChannels = false; }; } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/BUILD.gn index 5e296d9e3a1220c3e8efe79a6bd03c30766990d3..ff3ef6be3f3a75490e8b3a02b35f17772938a8c5 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/BUILD.gn @@ -175,6 +175,7 @@ if (defined(ohos_lite)) { "wifi_sensor_scene.cpp", "wifi_system_ability_listerner.cpp", "wifi_system_timer.cpp", + "ap_config_use.cpp", ] deps = [ diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.cpp similarity index 88% rename from wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.cpp rename to wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.cpp index 2674efed0e4145b0f8780b6329f828e05e7ac7df..0fd34bda5f96460f7001ea2c6a032d4dc49e626d 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.cpp @@ -27,6 +27,7 @@ #include "wifi_msg.h" #include "wifi_p2p_msg.h" #include "wifi_config_center.h" +#include "wifi_channel_helper.h" namespace OHOS { namespace Wifi { @@ -41,6 +42,12 @@ ApConfigUse::ApConfigUse(int id) : m_id(id) m_softapChannelPolicyPtr = nullptr; // xml loading completed, release pointer } +ApConfigUse &ApConfigUse::GetInstance() +{ + static ApConfigUse gApConfigUse; + return gApConfigUse; +} + void ApConfigUse::UpdateApChannelConfig(HotspotConfig &apConfig) const { int bestChannel = AP_CHANNEL_INVALID; @@ -70,9 +77,58 @@ void ApConfigUse::UpdateApChannelConfig(HotspotConfig &apConfig) const apConfig.GetChannel()); } +bool ApConfigUse::GetApVaildChannel(BandType band, std::vector &validChannel) const +{ + WIFI_LOGI("Instance %{public}d %{public}s", m_id, __func__); + std::vector freqs; + switch (band) { + case BandType::BAND_2GHZ: + if (!WifiChannelHelper::GetInstance().GetAvailableScanFreqs( + ScanBandType::SCAN_BAND_24_GHZ, freqs)) { + WIFI_LOGE("Failed to obtain 2.4g channels from the WifiChannelHelper."); + return false; + } + TransformFrequencyIntoChannel(freqs, validChannel); + break; + case BandType::BAND_5GHZ: + if (!WifiChannelHelper::GetInstance().GetAvailableScanFreqs( + ScanBandType::SCAN_BAND_5_GHZ, freqs)) { + WIFI_LOGE("Failed to obtain 5g channels from the WifiChannelHelper."); + return false; + } + TransformFrequencyIntoChannel(freqs, validChannel); + FilterIndoorChannel(validChannel); + break; + default: + WIFI_LOGE("band param is wrong"); + return false; + } + std::string channelString; + for (auto ite : validChannel) { + channelString = channelString + std::to_string(ite) + ", "; + } + WIFI_LOGI("Instance %{public}s channelString %{public}s", __func__, channelString.data()); + return true; +} + +void ApConfigUse::GetApVaildBands(std::vector &bands) const +{ + std::vector validChannel; + GetApVaildChannel(BandType::BAND_2GHZ, validChannel); + if (validChannel.size() > 0) { + bands.push_back(BandType::BAND_2GHZ); + } + validChannel.clear(); + GetApVaildChannel(BandType::BAND_5GHZ, validChannel); + if (validChannel.size() > 0) { + bands.push_back(BandType::BAND_5GHZ); + } +} + int ApConfigUse::GetBestChannelFor2G() const { - std::vector channels = GetChannelFromDrvOrXmlByBand(BandType::BAND_2GHZ); + std::vector channels; + GetApVaildChannel(BandType::BAND_2GHZ, channels); if (channels.empty()) { WIFI_LOGI("GetBestChannelFor2G is empty"); return AP_CHANNEL_INVALID; @@ -84,8 +140,8 @@ int ApConfigUse::GetBestChannelFor2G() const int ApConfigUse::GetBestChannelFor5G(HotspotConfig &apConfig) const { - std::vector channels = GetChannelFromDrvOrXmlByBand(BandType::BAND_5GHZ); - FilterIndoorChannel(channels); + std::vector channels; + GetApVaildChannel(BandType::BAND_5GHZ, channels); Filter165Channel(channels); WIFI_LOGD("Instance %{public}d %{public}s band:%{public}d, channel:%{public}d, bandwidth:%{public}d", m_id, __func__, static_cast(apConfig.GetBand()), apConfig.GetChannel(), apConfig.GetBandWidth()); @@ -198,7 +254,7 @@ std::set ApConfigUse::GetIndoorChanByCountryCode(const std::string &country { std::set indoorChannelByCode; if (countryCode.empty() || m_softapIndoorChannels.find(countryCode) == m_softapIndoorChannels.end()) { - return indoorChannelByCode; + return defaultIndoorChannel_; } indoorChannelByCode = m_softapIndoorChannels.find(countryCode)->second; return indoorChannelByCode; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.h similarity index 90% rename from wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.h rename to wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.h index 4cd8bdb3a039752678b4a29b3cc1f3661ecf1fba..e27cf530ac3304aa1e93181cca8ec8bb8a356700 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.h @@ -28,6 +28,7 @@ namespace Wifi { class ApConfigUse { FRIEND_GTEST(ApIdleState); public: + static ApConfigUse &GetInstance(); /** * @Description construction method * @@ -50,6 +51,21 @@ public: * @param apConfig - ap configuration input */ void UpdateApChannelConfig(HotspotConfig &apConfig) const; + + /** + * @Description Filter Indoor Channel + * + * @param band - band + * @param validChannel - channels + */ + bool GetApVaildChannel(BandType band, std::vector &validChannel) const; + + /** + * @Description GetApVaildBands + * + * @param bands - bands + */ + void GetApVaildBands(std::vector &bands) const; private: static constexpr int DEFAULT_STA_INSTANCE_ID = 0; @@ -97,6 +113,7 @@ private: std::unique_ptr m_softapChannelPolicyPtr; std::map> m_softapIndoorChannels; std::map> m_softapPreferredChannels; + std::set defaultIndoorChannel_ = {36, 40, 44, 48, 52, 56, 60, 64}; DISALLOW_COPY_AND_ASSIGN(ApConfigUse) int GetBestChannelFor2G() const; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.cpp index f325798da0b1e101c56d219221e2eb49a3be8fc8..524f7167cb907162cd72a9214e1a84aa60e04cf4 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.cpp @@ -83,7 +83,6 @@ int WifiChannelHelper::GetValidBands(std::vector &bands) int WifiChannelHelper::SetValidChannels(const ChannelsTable &channelsInfo) { - std::unique_lock lock(mMutex); mValidChannels = channelsInfo; return 0; } @@ -95,48 +94,9 @@ int WifiChannelHelper::GetValidChannels(ChannelsTable &channelsInfo) return 0; } -void WifiChannelHelper::UpdateValidChannels(std::string ifaceName, int instId) -{ - WIFI_LOGI("enter UpdateValidChannels"); - ChannelsTable chanTbs; - std::vector freqs2G; - std::vector freqs5G; - int band = static_cast(BandType::BAND_2GHZ); -#ifdef HDI_CHIP_INTERFACE_SUPPORT - if (!HalDeviceManager::GetInstance().GetFrequenciesByBand(ifaceName, band, freqs2G)) { - WIFI_LOGE("get 2g frequencies failed."); - WifiSettings::GetInstance().SetDefaultFrequenciesByCountryBand(BandType::BAND_2GHZ, freqs2G, instId); - } -#endif - band = static_cast(BandType::BAND_5GHZ); -#ifdef HDI_CHIP_INTERFACE_SUPPORT - if (!HalDeviceManager::GetInstance().GetFrequenciesByBand(ifaceName, band, freqs5G)) { - WIFI_LOGE("get 5g frequencies failed."); - } -#endif - std::vector supp2Gfreqs(freqs2G.begin(), freqs2G.end()); - std::vector supp5Gfreqs(freqs5G.begin(), freqs5G.end()); - for (auto iter = supp2Gfreqs.begin(); iter != supp2Gfreqs.end(); iter++) { - int32_t channel = TransformFrequencyIntoChannel(*iter); - if (channel == INVALID_FREQ_OR_CHANNEL) { - continue; - } - chanTbs[BandType::BAND_2GHZ].push_back(channel); - } - for (auto iter = supp5Gfreqs.begin(); iter != supp5Gfreqs.end(); iter++) { - int32_t channel = TransformFrequencyIntoChannel(*iter); - if (channel == INVALID_FREQ_OR_CHANNEL) { - continue; - } - chanTbs[BandType::BAND_5GHZ].push_back(channel); - } - if (SetValidChannels(chanTbs)) { - WIFI_LOGE("%{public}s, fail to SetValidChannels", __func__); - } -} - void WifiChannelHelper::UpdateValidFreqs() { + std::unique_lock lock(mMutex); std::vector freqs2G; std::vector freqs5G; std::vector freqsDfs; @@ -162,10 +122,16 @@ void WifiChannelHelper::UpdateValidFreqs() mValidFreqs[ScanBandType::SCAN_BAND_24_GHZ] = freqs2G; mValidFreqs[ScanBandType::SCAN_BAND_5_GHZ] = freqs5G; mValidFreqs[ScanBandType::SCAN_BAND_5_GHZ_DFS_ONLY] = freqsDfs; + + std::vector supp5Gfreqs(freqs5G.begin(), freqs5G.end()); + supp5Gfreqs.insert(supp5Gfreqs.end(), freqsDfs.begin(), freqsDfs.end()); + std::sort(supp5Gfreqs.begin(), supp5Gfreqs.end()); + UpdateValidChannels(freqs2G, supp5Gfreqs); } bool WifiChannelHelper::GetAvailableScanFreqs(ScanBandType band, std::vector& freqs) { + std::unique_lock lock(mMutex); switch (band) { case ScanBandType::SCAN_BAND_24_GHZ: { freqs.assign(mValidFreqs[ScanBandType::SCAN_BAND_24_GHZ].begin(), @@ -320,6 +286,27 @@ bool WifiChannelHelper::IsValid5GChannel(int channel) { return channel >= CHANNEL_5G_MIN && channel <= CHANNEL_5G_MAX; } +void WifiChannelHelper::UpdateValidChannels(std::vector &supp2Gfreqs, std::vector &supp5Gfreqs) +{ + ChannelsTable chanTbs; + for (auto iter = supp2Gfreqs.begin(); iter != supp2Gfreqs.end(); iter++) { + int32_t channel = TransformFrequencyIntoChannel(*iter); + if (channel == INVALID_FREQ_OR_CHANNEL) { + continue; + } + chanTbs[BandType::BAND_2GHZ].push_back(channel); + } + for (auto iter = supp5Gfreqs.begin(); iter != supp5Gfreqs.end(); iter++) { + int32_t channel = TransformFrequencyIntoChannel(*iter); + if (channel == INVALID_FREQ_OR_CHANNEL) { + continue; + } + chanTbs[BandType::BAND_5GHZ].push_back(channel); + } + if (SetValidChannels(chanTbs)) { + WIFI_LOGE("%{public}s, fail to SetValidChannels", __func__); + } +} } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.h index bc7abd98d98c8ed107de01d994833c9c46c5a24c..c612af0fdb40cf0922341959fbdeba247b0583c6 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.h @@ -30,12 +30,8 @@ public: int GetValidBands(std::vector &bands); - int SetValidChannels(const ChannelsTable &channelsInfo); - int GetValidChannels(ChannelsTable &channelsInfo); - void UpdateValidChannels(std::string ifaceName, int instId = 0); - bool GetAvailableScanFreqs(ScanBandType band, std::vector& freqs); bool IsFreqDbac(int freqA, int freqB); @@ -61,10 +57,11 @@ public: bool IsValid24GChannel(int channel); bool IsValid5GChannel(int channel); - + void UpdateValidFreqs(); private: WifiChannelHelper(); - void UpdateValidFreqs(); + void UpdateValidChannels(std::vector &supp2Gfreqs, std::vector &supp5Gfreqs); + int SetValidChannels(const ChannelsTable &channelsInfo); ChannelsTable mValidChannels {DEFAULT_VALID_CHANNEL}; std::mutex mMutex; std::map> mValidFreqs; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_internal_event_dispatcher.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_internal_event_dispatcher.cpp index f2be5f33992a544a48c9a00b2eeeb5e14d8c8632..2e5c713819c4a51571f4f2ade4ea04526458b931 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_internal_event_dispatcher.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_internal_event_dispatcher.cpp @@ -293,18 +293,24 @@ ErrCode WifiInternalEventDispatcher::AddScanCallback( int WifiInternalEventDispatcher::RemoveScanCallback(const sptr &remote, int instId) { - if (remote != nullptr) { - std::unique_lock lock(mScanCallbackMutex); - auto iter = mScanCallbacks.find(instId); - if (iter != mScanCallbacks.end()) { - auto itr = iter->second.find(remote); - if (itr != iter->second.end()) { - iter->second.erase(itr); - mScanCallBackInfo[instId].erase(mScanCallBackInfo[instId].find(remote)); - WIFI_LOGD("WifiInternalEventDispatcher::RemoveScanCallback!"); - } - } + if (remote == nullptr) { + return 0; + } + std::unique_lock lock(mScanCallbackMutex); + auto iter = mScanCallbacks.find(instId); + if (iter == mScanCallbacks.end()) { + return 0; + } + auto itr = iter->second.find(remote); + if (itr == iter->second.end()) { + WIFI_LOGW("WifiInternalEventDispatcher::remote not find"); + return 0; + } + iter->second.erase(itr); + if (mScanCallBackInfo[instId].find(remote) != mScanCallBackInfo[instId].end()) { + mScanCallBackInfo[instId].erase(mScanCallBackInfo[instId].find(remote)); } + WIFI_LOGD("WifiInternalEventDispatcher::RemoveScanCallback!"); return 0; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.cpp index 2cdfa027bf0bb6b601779709fe3213897b032ce3..9513c89b7e6b4937daf70052124e3c2fb9ff7818 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.cpp @@ -56,52 +56,6 @@ WifiNetAgent::~WifiNetAgent() } } -bool WifiNetAgent::RegisterNetConnObserver(int instId) -{ - if (instId != INSTID_WLAN0) { - WIFI_LOGI("RegisterNetConnObserver instId is not 0."); - return false; - } - - bool isBtNet = IsDefaultBtNet(); - WifiConfigCenter::GetInstance().SetAutoConnect(!isBtNet); - - if (netConnCallback_ == nullptr) { - netConnCallback_ = new (std::nothrow)NetInfoObserver(); - if (netConnCallback_ == nullptr) { - WIFI_LOGE("RegisterNetConnObserver netConnCallback is null."); - return false; - } - } - - NetManagerStandard::NetSpecifier netSpecifier; - NetManagerStandard::NetAllCapabilities netAllCapabilities; - netAllCapabilities.netCaps_.insert(NetManagerStandard::NetCap::NET_CAPABILITY_INTERNET); - netSpecifier.ident_ = ""; - netSpecifier.netCapabilities_ = netAllCapabilities; - sptr specifier = new NetManagerStandard::NetSpecifier(netSpecifier); - NetManagerStandard::NetConnClient::GetInstance().RegisterNetConnCallback(specifier, netConnCallback_, 0); - WIFI_LOGI("RegisterNetConnObserver success."); - return true; -} - -int32_t WifiNetAgent::NetInfoObserver::NetAvailable(sptr &netHandle) -{ - bool isBtNet = IsDefaultBtNet(); - WifiConfigCenter::GetInstance().SetAutoConnect(!isBtNet); - WIFI_LOGI("NetAvailable, isBtNet:%{public}d.", isBtNet); - return 0; -} - -bool WifiNetAgent::IsDefaultBtNet() -{ - NetManagerStandard::NetHandle defaultNet; - NetManagerStandard::NetConnClient::GetInstance().GetDefaultNet(defaultNet); - NetManagerStandard::NetAllCapabilities netAllCap; - NetConnClient::GetInstance().GetNetCapabilities(defaultNet, netAllCap); - return netAllCap.bearerTypes_.find(NetManagerStandard::BEARER_BLUETOOTH) != netAllCap.bearerTypes_.end(); -} - bool WifiNetAgent::RegisterNetSupplier(int instId) { TimeStats timeStats(__func__); @@ -264,7 +218,6 @@ void WifiNetAgent::OnStaMachineWifiStart(int instId) netAgentEventHandler_->PostSyncTask([this, m_instId = instId]() { this->RegisterNetSupplier(m_instId); this->RegisterNetSupplierCallback(m_instId); - this->RegisterNetConnObserver(m_instId); }); } } @@ -279,7 +232,6 @@ void WifiNetAgent::OnStaMachineNetManagerRestart(const sptrPostSyncTask([this, supplierInfo = netSupplierInfo, m_instId = instId]() { this->RegisterNetSupplier(m_instId); this->RegisterNetSupplierCallback(m_instId); - this->RegisterNetConnObserver(m_instId); WifiLinkedInfo linkedInfo; WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo, m_instId); if (linkedInfo.connState == ConnState::CONNECTED) { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.h index a4c1eef1ebfd8854312075ef9cc2a10313dd742e..b3b5e3c679649ace408106cd004b813370da7b33 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_net_agent.h @@ -32,7 +32,6 @@ #include "sta_service_callback.h" #include "wifi_log.h" #include "net_manager_constants.h" -#include "net_conn_callback_stub.h" namespace OHOS { namespace Wifi { struct WifiNetAgentCallbacks { @@ -111,13 +110,6 @@ public: */ void OnStaMachineWifiStart(int instId); - /** - * Register network connect call back - * - * @return true if register success else return false; - */ - bool RegisterNetConnObserver(int instId); - /** * Add OnStaMachineNetManagerRestart * @@ -231,12 +223,6 @@ private: WifiNetAgentCallbacks wifiNetAgentCallbacks_; std::unique_ptr netAgentEventHandler_ = nullptr; std::mutex netAgentMutex_; - class NetInfoObserver final : public NetManagerStandard::NetConnCallbackStub { - public: - int32_t NetAvailable(sptr &netHandle) override; - }; - sptr netConnCallback_ { nullptr }; - static bool IsDefaultBtNet(); }; } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_protect_manager.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_protect_manager.cpp index f4e4f7c701e1e721a70b77b3b570b1abf8f608bb..63f68c4d2e7a774596868a1c8ed22bba2e312364 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_protect_manager.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_protect_manager.cpp @@ -158,7 +158,7 @@ bool WifiProtectManager::GetWifiProtect( static_cast(protectMode), name.c_str()); return false; } - WifiProtectMode curProtectMode = WifiProtectMode::WIFI_PROTECT_DEFAULT; + WifiProtectMode curProtectMode; #endif bool isAlreadyExist = false; std::unique_lock lock(mMutex); @@ -462,4 +462,4 @@ void WifiProtectManager::OnAppForegroudChanged(const std::string &bundleName, in #endif } // namespace Wifi -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp index 31e6ae8e9f0652b923d9987e8fec6a5c9b042417..43654f2f7f6a5fbe4536c801594420b666567647 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine.cpp @@ -238,7 +238,6 @@ void ConcreteMangerMachine::IdleState::HandleSwitchToConnectMode(InternalMessage { ErrCode ret = WifiServiceScheduler::GetInstance().AutoStartStaService(mid, ifaceName); if (ret != WIFI_OPT_SUCCESS) { - WifiConfigCenter::GetInstance().SetWifiStopState(true); pConcreteMangerMachine->mcb.onStartFailure(mid); return; } @@ -249,7 +248,6 @@ void ConcreteMangerMachine::IdleState::HandleSwitchToScanOnlyMode(InternalMessag { ErrCode ret = WifiServiceScheduler::GetInstance().AutoStartScanOnly(mid, ifaceName); if (ret != WIFI_OPT_SUCCESS) { - WifiConfigCenter::GetInstance().SetWifiStopState(true); pConcreteMangerMachine->mcb.onStartFailure(mid); return; } @@ -260,7 +258,6 @@ void ConcreteMangerMachine::IdleState::HandleSwitchToSemiActiveMode(InternalMess { ErrCode ret = WifiServiceScheduler::GetInstance().AutoStartSemiStaService(mid, ifaceName); if (ret != WIFI_OPT_SUCCESS) { - WifiConfigCenter::GetInstance().SetWifiStopState(true); pConcreteMangerMachine->mcb.onStartFailure(mid); return; } @@ -273,14 +270,12 @@ void ConcreteMangerMachine::IdleState::HandleStartInIdleState(InternalMessagePtr WIFI_LOGI("HandleStartInIdleState mTargetRole:%{public}d mid:%{public}d", mTargetRole, mid); ErrCode res = WifiServiceScheduler::GetInstance().AutoStartScanOnly(mid, ifaceName); if (res != WIFI_OPT_SUCCESS) { - WifiConfigCenter::GetInstance().SetWifiStopState(true); pConcreteMangerMachine->mcb.onStartFailure(mid); return; } if (mTargetRole == static_cast(ConcreteManagerRole::ROLE_CLIENT_STA)) { ErrCode ret = WifiServiceScheduler::GetInstance().AutoStartStaService(mid, ifaceName); if (ret != WIFI_OPT_SUCCESS) { - WifiConfigCenter::GetInstance().SetWifiStopState(true); pConcreteMangerMachine->mcb.onStartFailure(mid); return; } @@ -292,7 +287,6 @@ void ConcreteMangerMachine::IdleState::HandleStartInIdleState(InternalMessagePtr mTargetRole == static_cast(ConcreteManagerRole::ROLE_CLIENT_STA_SEMI_ACTIVE)) { ErrCode ret = WifiServiceScheduler::GetInstance().AutoStartSemiStaService(mid, ifaceName); if (ret != WIFI_OPT_SUCCESS) { - WifiConfigCenter::GetInstance().SetWifiStopState(true); pConcreteMangerMachine->mcb.onStartFailure(mid); return; } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_define.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_define.h index 4169b75b05a3f6f44775894393a9b6b5de305e9c..15083f0f902a9ade16e2f2a96c75e69c915510ee 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_define.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_define.h @@ -24,7 +24,7 @@ namespace Wifi { #define WIFI_OPEN_RETRY_MAX_COUNT 3 #define WIFI_OPEN_RETRY_TIMEOUT 1000 #define WIFI_OPEN_TIMEOUT 10000 -#define CONCRETE_STOP_TIMEOUT 1000 +#define CONCRETE_STOP_TIMEOUT 10000 #define CMD_WIFI_TOGGLED 0x1 #define CMD_SOFTAP_TOGGLED 0x2 diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp index 971675706838b5e0d572285f428f8d843cbb5198..8dff7d37d18e0ac339189874cb0b1cf16f41a6ae 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_controller/wifi_controller_state_machine.cpp @@ -200,14 +200,13 @@ bool WifiControllerMachine::EnableState::ExecuteStateMsg(InternalMessagePtr msg) msg->GetParam1() == INSTID_WLAN0 ? HandleStaStartFailure(INSTID_WLAN0) : pWifiControllerMachine->multiStaManagers.RemoveManager(INSTID_WLAN1); break; - case CMD_CONCRETE_STOPPED: { + case CMD_CONCRETE_STOPPED: if (!pWifiControllerMachine->concreteManagers.IdExist(INSTID_WLAN0)) { WIFI_LOGI("HandleStopConcretRetry concreteManagers not IdExist"); break; } pWifiControllerMachine->HandleConcreteStop(INSTID_WLAN0); break; - } case CMD_MULTI_STA_STOPPED: pWifiControllerMachine->multiStaManagers.RemoveManager(INSTID_WLAN1); break; @@ -901,6 +900,12 @@ void WifiControllerMachine::HandleConcreteStop(int id) } } else { #endif + if (!WifiConfigCenter::GetInstance().GetCoexSupport() && + WifiManager::GetInstance().GetWifiTogglerManager()->HasAnyApRuning() && + WifiConfigCenter::GetInstance().GetApIfaceName() == "wlan0") { + WIFI_LOGI("Softap(wlan0) mode do not start scanonly after turn off wifi."); + return; + } if (ShouldEnableWifi(id)) { ConcreteManagerRole presentRole = GetWifiRole(); MakeConcreteManager(presentRole, 0); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c index e40831a990ae525bbbd8ed4ad64b8732416f019b..4da467468881a8b7b2554e2470c9f3e74b07c954 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy.c @@ -323,7 +323,7 @@ WifiErrorNo HdiWpaStart() pthread_mutex_unlock(&g_wpaObjMutex); return WIFI_HAL_OPT_FAILED; } - + RegistHdfDeathCallBack(); pthread_mutex_unlock(&g_wpaObjMutex); LOGI("HdiWpaStart start success!"); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_client.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_client.h index c8147a2e41576c7fd2061859712886ddc7b1f2e9..9e80991f2b88e7c0021719eb9ee6580ddf68ac28 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_client.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/wifi_hdi_wpa_client.h @@ -826,7 +826,7 @@ public: * @return WifiErrorNo */ WifiErrorNo DeliverP2pData(int32_t cmdType, int32_t dataType, const std::string& carryData) const; - + /** * @Description Enable Softap. * diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.cpp index 6ed49391a88aa086aa8810cffedc837f1aba450f..95bb938cae823f48e7e257013924e5a03245f1c1 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.cpp @@ -640,7 +640,7 @@ bool HalDeviceManager::SetTxPower(int power) if (!CheckReloadChipHdiService()) { return false; } - + std::lock_guard lock(mMutex); int32_t staResult = IfaceSetTxPower(WifiConfigCenter::GetInstance().GetStaIfaceName(), mIWifiStaIfaces, power); @@ -1636,4 +1636,4 @@ int32_t ChipIfaceCallback::OnWifiNetlinkMessage(uint32_t type, const std::vector } // namespace Wifi } // namespace OHOS -#endif +#endif \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.h index 84b0d1a40c58c80d6ca2e928c5e255d444981e12..1372f0634787eb58ff862b2c5bfd0ea65c9bd758 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/hal_device_manage/hal_device_manage.h @@ -434,7 +434,7 @@ public: /** * @Description Set p2p high perf mode - * @param interfaceName interfaceName + * @param ifaceName interfaceName * @param isEnable - enable high perf mode or not * @return bool */ @@ -500,4 +500,4 @@ private: } // namespace Wifi } // namespace OHOS #endif -#endif \ No newline at end of file +#endif diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/i_wifi_struct.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/i_wifi_struct.h index 206d9d299ad3beaf87e3d60b85f6b0b3db75ded9..155f3a9ca39d94027d9c13452f18cf2b5ed275fe 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/i_wifi_struct.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/i_wifi_struct.h @@ -14,10 +14,8 @@ */ #ifndef OHOS_IDL_IWIFI_STRUCT_H #define OHOS_IDL_IWIFI_STRUCT_H - #include #include - #ifdef __cplusplus extern "C" { #endif diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.h index 89b0a361ef5282bcbe86225128125e666a2e6951..c76cb6b2c2b9630db9cf764ecbe0b23187e4ce8d 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_native/wifi_hal_interface/wifi_sta_hal_interface.h @@ -447,5 +447,4 @@ private: }; } // namespace Wifi } // namespace OHOS - #endif \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_formed_state.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_formed_state.cpp index 52da099d4f9e8552ce99a72130cb7eaab02bd2b4..d4f8bab111a53ed5f81fa00704d79bdc47028ac9 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_formed_state.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_formed_state.cpp @@ -268,6 +268,7 @@ bool GroupFormedState::ProcessDisconnectEvt(const InternalMessagePtr msg) const if (groupManager.IsCurrGroupClientEmpty() && !groupManager.GetCurrentGroup().IsExplicitGroup()) { WIFI_LOGE("Clients empty, remove p2p group."); p2pStateMachine.SwitchState(&p2pStateMachine.p2pGroupOperatingState); + p2pStateMachine.SendMessage(static_cast(P2P_STATE_MACHINE_CMD::CMD_REMOVE_GROUP)); } else { p2pStateMachine.BroadcastP2pConnectionChanged(); } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp index a6e7102e163f669593c64e8441431be3057847c6..5180a2f28b0e996bb1cccfbd6a9a62780c6f7b1c 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/group_negotiation_state.cpp @@ -154,7 +154,6 @@ void GroupNegotiationState::DoDhcpInGroupStart(void) const WIFI_LOGI("ProcessGroupStartedEvt %{private}s %{private}s", device.GetDeviceAddress().c_str(), device.GetRandomDeviceAddress().c_str()); deviceManager.UpdateDeviceStatus(owner.GetDeviceAddress(), P2pDeviceStatus::PDS_CONNECTED); - p2pStateMachine.BroadcastP2pPeersChanged(); } else { WIFI_LOGE("fail:No GO device information is found."); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp index 425a2d5ad4989c7149e6050cd21895b0c54c7390..948a8014a6e6086eda50ea569944acfdb42eaf1b 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.cpp @@ -527,7 +527,7 @@ void P2pMonitor::WpaEventGroupStarted(const HalP2pGroupInfo &groupInfo) const } else { group.SetPassphrase(std::string(groupInfo.psk)); } - if (groupInfo.isPersistent && groupInfo.psk.empty()) { + if (groupInfo.isPersistent && !groupInfo.isGo && groupInfo.psk.empty()) { WIFI_LOGE("groupinfo isPersistent and psk is null"); group.SetIsPersistent(0); } else { @@ -649,9 +649,10 @@ void P2pMonitor::WpaEventApStaDisconnected(const std::string &p2pDeviceAddress) Broadcast2SmApStaDisconnected(selectIfacName, device); } -void P2pMonitor::WpaEventApStaConnected(const std::string &p2pDeviceAddress, const std::string &p2pGroupAddress) const +void P2pMonitor::WpaEventApStaConnected(const std::string &p2pDeviceAddress, + const std::string &p2pGroupAddress) const { - WIFI_LOGD("onStaAuthorized callback, p2pDeviceAddress: %{private}s, p2pGroupAddress: %{private}s", + WIFI_LOGD("onStaAuthorized callback, p2pDeviceAddress:%{private}s p2pGroupAddress %{private}s", p2pDeviceAddress.c_str(), p2pGroupAddress.c_str()); WifiP2pDevice device; device.SetDeviceAddress(p2pDeviceAddress); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.h index 2e3d91002d6fa6dcb44561b39e946176df83efe2..7fee1fbec0c99cc36a966d7ab5c65a3e6680b1d3 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_monitor.h @@ -413,9 +413,11 @@ private: * @Description Register the callback function for connecting STA to AP * * @param p2pDeviceAddress - the MAC address of the STA connected - * @param p2pGroupAddress - the group address of the STA connected + * @param p2pGroupAddress - the group MAC address of the STA connected */ - void WpaEventApStaConnected(const std::string &p2pDeviceAddress, const std::string &p2pGroupAddress) const; + void WpaEventApStaConnected(const std::string &p2pDeviceAddress, + const std::string &p2pGroupAddress) const; + /** * @Description Register Wpa_supplicant client connection failure callback function * diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_state_machine.cpp index de357b0ac1fdfb83325cdcbc3cc9c036e2889e9f..6c559fcd485265996bc744a8a142c11a640cf0b1 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/p2p_state_machine.cpp @@ -418,12 +418,12 @@ ErrCode P2pStateMachine::AddClientInfo(std::vector &gcInfos) GcInfo P2pStateMachine::MatchDevInGcInfos(const std::string &deviceAddr, const std::string &groupAddr, std::vector &gcInfos) { - WIFI_LOGD("P2pStateMachine::MatchDevInGcInfos: devAddr = %s, groupAddr = %s", + WIFI_LOGD("P2pStateMachine::MatchDevInGcInfos: devAddr = %{public}s, groupAddr = %{public}s", MacAnonymize(deviceAddr).c_str(), MacAnonymize(groupAddr).c_str()); GcInfo info; for (auto gcInfo : gcInfos) { if ((gcInfo.mac == deviceAddr) || (gcInfo.mac == groupAddr)) { - WIFI_LOGD("find curDev Ip:%s", gcInfo.ip.c_str()); + WIFI_LOGD("find curDev Ip:%{private}s", gcInfo.ip.c_str()); info = gcInfo; break; } @@ -433,7 +433,7 @@ GcInfo P2pStateMachine::MatchDevInGcInfos(const std::string &deviceAddr, ErrCode P2pStateMachine::RemoveClientInfo(std::string mac) { - WIFI_LOGD("P2pStateMachine::RemoveClientInfo: mac = %s", + WIFI_LOGD("P2pStateMachine::RemoveClientInfo: mac = %{private}s", MacAnonymize(mac).c_str()); WifiP2pLinkedInfo linkedInfo; WifiConfigCenter::GetInstance().GetP2pInfo(linkedInfo); @@ -933,7 +933,7 @@ void P2pStateMachine::DhcpResultNotify::OnFailed(int status, const char *ifname, void P2pStateMachine::DhcpResultNotify::OnDhcpServerSuccess(const char *ifname, DhcpStationInfo *stationInfos, size_t size) { - WIFI_LOGI("Dhcp notify ServerSuccess. ifname:%s", ifname); + WIFI_LOGI("Dhcp notify ServerSuccess. ifname:%{private}s", ifname); std::vector gcInfos; if (size < 0 || size > MAX_CLIENT_SIZE) { WIFI_LOGE("size is invaild"); @@ -976,7 +976,7 @@ void P2pStateMachine::StartDhcpClientInterface() if (strncpy_s(config.ifname, sizeof(config.ifname), groupManager.GetCurrentGroup().GetInterface().c_str(), groupManager.GetCurrentGroup().GetInterface().length()) != EOK) { WIFI_LOGE("strncpy_s config.ifname failed!"); - return; + return; } result = StartDhcpClient(config); if (result != 0) { @@ -1073,7 +1073,7 @@ int P2pStateMachine::GetAvailableFreqByBand(GroupOwnerBand band) const } int randomFreq = GetRandomSocialFreq(freqList); if (randomFreq == 0) { - WIFI_LOGE("Cannot get 1 6 11 channel frequency"); + WIFI_LOGE("Can not get 1 6 11 channel frequency"); return retFreq; } return randomFreq; @@ -1296,7 +1296,7 @@ void P2pStateMachine::UpdateGroupInfoToWpa() const WifiP2PHalInterface::GetInstance().P2pSetGroupConfig(createdNetId, wpaConfig); grpInfo.at(i) = grpBuf; } else { - WIFI_LOGW("AddNetwork failed when add %{public}s group!", grpBuf.GetGroupName().c_str()); + WIFI_LOGE("AddNetwork failed when add %{private}s group!", grpBuf.GetGroupName().c_str()); } } return; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.cpp index 46b5afadbece79dc05ce85b8afa1e6bb529c94f0..e670757827a00d30364b69e91471b2106d4a0ed8 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.cpp @@ -1205,12 +1205,12 @@ ErrCode WifiP2pServiceImpl::Hid2dCreateGroup(const int frequency, FreqType type) ErrCode WifiP2pServiceImpl::Hid2dRemoveGcGroup(const std::string& gcIfName) { WIFI_LOGI("Hid2dRemoveGcGroup:, gcIfName: %{public}s", gcIfName.c_str()); - // TO Imple: delete by interface int callingUid = GetCallingUid(); if (callingUid != SOFT_BUS_SERVICE_UID) { WIFI_LOGE("%{public}s, permission denied! uid = %{public}d", __func__, callingUid); return WIFI_OPT_PERMISSION_DENIED; } + // TO Imple: delete by interface return RemoveGroup(); } @@ -1437,15 +1437,6 @@ ErrCode WifiP2pServiceImpl::Hid2dSetUpperScene(const std::string& ifName, const return WIFI_OPT_PERMISSION_DENIED; } WifiConfigCenter::GetInstance().SetHid2dUpperScene(callingUid, scene); - IScanService *pScanService = WifiServiceManager::GetInstance().GetScanServiceInst(0); - if (pScanService == nullptr) { - WIFI_LOGE("Hid2dSetUpperScene, pService is nullptr"); - return WIFI_OPT_FAILED; - } - if (callingUid == SHARE_SERVICE_UID && scene.scene == false) { - WIFI_LOGI("Hid2dSetUpperScene, trigger scan"); - pScanService->Scan(true, ScanType::SCAN_TYPE_SYSTEMTIMER); - } /* Not support currently */ WIFI_LOGI("Set upper scene, ifName=%{public}s, scene=%{public}u, fps=%{public}d, bw=%{public}u", ifName.c_str(), scene.scene, scene.fps, scene.bw); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.h index c540eeb6bb4d4774f60a10fbae0a811d10f8ee78..143f20f90fded9de14b44f5f354d76c6e01590e3 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_service_impl.h @@ -480,4 +480,4 @@ private: }; } // namespace Wifi } // namespace OHOS -#endif \ No newline at end of file +#endif diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_stub.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_stub.cpp index 5ea7511ab4435d9e716b1612e39351b754d69de9..12804578f342ad989e0e5e36192ea408c9b8db04 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_stub.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_p2p_sa/wifi_p2p_stub.cpp @@ -435,6 +435,10 @@ void WifiP2pStub::OnQueryP2pLinkedInfo(uint32_t code, MessageParcel &data, Messa reply.WriteString(config.GetGroupOwnerAddress()); std::vector gcInfos = config.GetClientInfoList(); int size = static_cast(gcInfos.size()); + if (size <= 0) { + WIFI_LOGE("gcInfos.size is %{public}d", size); + return; + } reply.WriteInt32(size); for (int i = 0; i < size; i++) { reply.WriteString(gcInfos[i].mac); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper.cpp index 76fa421e1c5570a0bba3a0af90a4dbd03b36ad8f..39551933f94108dab41880865665e21f9ff83289 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper.cpp @@ -299,7 +299,7 @@ int32_t ApInfoHelper::GetApInfoByBssid(const std::string &bssid, ApInfoData &dat int32_t index = -1; auto iter = apInfos_.begin(); if (apInfos_.size() == 0) { - WIFI_LOGE("GetApInfoByBssid no apInfos_."); + WIFI_LOGD("GetApInfoByBssid no apInfos_."); return -1; } for (; iter != apInfos_.end();) { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.cpp index 6e6e8d37c8c6d8e977519fbdd21f33e0f5142a14..f86237555bf9bca9d4e360cc2cfb33ba377b91aa 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.cpp @@ -363,7 +363,9 @@ bool WifiIntelligenceStateMachine::DisabledState::ExecuteStateMsg(InternalMessag break; case EVENT_HANDLE_SCAN_RESULT: ret = EXECUTED; - pWifiIntelligenceStateMachine_->UpdateScanResult(msg); + if (pWifiIntelligenceStateMachine_->mIsScanning_) { + pWifiIntelligenceStateMachine_->UpdateScanResult(msg); + } break; case EVENT_WIFI_HANLE_OPEN: ret = EXECUTED; @@ -483,6 +485,8 @@ bool WifiIntelligenceStateMachine::IsInBlacklist(std::string bssid) void WifiIntelligenceStateMachine::DisabledState::HandleWifiFindTarget(InternalMessagePtr msg) { + WIFI_LOGI("DsiabledState, EVENT_WIFI_FIND_TARGET"); + pWifiIntelligenceStateMachine_->StopScanAp(); pWifiIntelligenceStateMachine_->StartTimer(EVENT_WIFI_HANLE_OPEN, AUTO_OPEN_WIFI_DELAY_TIME); } @@ -524,9 +528,7 @@ void WifiIntelligenceStateMachine::UpdateScanResult(InternalMessagePtr msg) SetScanIntervel(mScanType_); } else { if (mScanType_ == SCAN_TYPE_THREE) { - StopTimer(EVENT_SCAN_AGAIN); - mScanTimes_ = 0; - mScanType_ = SCAN_TYPE_ONE; + StopScanAp(); } else { mScanType_++; mScanTimes_ = 0; @@ -908,7 +910,12 @@ bool WifiIntelligenceStateMachine::FullScan() { WIFI_LOGD("start Fullscan"); if (!WifiConfigCenter::GetInstance().CheckScanOnlyAvailable(instId_)) { - WIFI_LOGI("scan only is not available, can not start scan."); + WIFI_LOGE("scan only is not available, can not start scan."); + return false; + } + if (WifiConfigCenter::GetInstance().GetWifiMidState() == WifiOprMidState::RUNNING) { + WIFI_LOGE("Wifi is already open, no need to start scan."); + StopScanAp(); return false; } IScanService *pScanService = WifiServiceManager::GetInstance().GetScanServiceInst(instId_); @@ -916,6 +923,7 @@ bool WifiIntelligenceStateMachine::FullScan() WIFI_LOGI("TryStartScan, pService is nullptr."); return false; } + mIsScanning_ = true; return pScanService->Scan(false); } @@ -1019,6 +1027,7 @@ void WifiIntelligenceStateMachine::StopScanAp() { mScanTimes_ = 0; mScanType_ = SCAN_TYPE_ONE; + mIsScanning_ = false; StopTimer(EVENT_SCAN_AGAIN); } } diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.h index 4a92edeaad7a3374cd788d626d73f0abe85d4e88..6d6d14387f1d577b9ad1dc468ffe296341fc2eef 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/wifi_intelligence_state_machine.h @@ -225,6 +225,7 @@ private: bool mIsScanInShort_ { false }; int32_t mScanType_ { 1 }; bool mIsAutoOpenSearch_ { false }; + bool mIsScanning_ { false }; bool ProcessScanResult(std::vector scanInfoList, std::string cellId); bool IsHasTargetAp(std::vector &scanInfoLis); bool IsInBlacklist(std::string bssid); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.cpp index 106d619d302fff51be9f52900cee2663199f2462..ed5ebc24c03495dd2b851d6bc9036c9101885dbf 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.cpp @@ -138,7 +138,7 @@ ErrCode WifiProStateMachine::Initialize() bool WifiProStateMachine::IsKeepCurrWifiConnected() { // First detect nonet and user select, do not switch - if (currentState_ == WifiProState::WIFI_NONET && WifiProUtils::IsUserSelectNetwork() && isFirstNetDectect_) { + if (currentState_ == WifiProState::WIFI_NONET && WifiProUtils::IsUserSelectNetwork() && !isFirstDectectHasNet_) { WifiProChr::GetInstance().RecordReasonNotSwitchChrCnt(WIFIPRO_NONET_BEFORE_CONNECT); WIFI_LOGI("IsKeepCurrWifiConnected, user select and nonet."); return true; @@ -485,6 +485,14 @@ bool WifiProStateMachine::TryWifi2Wifi(const NetworkSelectionResult &networkSele ErrCode WifiProStateMachine::FullScan() { WIFI_LOGD("start Fullscan"); + int32_t signalLevel = WifiProUtils::GetSignalLevel(instId_); +#ifndef OHOS_ARCH_LITE + if (currentState_ == WifiProState::WIFI_HASNET && WifiConfigCenter::GetInstance().IsScreenLandscape() && + signalLevel >= SIG_LEVEL_2 && InLandscapeSwitchLimitList()) { + WIFI_LOGI("FullScan ScreenLandscape and InLandscapeSwitchLimitList."); + return WIFI_OPT_SUCCESS; + } +#endif IScanService *pScanService = WifiServiceManager::GetInstance().GetScanServiceInst(instId_); if (pScanService == nullptr) { WIFI_LOGI("TryStartScan, pService is nullptr."); @@ -518,7 +526,7 @@ bool WifiProStateMachine::InLandscapeSwitchLimitList() { #ifndef OHOS_ARCH_LITE std::vector specialList; - if (WifiSettings::GetInstance().GetPackageInfoByName("InLandscapeSwitchLimitList", specialList) != 0) { + if (WifiSettings::GetInstance().GetPackageInfoByName("LandscapeSwitchLimitList", specialList) != 0) { WIFI_LOGE("ProcessSwitchInfoRequest GetPackageInfoByName failed"); return false; } @@ -565,7 +573,7 @@ bool WifiProStateMachine::IsFirstConnectAndNonet() return true; } return currentState_ == WifiProState::WIFI_NONET && WifiProUtils::IsUserSelectNetwork() && - config.numAssociation <= 1 && isFirstNetDectect_; + config.numAssociation <= 1 && !isFirstDectectHasNet_; } /* --------------------------- state machine default state ------------------------------ */ WifiProStateMachine::DefaultState::DefaultState(WifiProStateMachine *pWifiProStateMachine) @@ -796,7 +804,7 @@ void WifiProStateMachine::WifiConnectedState::InitConnectedState() if (pWifiProStateMachine_->duanBandHandoverType_ == ROAM_SCENE) { pWifiProStateMachine_->duanBandHandoverType_ = 0; } - pWifiProStateMachine_->isFirstNetDectect_ = true; + pWifiProStateMachine_->isFirstDectectHasNet_ = false; } void WifiProStateMachine::WifiConnectedState::HandleHttpResult(const InternalMessagePtr msg) @@ -954,7 +962,7 @@ void WifiProStateMachine::WifiHasNetState::GoOutState() { WIFI_LOGI("WifiHasNetState GoOutState function."); pWifiProStateMachine_->StopTimer(EVENT_CMD_INTERNET_STATUS_DETECT_INTERVAL); - pWifiProStateMachine_->isFirstNetDectect_ = false; + pWifiProStateMachine_->isFirstDectectHasNet_ = true; return; } @@ -1269,7 +1277,6 @@ void WifiProStateMachine::WifiNoNetState::GoInState() void WifiProStateMachine::WifiNoNetState::GoOutState() { WIFI_LOGI("WifiNoNetState GoOutState function."); - pWifiProStateMachine_->isFirstNetDectect_ = false; } bool WifiProStateMachine::WifiNoNetState::ExecuteStateMsg(InternalMessagePtr msg) @@ -1428,7 +1435,6 @@ void WifiProStateMachine::WifiPortalState::GoInState() void WifiProStateMachine::WifiPortalState::GoOutState() { WIFI_LOGI("WifiPortalState GoOutState function."); - pWifiProStateMachine_->isFirstNetDectect_ = false; } bool WifiProStateMachine::WifiPortalState::ExecuteStateMsg(InternalMessagePtr msg) diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.h index 2e45bcfb551dabaefffa7a836607638c37e372fd..933f87b2d12931a639d33385ef4e459980c2c6f0 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine.h @@ -226,7 +226,7 @@ private: int32_t wiFiNoInternetReason_ { 0 }; bool disconnectToConnectedState_ { false }; bool isWifiProEnabled_ { true }; // enabled by default, it should be assigned according to the settings. - bool isFirstNetDectect_ { true }; + bool isFirstDectectHasNet_ { false }; std::string badBssid_ { 0 }; std::string badSsid_ { 0 }; WifiSwitchReason wifiSwitchReason_ { WifiSwitchReason::WIFI_SWITCH_REASON_DEFAULT }; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn index ae27191c749f0b61152e2115673af7fe2a983f7b..dafe53464b349e223c7c087ac635d1a0046a7c41 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/BUILD.gn @@ -126,6 +126,7 @@ if (defined(ohos_lite)) { "common_event_service:cesfwk_innerkits", "hilog:libhilog", "samgr:samgr_proxy", + "ipc:ipc_single", ] cflags = memory_optimization_cflags cflags_cc = memory_optimization_cflags_cc diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp index f4ba82b638e6822bd7e5fcc88e8e725397ba3ff0..fd2082f8b513043045e2862da57777e8c22ee464 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_interface.cpp @@ -65,6 +65,7 @@ ErrCode ScanInterface::UnInit() return WIFI_OPT_SUCCESS; } +// scanType takes precedence over externFlag, when scanType is not SCAN_DEFAULT, externFlag invalid ErrCode ScanInterface::Scan(bool externFlag, ScanType scanType) { WIFI_LOGI("Enter ScanInterface::Scan\n"); @@ -76,6 +77,7 @@ ErrCode ScanInterface::Scan(bool externFlag, ScanType scanType) return pScanService->Scan(externFlag ? ScanType::SCAN_TYPE_EXTERN : ScanType::SCAN_TYPE_NATIVE_EXTERN); } +// scanType takes precedence over externFlag, when scanType is not SCAN_DEFAULT, externFlag invalid ErrCode ScanInterface::ScanWithParam(const WifiScanParams &wifiScanParams, bool externFlag, ScanType scanType) { WIFI_LOGI("Enter ScanInterface::ScanWithParam\n"); @@ -250,4 +252,4 @@ ErrCode ScanInterface::ResetScanInterval() return WIFI_OPT_SUCCESS; } } // namespace Wifi -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp index 47ca23be1352d473bb0663f0ad8a4e0e6684606f..19b665b6b70dbc76c4c68997a27ce1602c34077c 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan/scan_state_machine.cpp @@ -250,8 +250,7 @@ void ScanStateMachine::InitState::HandleUpdateCountryCode(InternalMessagePtr msg WifiConfigCenter::GetInstance().GetStaIfaceName(), wifiCountryCode); if (result == WifiErrorNo::WIFI_HAL_OPT_OK) { WIFI_LOGI("update wifi country code sucess, wifiCountryCode=%{public}s", wifiCountryCode.c_str()); - WifiChannelHelper::GetInstance().UpdateValidChannels( - WifiConfigCenter::GetInstance().GetStaIfaceName(), pScanStateMachine->m_instId); + WifiChannelHelper::GetInstance().UpdateValidFreqs(); return; } WIFI_LOGE("update wifi country code fail, wifiCountryCode=%{public}s, ret=%{public}d", diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_sa/wifi_scan_mgr_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_sa/wifi_scan_mgr_service_impl.cpp index 4f5314c6021ead2b3ea1f4c655a842d8bef31670..31d3a769bfeda503770dadb3ab9515c1873bdc64 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_sa/wifi_scan_mgr_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan_sa/wifi_scan_mgr_service_impl.cpp @@ -79,6 +79,7 @@ void WifiScanMgrServiceImpl::OnStart() void WifiScanMgrServiceImpl::OnStop() { + std::lock_guard lock(g_scanMutex); mState = ServiceRunningState::STATE_NOT_START; mPublishFlag = false; WIFI_LOGI("Stop scan service!"); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp index 699844d4df5183fa106628e92820e9d4e019398e..69175302a2f438aff6f72d2ec28a77d8194ca160 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure/self_cure_state_machine.cpp @@ -1302,6 +1302,7 @@ void SelfCureStateMachine::InternetSelfCureState::SelfcureForMultiGateway(Intern return; } isUsedMultiGwSelfcure_ = true; + pSelfCureStateMachine_->UpdateSelfcureState(WIFI_CURE_RESET_LEVEL_MULTI_GATEWAY, true); std::string ipAddr = MultiGateway::GetInstance().GetGatewayIp(); std::string macString = ""; MultiGateway::GetInstance().GetNextGatewayMac(macString); @@ -1313,21 +1314,12 @@ void SelfCureStateMachine::InternetSelfCureState::SelfcureForMultiGateway(Intern } return; } + std::string ifaceName = WifiConfigCenter::GetInstance().GetStaIfaceName(); - if (MultiGateway::GetInstance().SetStaticArp(ifaceName, ipAddr, macString) != 0) { - WIFI_LOGE("SetStaticArp failed"); - if (lastMultiGwSelfFailedType_ != -1) { - SelectSelfCureByFailedReason(lastMultiGwSelfFailedType_); - } - return; - } - WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::MULTI_GATEWAY_SELFCURE)); - pSelfCureStateMachine_->UpdateSelfcureState(WIFI_CURE_RESET_LEVEL_MULTI_GATEWAY, true); if (!pSelfCureStateMachine_->IsHttpReachable()) { MultiGateway::GetInstance().DelStaticArp(ifaceName, ipAddr); pSelfCureStateMachine_->SendMessage(WIFI_CURE_CMD_MULTI_GATEWAY); } else { - WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::MULTI_GATEWAY_SELFCURE_SUCC)); pSelfCureStateMachine_->SwitchState(pSelfCureStateMachine_->pConnectedMonitorState_); } } @@ -1355,7 +1347,6 @@ void SelfCureStateMachine::InternetSelfCureState::SelfCureForRandMacReassoc(int WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo); int networkId = linkedInfo.networkId; WifiConfigCenter::GetInstance().SetLastNetworkId(networkId); - WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::RAND_MAC_REASSOC_SELFCURE)); IStaService *pStaService = WifiServiceManager::GetInstance().GetStaServiceInst(0); if (pStaService == nullptr) { WIFI_LOGE("Get pStaService failed!"); @@ -1546,8 +1537,6 @@ void SelfCureStateMachine::InternetSelfCureState::HandleHttpReachableAfterSelfCu WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::REASSOC_SELFCURE_SUCC)); } else if (currentCureLevel == WIFI_CURE_RESET_LEVEL_HIGH_RESET) { WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::RESET_SELFCURE_SUCC)); - } else if (currentCureLevel == WIFI_CURE_RESET_LEVEL_RAND_MAC_REASSOC) { - WriteWifiSelfcureHisysevent(static_cast(WifiSelfcureType::RAND_MAC_REASSOC_SELFCURE_SUCC)); } } @@ -3044,7 +3033,7 @@ void SelfCureStateMachine::HandleConnectFailed() WIFI_LOGE("%{public}s: GetDeviceConfig failed!.", __FUNCTION__); return; } - //Connect failed, updateSelfcureConnectHistoryInfo + // Connect failed, updateSelfcureConnectHistoryInfo WifiSelfCureHistoryInfo selfCureHistoryInfo; std::string internetSelfCureHistory = config.internetSelfCureHistory; SelfCureUtils::GetInstance().String2InternetSelfCureHistoryInfo(internetSelfCureHistory, selfCureHistoryInfo); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h index b33c8c96e293ab8999bdb63c1fe55c1a86132264..1decb262ef3988f12fe99ca1e8e6cba75f7335cb 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/ista_service.h @@ -395,6 +395,13 @@ public: */ virtual ErrCode DeliverStaIfaceData(const std::string ¤tMac) = 0; + /** + * @Description deliver mac + * + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + virtual ErrCode StartWifiDetection() = 0; + /** * @Description Deliver Audio State * diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp index 39d23e6da5e5b50af3c2197a2e5531cce27bbc94..48039cef4fc5602eaa1ecab5193a6097bfbb3bcc 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.cpp @@ -517,6 +517,15 @@ ErrCode StaInterface::EnableHiLinkHandshake(bool uiFlag, const WifiDeviceConfig return WIFI_OPT_SUCCESS; } +ErrCode StaInterface::StartWifiDetection() +{ + WIFI_LOGI("Enter StartWifiDetection"); + std::lock_guard lock(mutex); + CHECK_NULL_AND_RETURN(pStaService, WIFI_OPT_FAILED); + pStaService->StartWifiDetection(); + return WIFI_OPT_SUCCESS; +} + ErrCode StaInterface::DeliverStaIfaceData(const std::string ¤tMac) { WIFI_LOGI("Enter DeliverStaIfaceData"); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h index ed1c4c99002ddccd963e2566238d23b8552b9548..d41eccfac3992ac622e6e2b93b834f77ccf40f16 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface.h @@ -392,6 +392,13 @@ public: virtual ErrCode EnableHiLinkHandshake(bool uiFlag, const WifiDeviceConfig &config, const std::string &bssid) override; + /** + * @Description StartWifiDetection. + * + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + virtual ErrCode StartWifiDetection() override; + /** * @Description DeliverStaIfaceData. * diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp index 2834f50e9a8152d0cf045a5ef475d1ca9d127a0e..b0f184fb08606974b210576f6aa89a15052824ed 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.cpp @@ -701,7 +701,7 @@ ErrCode StaService::AllowAutoConnect(int32_t networkId, bool isAllowed) const if (!isAllowed) { WifiLinkedInfo linkedInfo; WifiConfigCenter::GetInstance().GetLinkedInfo(linkedInfo, m_instId); - if (linkedInfo.networkId != networkId) { + if (linkedInfo.networkId != networkId && pStaStateMachine->GetTargetNetworkId() != networkId) { WIFI_LOGI("AllowAutoConnect, networkid is not correct, linked networkid:%{public}d", linkedInfo.networkId); return WIFI_OPT_SUCCESS; } @@ -1022,6 +1022,13 @@ ErrCode StaService::EnableHiLinkHandshake(bool uiFlag, const WifiDeviceConfig &c return WIFI_OPT_SUCCESS; } +ErrCode StaService::StartWifiDetection() +{ + CHECK_NULL_AND_RETURN(pStaStateMachine, WIFI_OPT_FAILED); + pStaStateMachine->SendMessage(CMD_START_NETCHECK); + return WIFI_OPT_SUCCESS; +} + ErrCode StaService::DeliverStaIfaceData(const std::string ¤tMac) { CHECK_NULL_AND_RETURN(pStaStateMachine, WIFI_OPT_FAILED); @@ -1185,4 +1192,4 @@ void StaService::GetDetectNetState(OperateResState &state) pStaStateMachine->GetDetectNetState(state); } } // namespace Wifi -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h index b7e33d5c98378e3bd5cf7bc662056ef6f5058c71..686bfaa4db094e699a84f2aea994c5f9aa2fd124 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service.h @@ -390,6 +390,13 @@ public: */ virtual ErrCode EnableHiLinkHandshake(bool uiFlag, const WifiDeviceConfig &config, const std::string &cmd); + /** + * @Description start wifi detection + * + * @return success: WIFI_OPT_SUCCESS, failed: WIFI_OPT_FAILED + */ + virtual ErrCode StartWifiDetection(); + /** * @Description deliver mac * @@ -493,4 +500,4 @@ private: }; } // namespace Wifi } // namespace OHOS -#endif \ No newline at end of file +#endif diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp index 4b1b1963737e8ab0ef8098e56ee6247c5430017f..ca3f3283dc1be369401761e86bde73fb04e7d9ae 100755 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.cpp @@ -723,20 +723,6 @@ StaStateMachine::LinkState::~LinkState() void StaStateMachine::LinkState::GoInState() { WIFI_LOGI("LinkState GoInState function."); - int result = pStaStateMachine->RegisterDhcpCallBack(); - if (result != WIFI_OPT_SUCCESS) { - WIFI_LOGE("Register dhcp callback failed, result = %{public}d", result); - return; - } - RouterConfig routerConfig; - routerConfig.bIpv6 = true; - routerConfig.bIpv4 = false; - std::string ifaceName = WifiConfigCenter::GetInstance().GetStaIfaceName(pStaStateMachine->m_instId); - if (strncpy_s(routerConfig.ifname, sizeof(routerConfig.ifname), ifaceName.c_str(), ifaceName.length()) < 0) { - WIFI_LOGE("LinkState GoInState, copy ifaceName failed"); - return; - } - StartDhcpClient(routerConfig); return; } @@ -894,7 +880,7 @@ void StaStateMachine::LinkState::DealDisconnectEventInLinkState(InternalMessageP pStaStateMachine->SwitchState(pStaStateMachine->pSeparatedState); } else { //connecting to another network while already connected pStaStateMachine->mPortalUrl = ""; - pStaStateMachine->StopDhcp(true, false); + pStaStateMachine->StopDhcp(true, true); pStaStateMachine->SaveLinkstate(ConnState::DISCONNECTED, DetailedState::DISCONNECTED); pStaStateMachine->InvokeOnStaConnChanged(OperateResState::DISCONNECT_DISCONNECTED, pStaStateMachine->linkedInfo); @@ -1683,6 +1669,7 @@ void StaStateMachine::GetIpState::GoInState() pStaStateMachine->SwitchState(pStaStateMachine->pLinkedState); return; #endif + pStaStateMachine->StopDhcp(false, true); // stop previous dhcp ipv6 first #ifndef OHOS_ARCH_LITE if (pStaStateMachine->NetSupplierInfo != nullptr) { pStaStateMachine->NetSupplierInfo->isAvailable_ = true; @@ -1705,6 +1692,16 @@ void StaStateMachine::GetIpState::GoInState() if (ret == 0) { assignMethod = config.wifiIpConfig.assignMethod; } + bool isStaticIpv6 = false; + // static ipv6 does not need dhcp + WifiDeviceConfig wificonfig; + if (WifiSettings::GetInstance().GetDeviceConfig(pStaStateMachine->linkedInfo.networkId, wificonfig, + pStaStateMachine->m_instId) == 0 && + wificonfig.wifiIpConfig.assignMethod == AssignIpMethod::STATIC && + wificonfig.wifiIpConfig.staticIpAddress.ipAddress.address.family == 1) { + WIFI_LOGI("Static IPv6 stop DHCP.\n"); + isStaticIpv6 = true; + } if (assignMethod == AssignIpMethod::STATIC) { pStaStateMachine->currentTpType = config.wifiIpConfig.staticIpAddress.ipAddress.address.family; @@ -1716,6 +1713,7 @@ void StaStateMachine::GetIpState::GoInState() } } pStaStateMachine->HandlePreDhcpSetup(); + /* start dhcp */ do { int dhcpRet; std::string ifname = WifiConfigCenter::GetInstance().GetStaIfaceName(pStaStateMachine->m_instId); @@ -1728,7 +1726,7 @@ void StaStateMachine::GetIpState::GoInState() config.prohibitUseCacheIp = IsProhibitUseCacheIp(); } config.isStaticIpv4 = assignMethod == AssignIpMethod::STATIC; - config.bIpv6 = false; + config.bIpv6 = !isStaticIpv6; config.bSpecificNetwork = pStaStateMachine->IsSpecificNetwork(); if (strncpy_s(config.ifname, sizeof(config.ifname), ifname.c_str(), ifname.length()) != EOK) { break; @@ -3409,8 +3407,12 @@ void StaStateMachine::DhcpResultNotify::DhcpResultNotifyEvent(DhcpReturnCode res void StaStateMachine::DhcpResultNotify::TryToCloseDhcpClient(int iptype) { std::string ifname = WifiConfigCenter::GetInstance().GetStaIfaceName(pStaStateMachine->m_instId); - if (iptype == 1) { - WIFI_LOGI("TryToCloseDhcpClient iptype ipv6 return"); + WifiDeviceConfig config; + int ret = WifiSettings::GetInstance().GetDeviceConfig(pStaStateMachine->linkedInfo.networkId, + config, pStaStateMachine->m_instId); + int family = config.wifiIpConfig.staticIpAddress.ipAddress.address.family; + if (iptype == 1 && (config.wifiIpConfig.assignMethod != AssignIpMethod::STATIC || family == 0 || ret != 0)) { + WIFI_LOGI("TryToCloseDhcpClient DHCP or StaticV4: iptype ipv6 return"); return; } @@ -5383,5 +5385,10 @@ void StaStateMachine::LogSignalInfo(WifiSignalPollInfo &signalInfo) linkedInfo.maxSupportedTxLinkSpeed, linkedInfo.connState, linkedInfo.detailedState, lastSignalLevel_, signalInfo.chloadSelf, signalInfo.c0Rssi, signalInfo.c1Rssi); } + +int32_t StaStateMachine::GetTargetNetworkId() +{ + return targetNetworkId_; +} } // namespace Wifi } // namespace OHOS diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h index d65f105a94f125c68a9be90ac9db358656d22531..7166ec7b00071f8482ad3efc442bdcd58fd5365b 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine.h @@ -504,6 +504,7 @@ public: */ void HandleForegroundAppChangedAction(InternalMessagePtr msg); #endif + int32_t GetTargetNetworkId(); /* ------------------ state machine private function ----------------- */ private: /** diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn index 9d6bfaf5901b6c101c9447d734fde57ee3ec44ea..864ffb44614afa68d6e4b709c30ffe56494af0b5 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn @@ -141,6 +141,7 @@ ohos_static_library("wifi_telephony_utils") { ] external_deps = [ "hilog:libhilog", + "ipc:ipc_single", ] defines = [] diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_mgr_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_mgr_service_impl.cpp index e6506a1157a66458bb4ab5a7d3457815524f8e94..4f6c8b9f214bc81c8af3de4ce02fc24abd87fe73 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_mgr_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_mgr_service_impl.cpp @@ -78,6 +78,7 @@ void WifiDeviceMgrServiceImpl::OnStart() void WifiDeviceMgrServiceImpl::OnStop() { + std::lock_guard lock(g_initMutex); mState = ServiceRunningState::STATE_NOT_START; mPublishFlag = false; WIFI_LOGI("Stop sta service!"); diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.cpp index fa6a43c279e5781a034b2a2cecd3a821229784f9..e6172735b8f74138195eb019e682bc8f5d8a9e68 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.cpp @@ -349,13 +349,13 @@ static bool CheckOriSsidLength(const WifiDeviceConfig &config) bool WifiDeviceServiceImpl::CheckConfigPwd(const WifiDeviceConfig &config) { - if (config.ssid.length() <= 0 || (config.keyMgmt.length()) <= 0) { + if ((config.ssid.length() <= 0) || (config.keyMgmt.length()) <= 0) { WIFI_LOGE("CheckConfigPwd: invalid ssid or keyMgmt!"); return false; } if (config.ssid.length() > DEVICE_NAME_LENGTH) { if (!CheckOriSsidLength(config)) { - LOGE("CheckConfigPwd: invalid ssid"); + WIFI_LOGE("CheckConfigPwd: invalid ssid"); return false; } } @@ -1405,9 +1405,11 @@ ErrCode WifiDeviceServiceImpl::GetLinkedInfo(WifiLinkedInfo &info) if (VerifyGetLinkedInfofoPermission() != WIFI_OPT_SUCCESS) { return WIFI_OPT_PERMISSION_DENIED; } + if (!IsStaServiceRunning()) { return WIFI_OPT_STA_NOT_OPENED; } + WifiConfigCenter::GetInstance().GetLinkedInfo(info, m_instId); UpdateWifiLinkInfo(info); return WIFI_OPT_SUCCESS; @@ -1425,6 +1427,12 @@ ErrCode WifiDeviceServiceImpl::GetMultiLinkedInfo(std::vector &m if (!IsStaServiceRunning()) { return WIFI_OPT_STA_NOT_OPENED; } + WifiLinkedInfo info; + WifiConfigCenter::GetInstance().GetLinkedInfo(info, m_instId); + if (info.wifiLinkType != WifiLinkType::WIFI7_EMLSR) { + WIFI_LOGI("GetMultiLinkedInfo failed, not emlsr connected"); + return WIFI_OPT_FAILED; + } if (WifiConfigCenter::GetInstance().GetMloLinkedInfo(mloLinkInfo, m_instId) < 0) { WIFI_LOGE("GetMultiLinkedInfo failed, not find valid mloLinkInfo"); return WIFI_OPT_FAILED; @@ -1988,7 +1996,8 @@ ErrCode WifiDeviceServiceImpl::FactoryReset() IWifiProService *pWifiProService = WifiServiceManager::GetInstance().GetWifiProServiceInst(m_instId); if (pWifiProService != nullptr) { WifiDeviceConfig config; - pWifiProService->OnWifiDeviceConfigChange(static_cast(ConfigChange::CONFIG_REMOVE), config, true); + pWifiProService->OnWifiDeviceConfigChange(static_cast(ConfigChange::CONFIG_REMOVE), + config, true); } #endif /* p2p */ @@ -2002,6 +2011,33 @@ ErrCode WifiDeviceServiceImpl::FactoryReset() return WIFI_OPT_SUCCESS; } +ErrCode WifiDeviceServiceImpl::StartWifiDetection() +{ +#ifndef OHOS_ARCH_LITE + WIFI_LOGI("StartWifiDetection(), pid:%{public}d, uid:%{public}d, BundleName:%{public}s.", + GetCallingPid(), GetCallingUid(), GetBundleName().c_str()); +#endif + if (!WifiAuthCenter::IsSystemAccess()) { + WIFI_LOGE("%{public}s NOT System APP, PERMISSION_DENIED!", __FUNCTION__); + return WIFI_OPT_NON_SYSTEMAPP; + } + if (WifiPermissionUtils::VerifySetWifiInfoPermission() == PERMISSION_DENIED) { + WIFI_LOGE("%{public}s set wifi info PERMISSION_DENIED!", __FUNCTION__); + return WIFI_OPT_PERMISSION_DENIED; + } + if (WifiPermissionUtils::VerifyWifiConnectionPermission() == PERMISSION_DENIED) { + WIFI_LOGE("%{public}s manage wifi PERMISSION_DENIED!", __FUNCTION__); + return WIFI_OPT_PERMISSION_DENIED; + } + IStaService *pService = WifiServiceManager::GetInstance().GetStaServiceInst(m_instId); + if (pService == nullptr) { + WIFI_LOGE("pService is nullptr!"); + return WIFI_OPT_STA_NOT_OPENED; + } + pService->StartWifiDetection(); + return WIFI_OPT_SUCCESS; +} + #ifndef OHOS_ARCH_LITE ErrCode WifiDeviceServiceImpl::FactoryResetNotify() { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.h index 13a23ef9a61c4023dee0e0a93413aa18fdedcbf3..4a8bcad079ce69b11c5385197abd0fd06f4f947a 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_service_impl.h @@ -68,7 +68,7 @@ public: ErrCode RemoveDevice(int networkId) override; ErrCode RemoveAllDevice() override; - + ErrCode SetTxPower(int power) override; ErrCode SetDpiMarkRule(const std::string &ifaceName, int uid, int protocol, int enable) override; @@ -109,10 +109,10 @@ public: ErrCode GetLinkedInfo(WifiLinkedInfo &info) override; - ErrCode GetSignalPollInfoArray(std::vector &wifiSignalPollInfos, int length) override; - ErrCode GetMultiLinkedInfo(std::vector &mloLinkInfo) override; + ErrCode GetSignalPollInfoArray(std::vector &wifiSignalPollInfos, int length) override; + ErrCode GetDisconnectedReason(DisconnectedReason &reason) override; ErrCode GetIpInfo(IpInfo &info) override; @@ -181,6 +181,8 @@ public: ErrCode FactoryReset() override; + ErrCode StartWifiDetection() override; + ErrCode ReceiveNetworkControlInfo(const WifiNetworkControlInfo& networkControlInfo) override; ErrCode LimitSpeed(const int controlId, const int limitMode) override; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_stub.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_stub.cpp index ad148cb114ff2a8ee8331f659615a8d2a31ed596..b74e96123e12f6245eb4c173d4961630cf810810 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_stub.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/wifi_device_stub.cpp @@ -131,10 +131,10 @@ void WifiDeviceStub::InitHandleMapEx2() MessageParcel &data, MessageParcel &reply) { OnSetDpiMarkRule(code, data, reply); }; handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_FEATURE_SUPPORTED)] = [this](uint32_t code, MessageParcel &data, MessageParcel &reply) { OnIsFeatureSupported(code, data, reply); }; - handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_NET_CONTROL_INFO)] = [this](uint32_t code, - MessageParcel &data, MessageParcel &reply) { OnReceiveNetworkControlInfo(code, data, reply); }; handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_NETWORK_LAG_INFO)] = [this](uint32_t code, MessageParcel &data, MessageParcel &reply) { OnUpdateNetworkLagInfo(code, data, reply); }; + handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_NET_CONTROL_INFO)] = [this](uint32_t code, + MessageParcel &data, MessageParcel &reply) { OnReceiveNetworkControlInfo(code, data, reply); }; handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_FETCH_SIGNALINFO_VOWIFI)] = [this](uint32_t code, MessageParcel &data, MessageParcel &reply) { OnFetchWifiSignalInfoForVoWiFi(code, data, reply); }; handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_SUPPORT_VOWIFI_DETECT)] = [this] @@ -147,10 +147,12 @@ void WifiDeviceStub::InitHandleMapEx2() (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnSetVoWifiDetectPeriod(code, data, reply); }; handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_VOWIFI_DETECT_PERIOD)] = [this] (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetVoWifiDetectPeriod(code, data, reply); }; - handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_SIGNALPOLL_INFO_ARRAY)] = [this] - (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetSignalPollInfoArray(code, data, reply); }; handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_MULTI_LINKED_INFO)] = [this] (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetMultiLinkedInfo(code, data, reply); }; + handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_GET_SIGNALPOLL_INFO_ARRAY)] = [this] + (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnGetSignalPollInfoArray(code, data, reply); }; + handleFuncMap[static_cast(DevInterfaceCode::WIFI_SVR_CMD_START_WIFI_DETECTION)] = [this] + (uint32_t code, MessageParcel &data, MessageParcel &reply) { OnStartWifiDetection(code, data, reply); }; } void WifiDeviceStub::InitHandleMap() @@ -475,6 +477,7 @@ void WifiDeviceStub::ReadWifiDeviceConfig(MessageParcel &data, WifiDeviceConfig config.wifiWapiConfig.wapiPskType = data.ReadInt32(); config.wifiWapiConfig.wapiAsCertData = data.ReadString(); config.wifiWapiConfig.wapiUserCertData = data.ReadString(); + config.isAllowAutoConnect = data.ReadBool(); return; } @@ -653,7 +656,7 @@ void WifiDeviceStub::SendDeviceConfig(int contentSize, std::vector lock(powermgrEventMutex); + if (powerMgrId != 0) { + WifiTimer::GetInstance()->UnRegister(powerMgrId); + } if (wifiPowermgrEventSubsciber_) { return; } @@ -1000,14 +1002,20 @@ void WifiEventSubscriberManager::RegisterPowermgrEvent() if (!EventFwk::CommonEventManager::SubscribeCommonEvent(wifiPowermgrEventSubsciber_)) { WIFI_LOGE("Powermgr SubscribeCommonEvent() failed"); wifiPowermgrEventSubsciber_ = nullptr; + WifiTimer::TimerCallback timeoutCallBack = std::bind(&WifiEventSubscriberManager::RegisterPowermgrEvent, this); + WifiTimer::GetInstance()->Register(timeoutCallBack, powerMgrId, TIMEOUT_EVENT_SUBSCRIBER, false); + WIFI_LOGI("RegisterPowermgrEvent retry, powerMgrId = %{public}u", powerMgrId); } else { - WIFI_LOGI("RegisterCesEvent success"); + WIFI_LOGI("RegisterPowermgrEvent success"); } } void WifiEventSubscriberManager::UnRegisterPowermgrEvent() { std::unique_lock lock(powermgrEventMutex); + if (powerMgrId != 0) { + WifiTimer::GetInstance()->UnRegister(powerMgrId); + } if (!wifiPowermgrEventSubsciber_) { return; } @@ -1034,14 +1042,13 @@ void PowermgrEventSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEventDa std::string action = eventData.GetWant().GetAction(); #ifdef FEATURE_HPF_SUPPORT if (action == COMMON_EVENT_POWER_MANAGER_STATE_CHANGED) { - WIFI_LOGI("Receive power manager state Event: %{public}s", eventData.GetCode()); + WIFI_LOGI("Receive power manager state Event: %{public}d", eventData.GetCode()); for (int i = 0; i < STA_INSTANCE_MAX_NUM; ++i) { WifiManager::GetInstance().InstallPacketFilterProgram(eventData.GetCode(), i); } } #endif } - #endif #ifdef HAS_NETMANAGER_EVENT_PART void WifiEventSubscriberManager::RegisterNetmgrEvent() @@ -1100,7 +1107,7 @@ NetmgrEventSubscriber::~NetmgrEventSubscriber() void NetmgrEventSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEventData &eventData) { - int bgContinuousTaskState = eventData.GetCode(); + uint32_t bgContinuousTaskState = eventData.GetCode(); WIFI_LOGI("NetmgrEventSubscriber OnReceiveEvent by BgTaskAware %{public}d", bgContinuousTaskState); IStaService *pService = WifiServiceManager::GetInstance().GetStaServiceInst(); if (pService == nullptr) { @@ -1367,13 +1374,17 @@ SettingsEnterSubscriber::SettingsEnterSubscriber( void SettingsEnterSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &eventData) { const auto &action = eventData.GetWant().GetAction(); - WIFI_LOGI("SettingsEnterSubscriber OnReceiveEvent: %{public}s", action.c_str()); + bool isSettingsEnter = eventData.GetWant().GetBoolParam(WLAN_PAGE_ENTER, false); + WIFI_LOGI("SettingsEnterSubscriber OnReceiveEvent: %{public}s, isSettingsEnter : %{public}d", + action.c_str(), isSettingsEnter); if (action == ENTER_SETTINGS) { - bool isSettingsEnter = eventData.GetWant().GetBoolParam(WLAN_PAGE_ENTER, false); - BlockConnectService::GetInstance().OnReceiveSettingsEnterEvent(isSettingsEnter); - IEnhanceService *pEnhanceService = WifiServiceManager::GetInstance().GetEnhanceServiceInst(); - if (pEnhanceService != nullptr) { - pEnhanceService->OnSettingsWlanEnterReceive(); + WifiConfigCenter::GetInstance().SetWlanPage(isSettingsEnter); + if (isSettingsEnter) { + BlockConnectService::GetInstance().OnReceiveSettingsEnterEvent(isSettingsEnter); + IEnhanceService *pEnhanceService = WifiServiceManager::GetInstance().GetEnhanceServiceInst(); + if (pEnhanceService != nullptr) { + pEnhanceService->OnSettingsWlanEnterReceive(); + } } } } @@ -1599,6 +1610,7 @@ int NetworkConnSubscriber::NetCapabilitiesChange(sptr lock(cellularObserverLock_); if (cellularStateObserver_ == nullptr) { cellularStateObserver_ = sptr::MakeSptr(); } else { @@ -1620,6 +1632,7 @@ void WifiEventSubscriberManager::RegisterCellularStateObserver() void WifiEventSubscriberManager::UnRegisterCellularStateObserver() { + std::lock_guard lock(cellularObserverLock_); if (cellularStateObserver_ != nullptr) { uint32_t telephonyObserverMask = Telephony::TelephonyObserverBroker::OBSERVER_MASK_CELL_INFO; for (int32_t i = 0; i < simCount_; i++) { @@ -1646,4 +1659,4 @@ void CellularStateObserver::OnCellInfoUpdated(int32_t slotId, const std::vector< #endif } // namespace Wifi } // namespace OHOS -#endif +#endif \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_event_subscriber_manager.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_event_subscriber_manager.h index 1d86fc0931688ccfd75046220013ba9b87e9cafc..b7cf2bb6dc45d0d3705c2e80711b6010c60ec723 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_event_subscriber_manager.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_event_subscriber_manager.h @@ -198,6 +198,7 @@ private: void UnRegisterPowermgrEvent(); std::shared_ptr wifiPowermgrEventSubsciber_ = nullptr; std::mutex powermgrEventMutex; + uint32_t powerMgrId{0}; #endif void UnRegisterCesEvent(); void UnRegisterLocationEvent(); @@ -287,10 +288,11 @@ private: #ifdef FEATURE_AUTOOPEN_SPEC_LOC_SUPPORT sptr cellularStateObserver_ { nullptr }; int32_t simCount_ { 0 }; + std::mutex cellularObserverLock_; #endif }; } // namespace Wifi } // namespace OHOS #endif -#endif // OHOS_WIFI_EVENT_SUBSCRIBER_MANAGER_H +#endif // OHOS_WIFI_EVENT_SUBSCRIBER_MANAGER_H \ No newline at end of file diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.cpp index c10149183456061fc7be0a09a8f244aae1f32416..38bcf6c51772949723abf6b77050a4ba7eba5576 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * 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 diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.h b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.h index 2b27b2b1854b6a5143bccb06a6886e83b72c00c2..b871408a062c58ee4c065e6536c23b9dfeb19c7f 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_msdp_state_listener.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * 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 diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_scan_manager.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_scan_manager.cpp index 20e1c8661e8952021146a9b7139fe3fbb1a0b8a8..3f08ca8376061631fbd73e7feec24d547f711d7d 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_scan_manager.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/wifi_scan_manager.cpp @@ -237,12 +237,6 @@ void WifiScanManager::DealScanFinished(int state, int instId) void WifiScanManager::DealScanInfoNotify(std::vector &results, int instId) { - bool autoConnectEnable = WifiConfigCenter::GetInstance().GetAutoConnect(); - if (!autoConnectEnable) { - WIFI_LOGI("DealScanInfoNotify: not auto connect"); - return; - } - if (WifiConfigCenter::GetInstance().GetWifiMidState(instId) == WifiOprMidState::RUNNING) { IStaService *pService = WifiServiceManager::GetInstance().GetStaServiceInst(instId); if (pService != nullptr) { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.cpp index 5128ea9790f85e666200a8d37522b416bef94899..c6497543cc3249b4ba53ec0853b60d47061c0367 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.cpp @@ -90,6 +90,9 @@ int WifiConfigCenter::Init() std::unique_ptr& WifiConfigCenter::GetWifiScanConfig() { + if (wifiScanConfig == nullptr) { + wifiScanConfig = std::make_unique(); + } return wifiScanConfig; } @@ -1049,6 +1052,16 @@ int WifiConfigCenter::GetScreenState() const return mScreenState.load(); } +void WifiConfigCenter::SetWlanPage(bool isWlanPage) +{ + isWlanPage_.store(isWlanPage); +} + +bool WifiConfigCenter::IsWlanPage() const +{ + return isWlanPage_.load(); +} + void WifiConfigCenter::SetThermalLevel(const int &level) { mThermalLevel = level; @@ -1544,22 +1557,6 @@ void WifiConfigCenter::SetFastScan(bool fastScan) std::unique_lock lock(mScanMutex); isNeedFastScan = fastScan; } - -void WifiConfigCenter::SetAutoConnect(bool autoConnectEnable) -{ - if (GetDeviceType() != ProductDeviceType::WEARABLE) { - LOGD("SetAutoConnect not wearable device"); - return; - } - - LOGI("SetAutoConnect autoConnectEnable:%{public}d", autoConnectEnable); - autoConnectEnable_.store(autoConnectEnable); -} - -bool WifiConfigCenter::GetAutoConnect() -{ - return autoConnectEnable_.load(); -} int WifiConfigCenter::GetLocalOnlyHotspotConfig(HotspotConfig &hotspotConfig) { diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.h b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.h index a6ad7035e827779dcc0030a1554a1c10f8613a2f..84e3b0d55ce6bcdf31e416f90eec65003ec3e292 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.h +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_config_center.h @@ -282,6 +282,10 @@ public: int GetScreenState() const; + void SetWlanPage(bool isWlanPage); + + bool IsWlanPage() const; + void SetThermalLevel(const int &level); int GetThermalLevel() const; @@ -360,9 +364,6 @@ public: bool IsNeedFastScan(void); void SetFastScan(bool fastScan); - void SetAutoConnect(bool autoConnectEnable); - - bool GetAutoConnect(); #ifndef OHOS_ARCH_LITE /** * @Description set screen state @@ -409,7 +410,6 @@ private: private: // STA std::mutex mStaMutex; - std::atomic autoConnectEnable_ {true}; std::atomic mWifiSelfcureReset {false}; std::atomic mWifiSelfcureResetEntered {false}; std::atomic mLastNetworkId {INVALID_NETWORK_ID}; @@ -479,6 +479,7 @@ private: // COMMON std::atomic mIsSupportCoex {false}; std::atomic mScreenState {MODE_STATE_DEFAULT}; + std::atomic isWlanPage_{false}; std::atomic mThermalLevel {static_cast(ThermalLevel::NORMAL)}; std::atomic mPowerIdelState {MODE_STATE_CLOSE}; std::atomic mGnssFixState {MODE_STATE_CLOSE}; diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp index cb8b2d473e3a598e333e09a7230ffb1821d35065..b04b33842e8e03b9c3aaa5defeb801ccfe291d6b 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/config/wifi_settings.cpp @@ -806,6 +806,10 @@ void WifiSettings::SetKeyMgmtBitset(WifiDeviceConfig &config) index = FindKeyMgmtPosition(KEY_MGMT_SAE); config.keyMgmtBitset |= (1 << index); } + if (config.keyMgmt == KEY_MGMT_SAE) { + index = FindKeyMgmtPosition(KEY_MGMT_WPA_PSK); + config.keyMgmtBitset |= (1 << index); + } } void WifiSettings::GetAllSuitableEncryption(const WifiDeviceConfig &config, diff --git a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/ip_tools.cpp b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/ip_tools.cpp index 1a0b0f429b47306452bce61b330161f6246d48ff..1c4f3a762b1d07266ca2fd4ec218345e008ccd4e 100644 --- a/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/ip_tools.cpp +++ b/wifi/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/ip_tools.cpp @@ -301,8 +301,8 @@ std::string IpTools::ConvertIpv6AddressToCompleted(const std::string &address) if (seg.empty()) { seg = "0"; } - unsigned int num = std::stoul(seg, nullptr, 16); - stream << std::setw(bitNum) << std::setfill('0') << std::hex << num; + int value = CheckDataLegalHex(seg); + stream << std::setw(bitNum) << std::setfill('0') << std::hex << value; } return stream.str(); } diff --git a/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.cpp b/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.cpp index 2c3247c9e76f75327f39d46eed3c7520ddd169b2..56766ab01dcc43c6e3b78a5c86fc0262ae9fd038 100644 --- a/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.cpp +++ b/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.cpp @@ -35,12 +35,6 @@ int32_t NetConnClient::RegisterNetSupplierCallback(uint32_t supplierId, const sp return NETMANAGER; } -int32_t NetConnClient::RegisterNetConnCallback(const sptr &netSpecifier, - const sptr callback, const uint32_t &timeoutMS) -{ - return NETMANAGER; -} - int32_t NetConnClient::UpdateNetSupplierInfo(uint32_t supplierId, const sptr &netSupplierInfo) { return NETMANAGER; diff --git a/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.h b/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.h index 61adb6d0fce08be779bf4d5ff01b22723581c2b9..88aab09c4fdef25d7f13f89dfa699f700e887bdc 100644 --- a/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.h +++ b/wifi/test/fuzztest/fuzz_common_func/mock_netconn_client.h @@ -31,9 +31,6 @@ public: int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr &callback); - int32_t RegisterNetConnCallback(const sptr &netSpecifier, const sptr callback, - const uint32_t &timeoutMS); - int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr &netSupplierInfo); int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr &netLinkInfo); diff --git a/wifi/test/fuzztest/fuzz_common_func/mock_wifi_ap_service.h b/wifi/test/fuzztest/fuzz_common_func/mock_wifi_ap_service.h index 8ade16609c945a0797a9b20257b1fe7a88860be7..89c4566d9f1b83bdf3f64d3e24feb0d9395205d1 100644 --- a/wifi/test/fuzztest/fuzz_common_func/mock_wifi_ap_service.h +++ b/wifi/test/fuzztest/fuzz_common_func/mock_wifi_ap_service.h @@ -48,8 +48,8 @@ public: class MockApStartedState : public ApStartedState { public: - MockApStartedState(ApStateMachine &apStateMachine, ApConfigUse &apConfigUse, ApMonitor &apMonitor) - : ApStartedState(apStateMachine, apConfigUse, apMonitor) + MockApStartedState(ApStateMachine &apStateMachine, ApMonitor &apMonitor) + : ApStartedState(apStateMachine, apMonitor) {} void GoInState(); void GoOutState(); @@ -67,8 +67,6 @@ public: ErrCode DelBlockList(const StationInfo &stationInfo); ErrCode SetHotspotConfig(const HotspotConfig &hotspotConfig); ErrCode DisconnetStation(const StationInfo &stationInfo); - ErrCode GetValidBands(std::vector &bands); - ErrCode GetValidChannels(BandType band, std::vector &validchannel); ErrCode RegisterApServiceCallbacks(const IApServiceCallbacks &callbacks); }; @@ -127,7 +125,7 @@ public: MockPendant() : mockApRootState(), mockApIdleState(mockApStateMachine), - mockApStartedState(mockApStateMachine, mockApConfigUse, mockApMonitor), + mockApStartedState(mockApStateMachine, mockApMonitor), mockApService(mockApStateMachine, mockApStartedState), mockApStateMachine( mockApStationsManager, mockApRootState, mockApIdleState, mockApStartedState, mockApMonitor), diff --git a/wifi/test/fuzztest/wifi_sta/enablep2p_fuzzer/BUILD.gn b/wifi/test/fuzztest/wifi_sta/enablep2p_fuzzer/BUILD.gn index 20fd08d40f4a4ab2ce88c1907223cbc4aa7820b6..9587e9aa43fbdf753d6596fce37cf7c3b121c2d4 100644 --- a/wifi/test/fuzztest/wifi_sta/enablep2p_fuzzer/BUILD.gn +++ b/wifi/test/fuzztest/wifi_sta/enablep2p_fuzzer/BUILD.gn @@ -92,7 +92,6 @@ ohos_fuzztest("EnableP2pFuzzTest") { } sources = [ - "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_monitor.cpp", @@ -107,6 +106,7 @@ ohos_fuzztest("EnableP2pFuzzTest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_death_recipient.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_service_impl.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap_sa/wifi_hotspot_stub.cpp", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/app_network_speed_limit/app_network_speed_limit_service.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/app_network_speed_limit/speed_limit_configs_writer.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/block_connect_service.cpp", diff --git a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/BUILD.gn b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/BUILD.gn index e2e9716d10218cc866aee2960c51c133efdb737d..3c1a3fc73fb185bde662c2f2cb74bbddf7471424 100644 --- a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/BUILD.gn +++ b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/BUILD.gn @@ -69,7 +69,6 @@ ohos_fuzztest("WifiApFuzzTest") { sources = [ "$WIFI_ROOT_DIR/base/utils/xml_parser.cpp", "$WIFI_ROOT_DIR/frameworks/native/src/wifi_p2p_msg.cpp", - "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_interface.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_monitor.cpp", @@ -80,6 +79,7 @@ ohos_fuzztest("WifiApFuzzTest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_stations_manager.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/wifi_ap_nat_manager.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_network_monitor.cpp", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_cmd_client.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/base_address.cpp", diff --git a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp index 6617b3931c2756c209c44307caceafbec44d2aef..f451040618defe4c72cbf262a0374661ec298112 100644 --- a/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifiap_fuzzer/wifiap_fuzzer.cpp @@ -250,21 +250,6 @@ void GetStationListFuzzTest(const uint8_t* data, size_t size) pApInterface->GetStationList(result); } -void GetValidBandsFuzzTest(const uint8_t* data, size_t size) -{ - std::vector bands; - pApService->GetValidBands(bands); - pApInterface->GetValidBands(bands); -} - -void GetValidChannelsFuzzTest(const uint8_t* data, size_t size) -{ - BandType bandType = static_cast(static_cast(data[0]) % SIX); - std::vector validChannel; - pApService->GetValidChannels(bandType, validChannel); - pApInterface->GetValidChannels(bandType, validChannel); -} - void RegisterApServiceCallbacksFuzzTest(const uint8_t* data, size_t size) { IApServiceCallbacks callbacks; @@ -362,8 +347,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Wifi::DelBlockListFuzzTest(data, size); OHOS::Wifi::DisconnetStationFuzzTest(data, size); OHOS::Wifi::GetStationListFuzzTest(data, size); - OHOS::Wifi::GetValidBandsFuzzTest(data, size); - OHOS::Wifi::GetValidChannelsFuzzTest(data, size); OHOS::Wifi::RegisterApServiceCallbacksFuzzTest(data, size); OHOS::Wifi::GetSupportedPowerModelFuzzTest(data, size); OHOS::Wifi::GetPowerModelFuzzTest(data, size); diff --git a/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp index e16a36391d481a57324385c2f67640e5ea19cdb3..ebd3c88a22e016f27890565c7a0ffb7d1e103223 100644 --- a/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifidevicestub_fuzzer/wifidevicestub_fuzzer.cpp @@ -640,6 +640,18 @@ void OnEnableHiLinkHandshakeFuzzTest(const uint8_t* data, size_t size) OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_IS_HILINK_CONNECT), datas); } +void OnStartWifiDetectionFuzzTest(const uint8_t* data, size_t size) +{ + MessageParcel datas; + if (!datas.WriteInterfaceToken(FORMMGR_INTERFACE_TOKEN)) { + LOGE("WriteInterfaceToken failed!"); + return; + } + datas.WriteInt32(0); + datas.WriteBuffer(data, size); + OnRemoteRequest(static_cast(DevInterfaceCode::WIFI_SVR_CMD_START_WIFI_DETECTION), datas); +} + void OnSetSatelliteStateFuzzTest(const uint8_t* data, size_t size) { MessageParcel datas; @@ -1039,6 +1051,11 @@ void EnableHiLinkHandshakeTest(const uint8_t* data, size_t size) pWifiDeviceServiceImpl->EnableHiLinkHandshake(uiFlag, bssid, config); } +void StartWifiDetectionTest(const uint8_t* data, size_t size) +{ + pWifiDeviceServiceImpl->StartWifiDetection(); +} + void RegisterFilterBuilderTest(const uint8_t* data, size_t size) { FilterTag filterTag = static_cast(static_cast(data[0]) % FIVE); @@ -1203,6 +1220,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Wifi::OnGetChangeDeviceConfigFuzzTest(data, size); OHOS::Wifi::OnLimitSpeedFuzzTest(data, size); OHOS::Wifi::OnEnableHiLinkHandshakeFuzzTest(data, size); + OHOS::Wifi::OnStartWifiDetectionFuzzTest(data, size); OHOS::Wifi::OnGetWifiDetailStateFuzzTest(data, size); OHOS::Wifi::OnSetTxPowerFuzzTest(data, size); OHOS::Wifi::OnSetSatelliteStateFuzzTest(data, size); @@ -1227,6 +1245,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) OHOS::Wifi::CheckCanEnableWifiTest(data, size); OHOS::Wifi::HilinkGetMacAddressTest(data, size); OHOS::Wifi::EnableHiLinkHandshakeTest(data, size); + OHOS::Wifi::StartWifiDetectionTest(data, size); OHOS::Wifi::RegisterFilterBuilderTest(data, size); OHOS::Wifi::OnSetDpiMarkRuleTest(data, size); OHOS::Wifi::OnGetDeviceConfigTest(data, size); diff --git a/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/BUILD.gn b/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/BUILD.gn index 4abeaf3582c19b2a838f2820d117d0bac1138c70..a75de28fcd2c1cb1a1b6baab604b303112a54e98 100644 --- a/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/BUILD.gn +++ b/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/BUILD.gn @@ -23,7 +23,6 @@ ohos_fuzztest("WifiHotspotImplFuzzTest") { "$WIFI_ROOT_DIR/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer" include_dirs = [ - "$WIFI_ROOT_DIR/base/utils", "$WIFI_ROOT_DIR/interfaces/inner_api", "$WIFI_ROOT_DIR/frameworks/native/interfaces", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/include", @@ -81,6 +80,7 @@ ohos_fuzztest("WifiHotspotImplFuzzTest") { sources = [ "$WIFI_ROOT_DIR/test/fuzztest/fuzz_common_func/mock_auth_center.cpp", "$WIFI_ROOT_DIR/test/fuzztest/fuzz_common_func/mock_netconn_client.cpp", + "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.cpp", "wifihotspotimpl_fuzzer.cpp", ] @@ -119,6 +119,8 @@ ohos_fuzztest("WifiHotspotImplFuzzTest") { "samgr:samgr_proxy", "time_service:time_client", "window_manager:libdm_lite", + "googletest:gmock_main", + "googletest:gtest_main", ] part_name = "wifi" diff --git a/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp index 3968f54a2bf3833123d021b0e255a28a0379ec38..468ec8b7cc8b7bdad0e2fc3a19f82be9177ab4fa 100644 --- a/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifihotspotimpl_fuzzer/wifihotspotimpl_fuzzer.cpp @@ -150,15 +150,14 @@ void IsValidHotspotConfigFuzzTest(const uint8_t* data, size_t size) HotspotConfig cfg; HotspotConfig cfgFromCenter; std::vector bandsFromCenter; - ChannelsTable channInfoFromCenter; cfg.SetIpAddress("192.168.8.100"); cfg.SetMaxConn(MAX_AP_CONN + 1); cfg.SetSecurityType(KeyMgmt::NONE); cfg.SetPreSharedKey(std::string(reinterpret_cast(data), size)); - pWifiHotspotServiceImpl->IsValidHotspotConfig(cfg, cfgFromCenter, bandsFromCenter, channInfoFromCenter); + pWifiHotspotServiceImpl->IsValidHotspotConfig(cfg, cfgFromCenter, bandsFromCenter); cfg.SetSecurityType(KeyMgmt::WPA_PSK); - pWifiHotspotServiceImpl->IsValidHotspotConfig(cfg, cfgFromCenter, bandsFromCenter, channInfoFromCenter); + pWifiHotspotServiceImpl->IsValidHotspotConfig(cfg, cfgFromCenter, bandsFromCenter); } /* Fuzzer entry point */ diff --git a/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp index 673ea48de8ed835c6f376c81f934e715553742ab..414fd873feb6dce5869d2a051f34a548a98b0cc0 100644 --- a/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifihotspotstub_fuzzer/wifihotspotstub_fuzzer.cpp @@ -390,7 +390,6 @@ void WifiHotspotServiceImplFuzzTest(const uint8_t* data, size_t size) std::string secondaryDeviceType = std::string(reinterpret_cast(data), size); std::vector bandsFromCenter; bandsFromCenter.push_back(newBand); - ChannelsTable channInfoFromCenter; HotspotConfig config; StationInfo updateInfo; if (size >= U32_AT_SIZE_ZERO) { @@ -419,7 +418,7 @@ void WifiHotspotServiceImplFuzzTest(const uint8_t* data, size_t size) mWifiHotspotServiceImpl.CfgCheckPsk(config); mWifiHotspotServiceImpl.CfgCheckBand(config, bandsFromCenter); mWifiHotspotServiceImpl.CfgCheckIpAddress(secondaryDeviceType); - mWifiHotspotServiceImpl.IsValidHotspotConfig(config, config, bandsFromCenter, channInfoFromCenter); + mWifiHotspotServiceImpl.IsValidHotspotConfig(config, config, bandsFromCenter); } /* Fuzzer entry point */ diff --git a/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/BUILD.gn b/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/BUILD.gn index 3b26f0e31eeb12bdb13d2a0f3d41da9c0999cc04..186fe1e416bcfa4730a4265342e0a76c748b3720 100644 --- a/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/BUILD.gn +++ b/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/BUILD.gn @@ -100,6 +100,7 @@ ohos_fuzztest("WifiStaServerFuzzTest") { deps = [ "$WIFI_ROOT_DIR/base:wifi_base", "$WIFI_ROOT_DIR/frameworks/native:wifi_sdk", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure:wifi_self_cure", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_device_service_impl", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_manager_service", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_scan_ability", @@ -107,7 +108,6 @@ ohos_fuzztest("WifiStaServerFuzzTest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/network_select:network_select", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common:wifi_common_service", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_native:wifi_native", - "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure:wifi_self_cure", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta:wifi_sta_service", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext:wifi_sta_ext_service", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext:wifi_telephony_utils", @@ -139,6 +139,11 @@ ohos_fuzztest("WifiStaServerFuzzTest") { "window_manager:libdm_lite", ] + if (wifi_feature_with_data_report) { + defines += [ "WIFI_DATA_REPORT_ENABLE" ] + sources += [ "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/wifi_data_report/select_network_data_report.cpp" ] + } + if (wifi_feature_with_security_detect) { defines += [ "WIFI_SECURITY_DETECT_ENABLE" ] external_deps += [ "security_guard:libsg_classify_sdk" ] diff --git a/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/wifistaserver_fuzzer.cpp b/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/wifistaserver_fuzzer.cpp index fbadee05c8f0e9357e9fb9b588173f842cdcab6c..1b26977b4648e127a37b8ec9048633b5ce5d1f2f 100644 --- a/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/wifistaserver_fuzzer.cpp +++ b/wifi/test/fuzztest/wifi_sta/wifistaserver_fuzzer/wifistaserver_fuzzer.cpp @@ -16,6 +16,7 @@ #include "wifistaserver_fuzzer.h" #include "wifi_fuzz_common_func.h" #include "mock_sta_state_machine.h" +#include "wifi_config_center.h" #include "wifi_security_detect.h" #include "wifi_security_detect_observer.h" @@ -27,7 +28,7 @@ #include "wifi_log.h" #include "sta_interface.h" #include "sta_auto_connect_service.h" -#include "wifi_config_center.h" +#include "wifi_settings.h" #include "sta_service.h" #include "wifi_internal_msg.h" #include "wifi_telephony_utils.h" @@ -114,11 +115,11 @@ public: void StaServerFuzzTest(const uint8_t* data, size_t size) { - int isRemoveAll = 0; int index = 0; int networkId = static_cast(data[index++]); int uid = static_cast(data[index++]); bool attemptEnable = (static_cast(data[0]) % TWO) ? true : false; + bool isRemoveAll = (static_cast(data[0]) % TWO) ? true : false; bool isAllowed = (static_cast(data[0]) % TWO) ? true : false; std::string cmd = std::string(reinterpret_cast(data), size); std::string conditionName = std::string(reinterpret_cast(data), size); @@ -169,6 +170,7 @@ void StaServerFuzzTest(const uint8_t* data, size_t size) pStaInterface->EnableAutoJoin(conditionName); pStaInterface->StartPortalCertification(); pStaInterface->EnableHiLinkHandshake(true, config, conditionName); + pStaInterface->StartWifiDetection(); pStaInterface->DeregisterFilterBuilder(filterTag, conditionName); pStaInterface->AllowAutoConnect(networkId, isAllowed); pStaInterface->EnableStaService(); @@ -236,6 +238,7 @@ void StaServerFuzzTest(const uint8_t* data, size_t size) pStaService->EnableAutoJoin(conditionName); pStaService->StartPortalCertification(); pStaService->EnableHiLinkHandshake(true, config, conditionName); + pStaService->StartWifiDetection(); pStaService->DeliverStaIfaceData(conditionName); WifiTelephonyUtils::GetDataSlotId(index); pStaService->AddDeviceConfig(config); diff --git a/wifi/test/wifi_standard/precompiled_macro/BUILD.gn b/wifi/test/wifi_standard/precompiled_macro/BUILD.gn index ec027e1242b60c6d5daa3d6a85bcf046cdc334d1..b0dc225c2a849400ed78f99d9b5ffb30a3c121e3 100644 --- a/wifi/test/wifi_standard/precompiled_macro/BUILD.gn +++ b/wifi/test/wifi_standard/precompiled_macro/BUILD.gn @@ -98,6 +98,7 @@ ohos_unittest("precompiled_macro_unittest") { deps = [ "$WIFI_ROOT_DIR/base:wifi_base", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext:wifi_sta_ext_service", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_device_ability", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_hotspot_ability", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage:wifi_manager_service", @@ -106,9 +107,8 @@ ohos_unittest("precompiled_macro_unittest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common:wifi_common_service", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_native:wifi_native", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_scan:wifi_scan_service", - "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure:wifi_self_cure", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta:wifi_sta_service", - "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext:wifi_sta_ext_service", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure:wifi_self_cure", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit", "$WIFI_ROOT_DIR/utils:wifi_utils", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext:wifi_telephony_utils", @@ -162,6 +162,11 @@ ohos_unittest("precompiled_macro_unittest") { "FEATURE_STA_SUPPORT", ] + if (wifi_feature_with_data_report) { + defines += [ "WIFI_DATA_REPORT_ENABLE" ] + sources += [ "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/wifi_data_report/select_network_data_report.cpp" ] + } + if (wifi_feature_with_extensible_authentication) { defines += [ "EXTENSIBLE_AUTHENTICATION" ] external_deps += ["netmanager_ext:ethernet_manager_if",] diff --git a/wifi/test/wifi_standard/wifi_base/mock_wifi_settings.h b/wifi/test/wifi_standard/wifi_base/mock_wifi_settings.h index 8fd25d008ee43be73237a83e0ff4a905e7fdbfc2..9125f5511e86ba20ab49e4b64232a399715ba75a 100644 --- a/wifi/test/wifi_standard/wifi_base/mock_wifi_settings.h +++ b/wifi/test/wifi_standard/wifi_base/mock_wifi_settings.h @@ -120,6 +120,8 @@ public: virtual int GetP2pInfo(WifiP2pLinkedInfo &linkedInfo) = 0; virtual void SetWifiToggledState(int state) = 0; virtual int GetScreenState() const = 0; + virtual void SetWlanPage(bool isWlanPage) = 0; + virtual bool IsWlanPage() const = 0; virtual int SetDeviceRandomizedMacSuccessEver(int networkId) = 0; virtual bool StoreWifiMacAddrPairInfo(WifiMacAddrInfoType type, const std::string &realMacAddr, const std::string &randomAddr) = 0; @@ -216,7 +218,6 @@ public: virtual bool GetSupportHwPnoFlag(int instId = 0) = 0; virtual int SetAcceptUnvalidated(int networkId, bool state) = 0; }; - class WifiSettings : public MockWifiSettings { public: static WifiSettings &GetInstance(void); @@ -304,6 +305,8 @@ public: MOCK_METHOD1(GetP2pInfo, int(WifiP2pLinkedInfo &linkedInfo)); MOCK_METHOD1(SetWifiToggledState, void(int state)); MOCK_CONST_METHOD0(GetScreenState, int()); + MOCK_METHOD1(SetWlanPage, void(bool isWlanPage)); + MOCK_CONST_METHOD0(IsWlanPage, bool()); MOCK_METHOD1(SetDeviceRandomizedMacSuccessEver, int(int networkId)); MOCK_METHOD1(SetValidChannels, int(const ChannelsTable &channelsInfo)); MOCK_METHOD1(GetPackageInfoMap, int(std::map> &filterMap)); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/idl_client/unittest/hal_device_manage_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/idl_client/unittest/hal_device_manage_test.cpp index 76cad91085514eb5f39b2c7856cfa3fce8ebce30..e33ceea19fd7f5c660c6869835dbcd9ed507027a 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/idl_client/unittest/hal_device_manage_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/idl_client/unittest/hal_device_manage_test.cpp @@ -196,7 +196,7 @@ HWTEST_F(WifiHalDeviceManagerTest, GetFrequenciesByBandTest, TestSize.Level1) std::string ifaceName; int instId = 0; HalDeviceManager::g_chipHdiServiceDied = true; - HalDeviceManager::GetInstance().CreateApIface( + DelayedSingleton::GetInstance()->CreateApIface( std::bind(WifiHalDeviceManagerTest::DestoryCallback, std::placeholders::_1, std::placeholders::_2), ifaceName); int32_t band = 0; std::vector frequencies; @@ -626,6 +626,16 @@ HWTEST_F(WifiHalDeviceManagerTest, SetApMacAddressTest_01, TestSize.Level1) EXPECT_EQ(result, true); } +HWTEST_F(WifiHalDeviceManagerTest, OnRssiReportCallbackTest_01, TestSize.Level1) +{ + int32_t index = 0; + int32_t c0Rssi = -60; + int32_t c1Rssi = -70; + ChipIfaceCallback data; + int result = data.OnRssiReport(index, c0Rssi, c1Rssi); + EXPECT_EQ(result, 0); +} + HWTEST_F(WifiHalDeviceManagerTest, ValidateInterfaceCacheTest_01, TestSize.Level1) { std::string ifaceName = "Wlan0"; @@ -735,16 +745,6 @@ HWTEST_F(WifiHalDeviceManagerTest, OnScanResultsCallbackTest_01, TestSize.Level1 EXPECT_EQ(result, 0); } -HWTEST_F(WifiHalDeviceManagerTest, OnRssiReportCallbackTest_01, TestSize.Level1) -{ - int32_t index = 0; - int32_t c0Rssi = -60; - int32_t c1Rssi = -70; - ChipIfaceCallback data; - int result = data.OnRssiReport(index, c0Rssi, c1Rssi); - EXPECT_EQ(result, 0); -} - HWTEST_F(WifiHalDeviceManagerTest, MakeMacFilterStringTest_01, TestSize.Level1) { std::vector blockList{}; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_channel_helper_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_channel_helper_test.cpp index 898b6cfe9c9a4bfd290d7b3c9711c5a5be701c33..2cfa457840e5c99acd88d89b76a1c81602f5039a 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_channel_helper_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_channel_helper_test.cpp @@ -67,16 +67,6 @@ HWTEST_F(WifiChannelHelperTest, TestGetValidChannels, TestSize.Level1) EXPECT_EQ(WifiChannelHelper::GetInstance().GetValidChannels(validChannels), 0); } -HWTEST_F(WifiChannelHelperTest, TestUpdateValidChannels, TestSize.Level1) -{ - std::string ifaceName = "wlan0"; - WifiChannelHelper::GetInstance().UpdateValidChannels(ifaceName); - - ifaceName = "wlan1"; - WifiChannelHelper::GetInstance().UpdateValidChannels(ifaceName); - EXPECT_FALSE(g_errLog.find("processWiTasDecisiveMessage")!=std::string::npos); -} - HWTEST_F(WifiChannelHelperTest, UpdateValidFreqsTest, TestSize.Level1) { WifiChannelHelper::GetInstance().UpdateValidFreqs(); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_net_agent_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_net_agent_test.cpp index be2c534df0929ba88e6d38d55fe27aaa492b8c14..74a85cbc9f07c9c1cb7e7e9bcc520aabe780e71b 100755 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_net_agent_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/common/wifi_net_agent_test.cpp @@ -54,17 +54,7 @@ HWTEST_F(WifiNetAgentTest, RegisterNetSupplier_ReturnsFalseWhenRegistrationFails EXPECT_FALSE(WifiNetAgent::GetInstance().RegisterNetSupplier(instId)); } -HWTEST_F(WifiNetAgentTest, RegisterNetConnObserverTest_ReturnsFalseWhenRegistrationFails, TestSize.Level1) -{ - EXPECT_TRUE(WifiNetAgent::GetInstance().RegisterNetConnObserver(INSTID_WLAN0)); -} - -HWTEST_F(WifiNetAgentTest, RegisterNetConnObserverTest_ReturnTrueWhenRegistrationSuccess, TestSize.Level1) -{ - EXPECT_FALSE(WifiNetAgent::GetInstance().RegisterNetConnObserver(INSTID_WLAN1)); -} - -HWTEST_F(WifiNetAgentTest, RegisterNetSupplierCallback_ReturnFalseWhenRegistrationFails, TestSize.Level1) +HWTEST_F(WifiNetAgentTest, RegisterNetSupplierCallback_ReturnsFalseWhenRegistrationFails, TestSize.Level1) { int instId = 0; EXPECT_FALSE(WifiNetAgent::GetInstance().RegisterNetSupplierCallback(instId)); @@ -285,13 +275,6 @@ HWTEST_F(WifiNetAgentTest, ReleaseNetworkTest001, TestSize.Level1) EXPECT_EQ(netConnCallback.ReleaseNetwork(netrequest), 0); } -HWTEST_F(WifiNetAgentTest, NetAvailableTest001, TestSize.Level1) -{ - WifiNetAgent::NetInfoObserver netConnCallback; - sptr netHandle = new NetManagerStandard::NetHandle(); - EXPECT_EQ(netConnCallback.NetAvailable(netHandle), 0); -} - HWTEST_F(WifiNetAgentTest, LogNetCapsTest001, TestSize.Level1) { WifiNetAgent::NetConnCallback netConnCallback; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp index 2e6ceae9e72afc6df3a99471d625ebb98329aa9e..11fe6d1f6a7d60a147c68a26492bd0cf7a515eba 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_manager_test.cpp @@ -200,23 +200,10 @@ HWTEST_F(WifiManagerTest, CheckAndStopScanServiceTest, TestSize.Level1) wifiManager.wifiScanManager->CheckAndStopScanService(); } -HWTEST_F(WifiManagerTest, DealScanInfoNotifyTest_001, TestSize.Level1) +HWTEST_F(WifiManagerTest, DealScanInfoNotifyTest, TestSize.Level1) { - WIFI_LOGI("DealScanInfoNotifyTest_001 enter!"); + WIFI_LOGI("DealScanInfoNotifyTest enter!"); std::vector results; - EXPECT_CALL(WifiConfigCenter::GetInstance(), GetAutoConnect()) - .WillOnce(DoAll(Return(true))); - EXPECT_CALL(WifiConfigCenter::GetInstance(), GetWifiMidState(_)) - .WillOnce(DoAll(Return(WifiOprMidState::RUNNING))); - wifiManager.wifiScanManager->DealScanInfoNotify(results); -} - -HWTEST_F(WifiManagerTest, DealScanInfoNotifyTest_002, TestSize.Level1) -{ - WIFI_LOGI("DealScanInfoNotifyTest_002 enter!"); - std::vector results; - EXPECT_CALL(WifiConfigCenter::GetInstance(), GetAutoConnect()) - .WillOnce(DoAll(Return(false))); EXPECT_CALL(WifiConfigCenter::GetInstance(), GetWifiMidState(_)) .WillOnce(DoAll(Return(WifiOprMidState::RUNNING))); wifiManager.wifiScanManager->DealScanInfoNotify(results); @@ -638,7 +625,7 @@ HWTEST_F(WifiManagerTest, IsInterfaceUpTest, TestSize.Level1) WIFI_LOGI("IsInterfaceUpTest enter!"); std::string iface = "wlan0"; wifiManager.wifiTogglerManager->IsInterfaceUp(iface); - EXPECT_FALSE(wifiManager.wifiTogglerManager->IsInterfaceUp(iface)); + EXPECT_TRUE(wifiManager.wifiTogglerManager->IsInterfaceUp(iface)); } HWTEST_F(WifiManagerTest, OnNativeProcessStatusChange_WpaDeath, TestSize.Level1) diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_power_state_listener_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_power_state_listener_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82d6d9afa8e3e1f9f6a4b94c2a3bfcff5f8219c2 --- /dev/null +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_power_state_listener_test.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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 "wifi_power_state_listener_test.h" +#include "wifi_config_center.h" +#include "wifi_logger.h" + +using namespace testing::ext; +DEFINE_WIFILOG_LABEL("WifiPowerStateListenerTest"); + +namespace OHOS { +namespace Wifi { +static std::string g_errLog; +void WifiPowerStateListenerCallBack(const LogType type, const LogLevel level, + const unsigned int domain, + const char *tag, const char *msg) +{ + g_errLog = msg; +} +HWTEST_F(WifiPowerStateListenerTest, OnSyncSleepTest, TestSize.Level1) +{ + WIFI_LOGE("OnSyncSleepTest enter!"); + bool onForceSleep = true; + WifiPowerStateListener::GetInstance().OnSyncSleep(onForceSleep); + onForceSleep = false; + WifiPowerStateListener::GetInstance().OnSyncSleep(onForceSleep); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} + +HWTEST_F(WifiPowerStateListenerTest, OnSyncWakeupTest, TestSize.Level1) +{ + WIFI_LOGE("OnSyncWakeupTest enter!"); + bool onForceSleep = true; + WifiPowerStateListener::GetInstance().OnSyncWakeup(onForceSleep); + onForceSleep = false; + WifiPowerStateListener::GetInstance().OnSyncWakeup(onForceSleep); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} + +HWTEST_F(WifiPowerStateListenerTest, DealPowerEnterSleepEventTest, TestSize.Level1) +{ + WIFI_LOGE("DealPowerEnterSleepEventTest enter!"); + WifiConfigCenter::GetInstance().SetWifiMidState(WifiOprMidState::RUNNING); + WifiPowerStateListener::GetInstance().DealPowerEnterSleepEvent(); + WifiConfigCenter::GetInstance().SetWifiMidState(WifiOprMidState::CLOSED); + WifiPowerStateListener::GetInstance().DealPowerEnterSleepEvent(); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} + +HWTEST_F(WifiPowerStateListenerTest, DealPowerExitSleepEventTest, TestSize.Level1) +{ + WIFI_LOGE("DealPowerExitSleepEventTest enter!"); + WifiConfigCenter::GetInstance().SetWifiMidState(WifiOprMidState::RUNNING); + WifiPowerStateListener::GetInstance().DealPowerEnterSleepEvent(); + WifiPowerStateListener::GetInstance().DealPowerExitSleepEvent(); + WifiPowerStateListener::GetInstance().DealPowerExitSleepEvent(); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} +} // namespace Wifi +} // namespace OHOS \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_power_state_listener_test.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_power_state_listener_test.h new file mode 100644 index 0000000000000000000000000000000000000000..cc12d2a86dcbd3a67a4236e8a6268bb6492eb679 --- /dev/null +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/unittest/wifi_power_state_listener_test.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * 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 OHOS_WIFI_POWER_STATE_LISTENER_TEST_H +#define OHOS_WIFI_POWER_STATE_LISTENER_TEST_H +#include +#include "wifi_power_state_listener.h" + +namespace OHOS { +namespace Wifi { +class WifiPowerStateListenerTest : public testing::Test { +public: + static void SetUpTestCase() {} + static void TearDownTestCase() {} + virtual void SetUp() {} + virtual void TearDown() {} +}; +} // namespace Wifi +} // namespace OHOS +#endif \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn index 00afd221ff6397341c932959cb6981dbd3fdbcd7..a5a0ce693552061f4afa1a7f84f0b7c84269ca45 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/BUILD.gn @@ -39,7 +39,6 @@ ohos_unittest("WifiApServiceTest") { "$WIFI_ROOT_DIR/frameworks/native/src/wifi_hid2d_msg.cpp", "$WIFI_ROOT_DIR/frameworks/native/src/wifi_msg.cpp", "$WIFI_ROOT_DIR/frameworks/native/src/wifi_p2p_msg.cpp", - "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_idle_state.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_monitor.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_root_state.cpp", @@ -49,6 +48,7 @@ ohos_unittest("WifiApServiceTest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_stations_manager.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/wifi_ap_nat_manager.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_network_monitor.cpp", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/ap_config_use.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_channel_helper.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/wifi_cmd_client.cpp", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper/base_address.cpp", @@ -63,6 +63,7 @@ ohos_unittest("WifiApServiceTest") { "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/utils/wifi_randommac_helper.cpp", "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_wifi_sta_hal_interface.cpp", "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_wifi_supplicant_hal_interface.cpp", + "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.cpp", "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/Mock/mock_wifi_config_center.cpp", "../../wifi_manage/wifi_sta/Mock/mock_dhcp_service.cpp", "./Mock/mock_ap_state_machine.cpp", diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.cpp index 3c678f13474bbbc2cec427411bcc18724a996b0a..9c479f69f3879325ca74dcd12b0ac67bf3c01d53 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.cpp @@ -62,16 +62,6 @@ ErrCode ApInterface::GetStationList(std::vector &result) return WIFI_OPT_SUCCESS; } -ErrCode ApInterface::GetValidBands(std::vector &bands) -{ - return WIFI_OPT_SUCCESS; -} - -ErrCode ApInterface::GetValidChannels(BandType band, std::vector &validChannel) -{ - return WIFI_OPT_SUCCESS; -} - ErrCode ApInterface::RegisterApServiceCallbacks(const IApServiceCallbacks &callbacks) { return WIFI_OPT_SUCCESS; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.h index 114c800b461e2bffe3b8a1031ad6abf104e8e0e9..61887577361db59b51cc9dadfe4032a89978d0d0 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_interface.h @@ -35,8 +35,6 @@ public: virtual ErrCode DisconnetStation(const StationInfo &stationInfo); virtual ErrCode GetStationList(std::vector &result); virtual ErrCode RegisterApServiceCallbacks(const IApServiceCallbacks &callbacks); - virtual ErrCode GetValidBands(std::vector &bands); - virtual ErrCode GetValidChannels(BandType band, std::vector &validChannel); virtual ErrCode GetSupportedPowerModel(std::set& setPowerModelList); virtual ErrCode GetPowerModel(PowerModel& model); virtual ErrCode SetPowerModel(const PowerModel& model); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_service.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_service.h index d77aba472b822ab0028052ed0b530508e20b5fc1..9b9846e71e105b9f64cb4c014021913f9d85d552 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_service.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_service.h @@ -34,8 +34,6 @@ public: MOCK_METHOD1(DelBlockList, ErrCode(const StationInfo &stationInfo)); MOCK_METHOD1(SetHotspotConfig, ErrCode(const HotspotConfig &hotspotConfig)); MOCK_METHOD1(DisconnetStation, ErrCode(const StationInfo &stationInfo)); - MOCK_METHOD1(GetValidBands, ErrCode(std::vector &bands)); - MOCK_METHOD2(GetValidChannels, ErrCode(BandType band, std::vector &validchannel)); MOCK_METHOD1(RegisterApServiceCallbacks, ErrCode(const IApServiceCallbacks &callbacks)); }; } /* namespace Wifi */ diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_started_state.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_started_state.h index 6e85443cfae4c2aaeaa6838446b7df07109eb331..11fe7ee4f346bfd65fbd6daf2c79390deb65a17c 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_started_state.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_ap_started_state.h @@ -24,8 +24,8 @@ namespace OHOS { namespace Wifi { class MockApStartedState : public ApStartedState { public: - MockApStartedState(ApStateMachine &apStateMachine, ApConfigUse &apConfigUse, ApMonitor &apMonitor) - : ApStartedState(apStateMachine, apConfigUse, apMonitor) + MockApStartedState(ApStateMachine &apStateMachine, ApMonitor &apMonitor) + : ApStartedState(apStateMachine, apMonitor) {} MOCK_METHOD0(GoInState, void()); MOCK_METHOD0(GoOutState, void()); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_pendant.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_pendant.h index 66340c4482e0dd977b9309b03374391f367cb22b..f2feff5b7a7386bc2c717f8d0dfcd135e7e8c13d 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_pendant.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/Mock/mock_pendant.h @@ -34,7 +34,7 @@ public: MockPendant() : m_MockApRootState(), m_MockApIdleState(m_MockApStateMachine), - m_MockApStartedState(m_MockApStateMachine, m_MockApConfigUse, m_MockApMonitor), + m_MockApStartedState(m_MockApStateMachine, m_MockApMonitor), m_MockApService(m_MockApStateMachine, m_MockApStartedState), m_MockApStateMachine( m_MockApStationsManager, m_MockApRootState, m_MockApIdleState, m_MockApStartedState, m_MockApMonitor), diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use_test.cpp index 3f50b0f0bfcc717985bbc35fcb23014d25c274b0..7edc80304642cddcc008e65737d90bc32c732909 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_config_use_test.cpp @@ -26,6 +26,7 @@ #include "wifi_msg.h" #include "wifi_p2p_msg.h" #include "wifi_country_code_manager.h" +#include "wifi_channel_helper.h" using ::testing::_; using ::testing::AtLeast; @@ -98,6 +99,7 @@ HWTEST_F(ApConfigUse_Test, GetChannelFromDrvOrXmlByBandTest, TestSize.Level1) HWTEST_F(ApConfigUse_Test, GetBestChannelFor2GTest, TestSize.Level1) { WIFI_LOGI("GetBestChannelFor2GTest enter"); + WifiChannelHelper::GetInstance().mValidFreqs[ScanBandType::SCAN_BAND_24_GHZ] = {2412, 2417, 2422}; int channel = m_apConfigUse->GetBestChannelFor2G(); WIFI_LOGI("GetBestChannelFor2GTest channel=%{public}d", channel); EXPECT_TRUE(IsValid24GChannel(channel)); @@ -106,13 +108,12 @@ HWTEST_F(ApConfigUse_Test, GetBestChannelFor2GTest, TestSize.Level1) HWTEST_F(ApConfigUse_Test, GetBestChannelFor5GTest, TestSize.Level1) { WIFI_LOGI("GetBestChannelFor5GTest enter"); - std::vector frequencies = {5180, 5200, 5220}; HotspotConfig apConfig; apConfig.SetBandWidth(AP_BANDWIDTH_DEFAULT); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, _)) - .WillRepeatedly(DoAll(SetArgReferee<2>(frequencies), Return(WifiErrorNo::WIFI_HAL_OPT_OK))); + WifiChannelHelper::GetInstance().mValidFreqs[ScanBandType::SCAN_BAND_5_GHZ] = {5180, 5200, 5220, 5745}; int channel = m_apConfigUse->GetBestChannelFor5G(apConfig); WIFI_LOGI("GetBestChannelFor5GTest channel=%{public}d", channel); + EXPECT_TRUE(IsValid5GChannel(channel)); } HWTEST_F(ApConfigUse_Test, GetBestChannelFor5G160MTest, TestSize.Level1) @@ -168,5 +169,36 @@ HWTEST_F(ApConfigUse_Test, JudgeDbacWithP2pTest, TestSize.Level1) .WillOnce(DoAll(Return(wifiP2pGroupInfo))); m_apConfigUse->JudgeDbacWithP2p(apConfig); } +HWTEST_F(ApConfigUse_Test, GetApVaildChannelTest, TestSize.Level1) +{ + WIFI_LOGI("GetApVaildChannelTest enter"); + WifiChannelHelper::GetInstance().mValidFreqs[ScanBandType::SCAN_BAND_24_GHZ] = {2412, 2417, 2422}; + + std::vector channels; + m_apConfigUse->GetApVaildChannel(BandType::BAND_2GHZ, channels); + EXPECT_FALSE(channels.size() == 0); +} + +HWTEST_F(ApConfigUse_Test, GetApVaildChannelTest1, TestSize.Level1) +{ + WIFI_LOGI("GetApVaildChannelTest1 enter"); + WifiChannelHelper::GetInstance().mValidFreqs[ScanBandType::SCAN_BAND_5_GHZ] = {5180, 5200, 5220, 5745}; + + std::vector channels; + m_apConfigUse->GetApVaildChannel(BandType::BAND_5GHZ, channels); + EXPECT_FALSE(channels.size() == 0); +} + +HWTEST_F(ApConfigUse_Test, GetGetApVaildBandsTest, TestSize.Level1) +{ + WIFI_LOGI("GetApVaildChannelTest enter"); + WifiChannelHelper::GetInstance().mValidFreqs[ScanBandType::SCAN_BAND_24_GHZ] = {2412, 2417, 2422}; + WifiChannelHelper::GetInstance().mValidFreqs[ScanBandType::SCAN_BAND_5_GHZ] = {5180, 5200, 5220, 5745}; + + std::vector bands; + m_apConfigUse->GetApVaildBands(bands); + EXPECT_FALSE(bands.size() == 0); +} + } // namespace Wifi } // namespace OHOS \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service_test.cpp index 6d806abb83af73682333a16e1d78cfe71057c819..43a55c16bde9cd3101a56c342b2a5ed7e78140f2 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_service_test.cpp @@ -44,7 +44,6 @@ const StationInfo staInfo = { "127.0.0.1", }; -constexpr int FREQUENCY2G = 2412; class ApService_test : public testing::Test { public: @@ -129,42 +128,6 @@ HWTEST_F(ApService_test, DisconnetStation_SUCCESS, TestSize.Level1) EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->DisconnetStation(staInfo)); } -/* GetValidBands */ -HWTEST_F(ApService_test, GetValidBands_SUCCESS, TestSize.Level1) -{ - std::vector vecSta; - - EXPECT_CALL(WifiApHalInterface::GetInstance(), RegisterApEvent(_, 0)) - .WillRepeatedly(Return(WifiErrorNo::WIFI_HAL_OPT_OK)); - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidBands(vecSta)); -} -HWTEST_F(ApService_test, GetValidBands_FAILED, TestSize.Level1) -{ - std::vector vecSta; - - EXPECT_CALL(WifiApHalInterface::GetInstance(), RegisterApEvent(_, 0)) - .WillRepeatedly(Return(WifiErrorNo::WIFI_HAL_OPT_OK)); - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidBands(vecSta)); -} - -/* GetValidChannels */ -HWTEST_F(ApService_test, GetValidChannels_SUCCESS, TestSize.Level1) -{ - std::vector vecChannels; - std::vector band_2G_channel = { 1, 2, 3, 4, 5, 6, 7 }; - std::vector band_5G_channel = { 149, 168, 169 }; - ChannelsTable temp = { { BandType::BAND_2GHZ, band_2G_channel }, { BandType::BAND_5GHZ, band_5G_channel } }; - EXPECT_CALL(WifiApHalInterface::GetInstance(), RegisterApEvent(_, 0)) - .WillRepeatedly(Return(WifiErrorNo::WIFI_HAL_OPT_OK)); - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidChannels(BandType::BAND_2GHZ, vecChannels)); - vecChannels.clear(); - - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidChannels(BandType::BAND_5GHZ, vecChannels)); - vecChannels.clear(); - - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidChannels(BandType::BAND_5GHZ, vecChannels)); -} - /* RegisterApServiceCallbacks */ HWTEST_F(ApService_test, RegisterApServiceCallbacks_SUCCESS, TestSize.Level1) { @@ -195,56 +158,6 @@ HWTEST_F(ApService_test, GetStationListFailed, TestSize.Level1) EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetStationList(result)); } -HWTEST_F(ApService_test, GetValidBandsSuccess, TestSize.Level1) -{ - std::vector vecSta; - std::vector allowed2GFreq; - allowed2GFreq.push_back(FREQUENCY2G); - EXPECT_CALL(WifiConfigCenter::GetInstance(), GetApIfaceName()).WillRepeatedly(Return("wifitest")); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, Eq(allowed2GFreq))) - .WillOnce(DoAll(SetArgReferee<2>(allowed2GFreq), Return(WifiErrorNo::WIFI_HAL_OPT_OK))); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, _)) - .WillRepeatedly(Return(WifiErrorNo::WIFI_HAL_OPT_OK)); - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidBands(vecSta)); -} - -HWTEST_F(ApService_test, GetValidBandsFailed, TestSize.Level1) -{ - std::vector vecSta; - EXPECT_CALL(WifiConfigCenter::GetInstance(), GetApIfaceName()).WillRepeatedly(Return("wifitest")); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, _)) - .WillRepeatedly(Return(WifiErrorNo::WIFI_HAL_OPT_OK)); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, _)) - .WillRepeatedly(Return(WifiErrorNo::WIFI_HAL_OPT_OK)); - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidBands(vecSta)); -} - -HWTEST_F(ApService_test, GetValidChannelsSuccess2, TestSize.Level1) -{ - std::vector vecChannels; - std::vector allowed2GFreq = { 2412, 2417, 2422, 2427, 2432, 2437, 2442 }; - std::vector allowed5GFreq = { 5745, 5765, 5785 }; - EXPECT_CALL(WifiConfigCenter::GetInstance(), GetApIfaceName()).WillRepeatedly(Return("wifitest")); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, Eq(allowed2GFreq))) - .WillOnce(DoAll(SetArgReferee<2>(allowed2GFreq), Return(WifiErrorNo::WIFI_HAL_OPT_OK))); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, _)) - .WillRepeatedly(DoAll(SetArgReferee<2>(allowed5GFreq), Return(WifiErrorNo::WIFI_HAL_OPT_OK))); - EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->GetValidChannels(BandType::BAND_2GHZ, vecChannels)); -} - -HWTEST_F(ApService_test, GetValidChannelsFail2, TestSize.Level1) -{ - std::vector vecChannels; - std::vector allowed2GFreq = { 2412, 2417, 2422, 2427, 2432, 2437, 2442 }; - std::vector allowed5GFreq = { 5745, 5765, 5785 }; - EXPECT_CALL(WifiConfigCenter::GetInstance(), GetApIfaceName()).WillRepeatedly(Return("wifitest")); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, Eq(allowed2GFreq))) - .WillOnce(DoAll(SetArgReferee<2>(allowed2GFreq), Return(WifiErrorNo::WIFI_HAL_OPT_OK))); - EXPECT_CALL(WifiApHalInterface::GetInstance(), GetFrequenciesByBand(_, _, _)) - .WillRepeatedly(DoAll(SetArgReferee<2>(allowed5GFreq), Return(WifiErrorNo::WIFI_HAL_OPT_OK))); - EXPECT_EQ(ErrCode::WIFI_OPT_INVALID_PARAM, pApService->GetValidChannels(BandType::BAND_ANY, vecChannels)); -} - HWTEST_F(ApService_test, GetSupportedPowerModelSuccess, TestSize.Level1) { std::set setPowerModelList; @@ -277,7 +190,7 @@ HWTEST_F(ApService_test, OnWifiCountryCodeChangedSuccess, TestSize.Level1) EXPECT_EQ(ErrCode::WIFI_OPT_SUCCESS, pApService->m_apObserver->OnWifiCountryCodeChanged(countryCode)); } -HWTEST_F(ApService_test, GetPowerModelTest, TestSize.Level1) +HWTEST_F(ApService_test, GetHotspotModeTest, TestSize.Level1) { WIFI_LOGI("GetPowerModelTest enter"); HotspotMode mode = HotspotMode::NONE; @@ -295,4 +208,4 @@ HWTEST_F(ApService_test, SetHotspotModeTest, TestSize.Level1) EXPECT_EQ(mode, HotspotMode::RPT); } } // namespace Wifi -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state_test.cpp index af6fa65ccebb909159ce1c2af591ba82f3580c2f..40f650152f7883697484c57ec4150de28ccf879c 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_ap/ap_started_state_test.cpp @@ -65,7 +65,7 @@ public: pMockApNatManager = new MockWifiApNatManager(); - pApStartedState = std::make_unique(*pMockApStateMachine, *pMockApConfigUse, *pMockApMonitor); + pApStartedState = std::make_unique(*pMockApStateMachine, *pMockApMonitor); msg = std::make_shared(); @@ -273,6 +273,9 @@ HWTEST_F(ApStartedState_test, ExecuteStateMsg_SUCCESS, TestSize.Level1) msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_FAIL)); EXPECT_TRUE(pApStartedState->ExecuteStateMsg(msg)); + msg->SetMessageName(static_cast(ApStatemachineEvent::CMD_START_HOTSPOT_TIMEOUT)); + EXPECT_TRUE(pApStartedState->ExecuteStateMsg(msg)); + EXPECT_CALL(WifiConfigCenter::GetInstance(), GetStationList(_, 0)).WillRepeatedly(Return(ErrCode::WIFI_OPT_FAILED)); msg->ClearMessageBody(); StationInfo staInfo; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine_test.cpp index 81ad1c3112645abaffb3856d62dcbdee62b93583..0d365cd73094b73adc2ccff4c2f955c912794dfe 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_controller/concrete_manager_state_machine_test.cpp @@ -59,7 +59,6 @@ public: { WifiManager::GetInstance().Init(); pConcreteManagerMachine = std::make_unique(); - pWifiTogglerManager = std::make_unique(); pConcreteManagerMachine->InitConcreteMangerMachine(); mCb.onStartFailure = DealConcreteStartFailure; mCb.onStopped = DealConcreteStop; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..33779c6f4f493ed65b0ec9e14aeec732991f56d0 --- /dev/null +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * 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 "mock_hal_device_manage.h" + +namespace OHOS { +namespace Wifi { + +HalDeviceManager::HalDeviceManager() +{} + +HalDeviceManager::~HalDeviceManager() +{} + +HalDeviceManager &HalDeviceManager::GetInstance() +{ + static HalDeviceManager instance; + return instance; +} +} +} \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.h new file mode 100644 index 0000000000000000000000000000000000000000..8251e4af205597e93d6586e05fde740fa148a0d2 --- /dev/null +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/Mock/mock_hal_device_manage.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 OHOS_MOCK_HAL_DEVICE_MANAGE_H +#define OHOS_MOCK_HAL_DEVICE_MANAGE_H + +#include +#include +#include + +namespace OHOS { +namespace Wifi { + +class MockHalDeviceManager { +public: + + virtual ~MockHalDeviceManager() = default; + virtual bool GetFrequenciesByBand(const std::string &ifaceName, int32_t band, std::vector &frequencies); +}; + +class HalDeviceManager : public MockHalDeviceManager { +public: + HalDeviceManager(); + + ~HalDeviceManager() override; + /** + * @Description get instance of HalDeviceManager + * + * @param + * @return HalDeviceManager + */ + static HalDeviceManager &GetInstance(); + + MOCK_METHOD3(GetFrequenciesByBand, bool(const std::string &ifaceName, int32_t band, std::vector &frequencies)); +}; +} +} +#endif \ No newline at end of file diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy_test.cpp index fdd2e419f9de461c1a34cca708538ab1bb0d7b33..2e931a1bf2c040262d77365604e10fd8a20b6c02 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_native/client/hdi_client/hdi_interface/wifi_hdi_wpa_proxy_test.cpp @@ -117,6 +117,13 @@ HWTEST_F(WifiHdiWpaProxyTest, RegistHdfApDeathCallBackTest, TestSize.Level1) EXPECT_EQ(result, WIFI_HAL_OPT_FAILED); } +extern "C" WifiErrorNo UnRegistHdfDeathCallBack(); +HWTEST_F(WifiHdiWpaProxyTest, RegistHdfDeathCallBackTest, TestSize.Level1) +{ + WifiErrorNo result = UnRegistHdfDeathCallBack(); + EXPECT_EQ(result, WIFI_HAL_OPT_FAILED); +} + extern "C" void RemoveIfaceName(const char* ifName); HWTEST_F(WifiHdiWpaProxyTest, RemoveIfaceNameTest, TestSize.Level1) { diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/test/Mock/mock_wifi_p2p_hal_interface.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/test/Mock/mock_wifi_p2p_hal_interface.h index 8ad543b56d813a50c92cf97d6f423e380715c5e1..99e43ebf3159e041a1fb6a7b898856e95f0bbf69 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/test/Mock/mock_wifi_p2p_hal_interface.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_p2p/test/Mock/mock_wifi_p2p_hal_interface.h @@ -93,6 +93,8 @@ public: virtual WifiErrorNo GroupClientRemove(const std::string &deviceMac) const = 0; virtual WifiErrorNo P2pReject(const std::string &mac); virtual WifiErrorNo SetMiracastSinkConfig(const std::string &config); + virtual WifiErrorNo TempGroupAdd(int freq); + virtual WifiErrorNo P2pSetTempConfig(int networkId, const HalP2pGroupConfig &config) const = 0; virtual WifiErrorNo SetP2pHighPerf(bool isEnable); }; @@ -165,8 +167,10 @@ public: MOCK_CONST_METHOD1(GroupClientRemove, WifiErrorNo(const std::string &deviceMac)); MOCK_METHOD1(P2pReject, WifiErrorNo(const std::string &mac)); MOCK_METHOD1(SetMiracastSinkConfig, WifiErrorNo(const std::string &config)); + MOCK_METHOD1(TempGroupAdd, WifiErrorNo(int freq)); + MOCK_CONST_METHOD2(P2pSetTempConfig, WifiErrorNo(int networkId, const HalP2pGroupConfig &config)); MOCK_METHOD1(SetP2pHighPerf, WifiErrorNo(bool isEnable)); }; } // namespace Wifi } // namespace OHOS -#endif \ No newline at end of file +#endif diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper_test.cpp index a0c8b5482e958c3242f809b7ef2cc312f5443de7..a7fa79144b837f619e98da79e40df3d31e23f3cc 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_intelligence/ap_info_helper_test.cpp @@ -72,7 +72,7 @@ HWTEST_F(ApInfoHelperTest, GetAllApInfosTest, TestSize.Level1) helper->wifiDataBaseUtils_ = nullptr; EXPECT_FALSE(helper->GetAllApInfos()); helper->wifiDataBaseUtils_ = WifiRdbManager::GetRdbManger(RdbType::WIFI_PRO); - EXPECT_FALSE(helper->GetAllApInfos()); + EXPECT_TRUE(helper->GetAllApInfos()); } HWTEST_F(ApInfoHelperTest, AddApInfoTest1, TestSize.Level1) diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine_test.cpp index 1da04ea738244b652afd8ec25667179fcf8c4f82..0abfd212191b6f82f78f9ff6a1ebc28f24fa5b4f 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_pro/wifi_pro_state_machine_test.cpp @@ -297,11 +297,11 @@ HWTEST_F(WifiProStateMachineTest, TryNoNetSwitchTest, TestSize.Level1) { NetworkSelectionResult networkSelectionResult; networkSelectionResult.wifiDeviceConfig.networkId = 1; - wifiNoNetState_->pWifiProStateMachine_->isFirstNetDectect_ = false; + wifiNoNetState_->pWifiProStateMachine_->isFirstDectectHasNet_ = true; wifiNoNetState_->pWifiProStateMachine_->wifiSwitchReason_ = WIFI_SWITCH_REASON_NO_INTERNET; wifiNoNetState_->pWifiProStateMachine_->TryWifi2Wifi(networkSelectionResult); - wifiNoNetState_->pWifiProStateMachine_->isFirstNetDectect_ = true; + wifiNoNetState_->pWifiProStateMachine_->isFirstDectectHasNet_ = false; wifiNoNetState_->pWifiProStateMachine_->wifiSwitchReason_ = WIFI_SWITCH_REASON_NO_INTERNET; wifiNoNetState_->pWifiProStateMachine_->TryWifi2Wifi(networkSelectionResult); @@ -310,12 +310,6 @@ HWTEST_F(WifiProStateMachineTest, TryNoNetSwitchTest, TestSize.Level1) EXPECT_NE(pWifiProStateMachine_->wifiSwitchReason_, TEN); } -HWTEST_F(WifiProStateMachineTest, IsFirstConnectAndNonetTest01, TestSize.Level1) -{ - pWifiProStateMachine_->currentState_ = WifiProState::WIFI_HASNET; - EXPECT_EQ(pWifiProStateMachine_->IsFirstConnectAndNonet(), false); -} - HWTEST_F(WifiProStateMachineTest, WifiProEnableStateTransitionNetStateTest01, TestSize.Level1) { wifiProEnableState_->pWifiProStateMachine_ = new WifiProStateMachine(); @@ -701,7 +695,7 @@ HWTEST_F(WifiProStateMachineTest, WifiPortalStateGoInStateTest01, TestSize.Level { wifiPortalState_->GoInState(); wifiPortalState_->GoOutState(); - EXPECT_EQ(wifiPortalState_->pWifiProStateMachine_->isFirstNetDectect_, false); + EXPECT_EQ(wifiPortalState_->pWifiProStateMachine_->currentState_, WifiProState::WIFI_PORTAL); } HWTEST_F(WifiProStateMachineTest, WifiPortalStateExecuteStateMsgTest01, TestSize.Level1) diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn index cd26714e90d4bdb516bdf1a6074f6826b6dd6daf..b83a3c79dc3ea9b9239be7ee6a064cf86feada32 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/BUILD.gn @@ -97,6 +97,7 @@ local_base_include_dirs = [ "$WIFI_ROOT_DIR/base/utils", "$WIFI_ROOT_DIR/base/inner_api", "$WIFI_ROOT_DIR/base/state_machine/include", + "$WIFI_ROOT_DIR/base/shared_util", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/include", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/net_helper", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit/log", @@ -162,8 +163,8 @@ local_base_external_deps = [ "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", - "c_utils:utils", "cJSON:cjson", + "c_utils:utils", "certificate_manager:cert_manager_sdk", "data_share:datashare_consumer", "dhcp:dhcp_sdk", @@ -184,7 +185,6 @@ local_base_external_deps = [ "samgr:samgr_proxy", "time_service:time_client", "window_manager:libdm_lite", - "security_guard:libsg_classify_sdk", ] if (defined(global_parts_info) && defined(global_parts_info.telephony_core_service) && diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp index e180d7e1ad9db4cfd00dad03f6831a6f176d5ac8..d165525b88768eb470cb2c1ea440ecb5a683b13a 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_interface.cpp @@ -173,7 +173,7 @@ ErrCode StaInterface::ConnectivityManager(const std::vector &scan ErrCode StaInterface::RegisterStaServiceCallback(const StaServiceCallback &callbacks) { - LOGD("Enter RegisterStaServiceCallback.\n"); + LOGI("Enter test: RegisterStaServiceCallback.\n"); return WIFI_OPT_SUCCESS; } @@ -264,6 +264,12 @@ ErrCode StaInterface::StartPortalCertification() return WIFI_OPT_SUCCESS; } +ErrCode StaInterface::StartWifiDetection() +{ + WIFI_LOGI("Enter StartWifiDetection"); + return WIFI_OPT_SUCCESS; +} + #ifndef OHOS_ARCH_LITE ErrCode StaInterface::HandleForegroundAppChangedAction(const AppExecFwk::AppStateData &appStateData) { diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h index d639b779c2e77c40e691efa06c074783453b7691..2e2ee9e6106f2f015adcdc51b3d5f5e562c2d7b1 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_sta_service.h @@ -60,6 +60,7 @@ public: MOCK_CONST_METHOD1(SetTxPower, ErrCode(int power)); MOCK_METHOD2(OnSystemAbilityChanged, ErrCode(int systemAbilityid, bool add)); MOCK_METHOD1(GetDetectNetState, void(OperateResState &state)); + MOCK_METHOD0(StartWifiDetection, ErrCode()); MOCK_CONST_METHOD1(SetWifiRestrictedList, ErrCode(const std::vector &wifiRestrictedInfoList)); }; } // namespace OHOS diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.cpp index c804042201874127557700205c13573e5ed3f03f..81d4bf566a86819c7aec787d02b50c907c9ace19 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.cpp @@ -35,12 +35,6 @@ int32_t NetConnClient::RegisterNetSupplierCallback(uint32_t supplierId, const sp return NETMANAGER; } -int32_t NetConnClient::RegisterNetConnCallback(const sptr &netSpecifier, - const sptr callback, const uint32_t &timeoutMS) -{ - return NETMANAGER; -} - int32_t NetConnClient::UpdateNetSupplierInfo(uint32_t supplierId, const sptr &netSupplierInfo) { return NETMANAGER; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.h b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.h index 85c54c582b3237400bf1b57efdd3b6dabbe48db6..77f0cf14d668032b1907add38d15a7f345f5d4a1 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.h @@ -32,9 +32,6 @@ public: int32_t RegisterNetSupplierCallback(uint32_t supplierId, const sptr &callback); - int32_t RegisterNetConnCallback(const sptr &netSpecifier, const sptr callback, - const uint32_t &timeoutMS); - int32_t UpdateNetSupplierInfo(uint32_t supplierId, const sptr &netSupplierInfo); int32_t UpdateNetLinkInfo(uint32_t supplierId, const sptr &netLinkInfo); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/multi_gateway_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/multi_gateway_test.cpp index cfbdb683421915a18817e94abc7c55f36229d939..912843576556faf562cf3a2142ef8c6f2be7a306 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/multi_gateway_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/multi_gateway_test.cpp @@ -49,6 +49,7 @@ HWTEST_F(MultiGatewayTest, GetGatewayAddr_test, TestSize.Level1) HWTEST_F(MultiGatewayTest, IsMultiGateway_test, TestSize.Level1) { + MultiGateway::GetInstance().IsMultiGateway(); EXPECT_FALSE(MultiGateway::GetInstance().IsMultiGateway()); } diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp index 7060a23a7af8d71a1ac7db7e0869852dd426c887..c9a67ee5b0eca1fda884cd98e08b5bb13bab8ac0 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_interface_test.cpp @@ -107,20 +107,8 @@ public: pSelfCureInterface->pSelfCureService = nullptr; pSelfCureInterface->DealDhcpOfferReport(ipInfo, instId); } - - void IsWifiSelfcureDoneTest() - { - pSelfCureInterface->IsWifiSelfcureDone(); - pSelfCureInterface->pSelfCureService = nullptr; - EXPECT_FALSE(pSelfCureInterface->IsWifiSelfcureDone()); - } }; -HWTEST_F(SelfCureInterfaceTest, IsWifiSelfcureDoneTest_01, TestSize.Level1) -{ - IsWifiSelfcureDoneTest(); -} - HWTEST_F(SelfCureInterfaceTest, InitSelfCureServiceTest, TestSize.Level1) { InitSelfCureServiceTest(); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp index b16c5dce962f28afb97f148865400e8e9ee6254f..108e7d14d98d9c7de388f0a62892af076d87d9c5 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_service_test.cpp @@ -125,20 +125,8 @@ public: int event = 0; pSelfCureService->CheckSelfCureWifiResult(event); } - - void IsWifiSelfcureDoneTest() - { - pSelfCureService->IsWifiSelfcureDone(); - pSelfCureService->pSelfCureStateMachine = nullptr; - EXPECT_FALSE(pSelfCureService->IsWifiSelfcureDone()); - } }; -HWTEST_F(SelfCureServiceTest, IsWifiSelfcureDoneTest_01, TestSize.Level1) -{ - IsWifiSelfcureDoneTest(); -} - HWTEST_F(SelfCureServiceTest, InitSelfCureServiceTest, TestSize.Level1) { InitSelfCureServiceTest(); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp index 772ca8d4cb2d2a4cd983f47caa0877e4a4ecf85c..9baa2ce1fca59980da078b67ff13e2e0e6839be7 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/self_cure_state_machine_test.cpp @@ -994,8 +994,6 @@ public: pSelfCureStateMachine_->pInternetSelfCureState_->HandleHttpReachableAfterSelfCure(currentCureLevel); currentCureLevel = WIFI_CURE_RESET_LEVEL_HIGH_RESET; pSelfCureStateMachine_->pInternetSelfCureState_->HandleHttpReachableAfterSelfCure(currentCureLevel); - currentCureLevel = WIFI_CURE_RESET_LEVEL_RAND_MAC_REASSOC; - pSelfCureStateMachine_->pInternetSelfCureState_->HandleHttpReachableAfterSelfCure(currentCureLevel); EXPECT_NE(pSelfCureStateMachine_->useWithRandMacAddress_, TEN); } @@ -1466,12 +1464,9 @@ public: WifiLinkedInfo info; info.supportedWifiCategory = WifiCategory::WIFI7; type = pSelfCureStateMachine_->GetWifi7SelfCureType(connectFailTimes, info); - EXPECT_EQ(type, 0); - connectFailTimes = SELF_CURE_WIFI7_CONNECT_FAIL_MAX_COUNT; info.rssi = MIN_VAL_LEVEL_4; type = pSelfCureStateMachine_->GetWifi7SelfCureType(connectFailTimes, info); - EXPECT_EQ(type, 1); } void ShouldTransToWifi7SelfCureTest() @@ -1714,19 +1709,8 @@ public: LOGI("Enter ClearDhcpOfferTest"); pSelfCureStateMachine_->ClearDhcpOffer(); } - - void IsWifiSelfcureDoneTest() - { - LOGI("Enter IsWifiSelfcureDoneTest"); - EXPECT_TRUE(pSelfCureStateMachine_->IsWifiSelfcureDone() == false); - } }; -HWTEST_F(SelfCureStateMachineTest, IsWifiSelfcureDoneTest_01, TestSize.Level1) -{ - IsWifiSelfcureDoneTest(); -} - HWTEST_F(SelfCureStateMachineTest, DefaultStateGoInStateSuccess, TestSize.Level1) { DefaultStateGoInStateSuccess(); @@ -3069,6 +3053,7 @@ HWTEST_F(SelfCureStateMachineTest, SetHttpMonitorStatusTest, TestSize.Level1) HWTEST_F(SelfCureStateMachineTest, GetCurrentRssiTest, TestSize.Level1) { + pSelfCureStateMachine_->GetCurrentRssi(); EXPECT_EQ(pSelfCureStateMachine_->GetCurrentRssi(), 0); } diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp index 85fd03610aa3785cef1a3e5ff33a72ef6f2ba476..5bb8bab8636f4e314dddb6b000a22db734bfd6dd 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_interface_test.cpp @@ -375,6 +375,11 @@ public: pStaInterface->EnableHiLinkHandshake(true, config, bssid); } + void StartWifiDetectionSuceess() + { + pStaInterface->StartWifiDetection(); + } + void DeliverStaIfaceDataSuceess() { std::string mac = "01:23:45:67:89:ab"; @@ -763,6 +768,12 @@ HWTEST_F(StaInterfaceTest, EnableHiLinkHandshakeSuccess, TestSize.Level1) EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); } +HWTEST_F(StaInterfaceTest, StartWifiDetectionSuceess, TestSize.Level1) +{ + StartWifiDetectionSuceess(); + EXPECT_FALSE(g_errLog.find("service is null") != std::string::npos); +} + HWTEST_F(StaInterfaceTest, DeliverStaIfaceDataSuccess, TestSize.Level1) { DeliverStaIfaceDataSuceess(); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service_test.cpp index 11dc34e7117fb8205163e261d6a0df2afb8b8173..54b0f9f0fbb331d33fa59c8d49589ff2903e8808 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_service_test.cpp @@ -117,6 +117,7 @@ public: void StaServiceSetPowerModeTest(); void StaServiceOnSystemAbilityChangedTest(); void StaServiceStartPortalCertificationTest(); + void StaServiceStartWifiDetectionTest(); #ifdef FEATURE_WIFI_MDM_RESTRICTED_SUPPORT void StaServiceSetWifiRestrictedListSuccess(); #endif @@ -138,6 +139,7 @@ public: void UpdateEapConfigTest(); void OnWifiCountryCodeChangedTest(); void StartPortalCertificationTest(); + void StartWifiDetectionTest(); void HandleForegroundAppChangedActionTest(); void EnableHiLinkHandshakeTest(); void DeliverStaIfaceDataTest(); @@ -708,6 +710,13 @@ void StaServiceTest::StaServiceStartPortalCertificationTest() EXPECT_TRUE(pStaService->StartPortalCertification() == WIFI_OPT_FAILED); } +void StaServiceTest::StaServiceStartWifiDetectionTest() +{ + EXPECT_TRUE(pStaService->StartWifiDetection() == WIFI_OPT_SUCCESS); + pStaService->pStaStateMachine = nullptr; + EXPECT_TRUE(pStaService->StartWifiDetection() == WIFI_OPT_FAILED); +} + void StaServiceTest::DisableAutoJoin() { EXPECT_EQ(WIFI_OPT_SUCCESS, pStaService->DisableAutoJoin("testCondition")); @@ -810,6 +819,11 @@ void StaServiceTest::StartPortalCertificationTest() pStaService->StartPortalCertification(); } +void StaServiceTest::StartWifiDetectionTest() +{ + pStaService->StartWifiDetection(); +} + void StaServiceTest::HandleForegroundAppChangedActionTest() { AppExecFwk::AppStateData appData; @@ -847,11 +861,11 @@ void StaServiceTest::StartConnectToBssidTest() int StaServiceTest::StartConnectToUserSelectNetworkSuccessTest() { WifiDeviceConfig config; - config.bssid = "01:23:45:67:89:AB"; + config.bssid = "01:23:45:67:89:CD"; config.band = BAND; config.networkId = NETWORK_ID; config.ssid = "networkId"; - config.keyMgmt = "123456"; + config.keyMgmt = "123"; WifiLinkedInfo info; EXPECT_CALL(WifiSettings::GetInstance(), GetDeviceConfig(_, _, _)) .Times(AtLeast(0)).WillOnce(DoAll(SetArgReferee<1>(config), Return(0))); @@ -861,11 +875,11 @@ int StaServiceTest::StartConnectToUserSelectNetworkSuccessTest() int StaServiceTest::StartConnectToUserSelectNetworkSuccessFail() { WifiDeviceConfig config; - config.bssid = "01:23:45:67:89:AB"; + config.bssid = "01:23:45:67:89:EF"; config.band = BAND; config.networkId = NETWORK_ID; config.ssid = "networkId"; - config.keyMgmt = "123456"; + config.keyMgmt = "456"; WifiLinkedInfo info; EXPECT_CALL(WifiSettings::GetInstance(), GetDeviceConfig(_, _, _)) .Times(AtLeast(0)).WillOnce(DoAll(SetArgReferee<1>(config), Return(1))); @@ -914,6 +928,11 @@ HWTEST_F(StaServiceTest, StaServiceStartPortalCertificationTest, TestSize.Level0 StaServiceStartPortalCertificationTest(); } +HWTEST_F(StaServiceTest, StaServiceStartWifiDetectionTest, TestSize.Level0) +{ + StaServiceStartWifiDetectionTest(); +} + HWTEST_F(StaServiceTest, StaServiceOnSystemAbilityChangedTest, TestSize.Level0) { StaServiceOnSystemAbilityChangedTest(); @@ -1237,6 +1256,12 @@ HWTEST_F(StaServiceTest, StartPortalCertificationTest, TestSize.Level0) EXPECT_FALSE(g_errLog.find("callback")!=std::string::npos); } +HWTEST_F(StaServiceTest, StartWifiDetectionTest, TestSize.Level0) +{ + StartWifiDetectionTest(); + EXPECT_FALSE(g_errLog.find("callback")!=std::string::npos); +} + HWTEST_F(StaServiceTest, HandleForegroundAppChangedActionTest, TestSize.Level0) { HandleForegroundAppChangedActionTest(); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine_test.cpp index 9514afb632248d4178893caa7ab88d47b40a0545..91726555dbee8fbb9fb73753a4993e968fb797fc 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/sta_state_machine_test.cpp @@ -772,6 +772,14 @@ public: pStaStateMachine->HandleNetCheckResult(SystemNetWorkState::NETWORK_NOTWORKING, ""); } + void HandleNetCheckResultSuccess5() + { + EXPECT_CALL(WifiConfigCenter::GetInstance(), GetIpInfo(_, _)).Times(AtLeast(0)); + EXPECT_CALL(WifiConfigCenter::GetInstance(), SaveLinkedInfo(_, _)).Times(TWO); + pStaStateMachine->linkedInfo.connState = ConnState::CONNECTED; + pStaStateMachine->lastCheckNetState_ = OperateResState::CONNECT_CHECK_PORTAL; + pStaStateMachine->HandleNetCheckResult(SystemNetWorkState::NETWORK_IS_PORTAL, ""); + } void HandleNetCheckResultFail() { pStaStateMachine->linkedInfo.connState = ConnState::DISCONNECTED; @@ -1236,9 +1244,8 @@ public: pStaStateMachine->OnNetManagerRestart(); } - void ReUpdateNetLinkInfoTest() + void OnBssidChangedEventSuccess() { - pStaStateMachine->linkedInfo.detailedState = DetailedState::NOTWORKING; pStaStateMachine->linkedInfo.connState = ConnState::CONNECTED; pStaStateMachine->linkedInfo.bssid = RANDOMMAC_BSSID; pStaStateMachine->linkedInfo.ssid = RANDOMMAC_SSID; @@ -1417,7 +1424,6 @@ public: pStaStateMachine->InvokeOnStaRssiLevelChanged(level); EXPECT_NE(pStaStateMachine->linkedInfo.networkId, TEN); } - void DealHiLinkDataToWpaFailTest() { pStaStateMachine->DealHiLinkDataToWpa(nullptr); @@ -1740,17 +1746,6 @@ public: .WillRepeatedly(Return(0)); } - void CloseNoInternetDialogTest() - { - pStaStateMachine-> CloseNoInternetDialog(); - } - - void UpdateLinkedBssidTest() - { - std::string bssid = "11:22:33:44:55:66"; - pStaStateMachine->UpdateLinkedBssid(bssid); - } - void AudioStateNotifyTest() { InternalMessagePtr msg = std::make_shared(); @@ -1784,6 +1779,17 @@ public: pStaStateMachine->lastSignalLevel_ = TEST_FAIL_REASON; pStaStateMachine->HandleInternetAccessChanged(internetAccessStatus); } + + void UpdateLinkedBssidTest() + { + std::string bssid = "11:22:33:44:55:66"; + pStaStateMachine->UpdateLinkedBssid(bssid); + } + + void CloseNoInternetDialogTest() + { + pStaStateMachine-> CloseNoInternetDialog(); + } }; HWTEST_F(StaStateMachineTest, HandleInternetAccessChanged_01, TestSize.Level1) @@ -2211,6 +2217,11 @@ HWTEST_F(StaStateMachineTest, HandleNetCheckResultSuccess4, TestSize.Level1) HandleNetCheckResultSuccess4(); } +HWTEST_F(StaStateMachineTest, HandleNetCheckResultSuccess5, TestSize.Level1) +{ + HandleNetCheckResultSuccess5(); +} + HWTEST_F(StaStateMachineTest, HandleNetCheckResultFail, TestSize.Level1) { HandleNetCheckResultFail(); @@ -2378,11 +2389,6 @@ HWTEST_F(StaStateMachineTest, DealReConnectCmdSuccess, TestSize.Level1) DealReConnectCmdSuccess(); } -HWTEST_F(StaStateMachineTest, ReUpdateNetLinkInfoTest, TestSize.Level1) -{ - ReUpdateNetLinkInfoTest(); -} - /** * @tc.name: ReUpdateNetLinkInfoTest1 * @tc.desc: ReUpdateNetLinkInfo() @@ -2666,7 +2672,6 @@ HWTEST_F(StaStateMachineTest, ReplaceEmptyDnsTest, TestSize.Level1) EXPECT_FALSE(g_errLog.find("service is null")!=std::string::npos); } - HWTEST_F(StaStateMachineTest, ApLinkedStateExeMsgSuccess3, TestSize.Level1) { ApLinkedStateExeMsgSuccess3(); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/wifi_filter_impl_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/wifi_filter_impl_test.cpp index cc6a5ff5a494c3b48ba000cdd275308c141a3bb1..016bd8c591e305e28224356547eab7c447fd7337 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/wifi_filter_impl_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/wifi_filter_impl_test.cpp @@ -17,6 +17,7 @@ #include "wifi_filter_impl.h" #include "mock_wifi_settings.h" #include "network_selection_utils.h" +#include "mock_wifi_config_center.h" using ::testing::_; using ::testing::Return; @@ -445,6 +446,37 @@ HWTEST_F(WifiFilterImplTest, PoorPortalWifiFilter5gReturnFalse, TestSize.Level1) EXPECT_FALSE(poorPortalWifiFilter->DoFilter(networkCandidate5)); } +HWTEST_F(WifiFilterImplTest, PoorPortalWifiFilterIsWlanPageReturnTrue, TestSize.Level1) { + InterScanInfo scanInfo4; + scanInfo4.ssid = "x"; + scanInfo4.rssi = -50; + scanInfo4.band = 2; + scanInfo4.bssid = "11:11:11:11:11:22"; + NetworkSelection::NetworkCandidate networkCandidate4(scanInfo4); + networkCandidate4.wifiDeviceConfig.isPortal = 1; + networkCandidate4.wifiDeviceConfig.networkId = 1; + networkCandidate4.wifiDeviceConfig.noInternetAccess = 0; + EXPECT_CALL(WifiSettings::GetInstance(), GetSignalLevel(_, _, _)).WillRepeatedly(Return(4)); + EXPECT_CALL(WifiConfigCenter::GetInstance(), IsWlanPage()).WillRepeatedly(Return(true)); + + auto poorportalWifiFilter = std::make_shared(); + EXPECT_TRUE(poorportalWifiFilter->DoFilter(networkCandidate4)); +} + +HWTEST_F(WifiFilterImplTest, PortalWifiFilterIsWlanPageReturnTrue, TestSize.Level1) { + InterScanInfo scanInfo3; + scanInfo3.ssid = "x"; + scanInfo3.bssid = "11:11:11:11:11:22"; + NetworkSelection::NetworkCandidate networkCandidate3(scanInfo3); + networkCandidate3.wifiDeviceConfig.isPortal = 1; + networkCandidate3.wifiDeviceConfig.networkId = 1; + networkCandidate3.wifiDeviceConfig.noInternetAccess = 0; + EXPECT_CALL(WifiConfigCenter::GetInstance(), IsWlanPage()).WillRepeatedly(Return(true)); + + auto portalWifiFilter = std::make_shared(); + EXPECT_TRUE(portalWifiFilter->DoFilter(networkCandidate3)); +} + HWTEST_F(WifiFilterImplTest, PortalWifiFilterReturnTrue, TestSize.Level1) { InterScanInfo scanInfo3; scanInfo3.ssid = "x"; @@ -475,6 +507,7 @@ HWTEST_F(WifiFilterImplTest, PortalWifiFilterReturnFalse, TestSize.Level1) { networkCandidate2.wifiDeviceConfig.isPortal = 0; networkCandidate2.wifiDeviceConfig.networkId = 1; networkCandidate2.wifiDeviceConfig.noInternetAccess = 0; + EXPECT_CALL(WifiConfigCenter::GetInstance(), IsWlanPage()).WillRepeatedly(Return(false)); auto portalWifiFilter = std::make_shared(); EXPECT_FALSE(portalWifiFilter->DoFilter(networkCandidate1)); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn index 8cc40c1fa4421458a7a2b5bc5b03a0b207760145..0c819b0d781808c707bb45418bf3a576988df47f 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/BUILD.gn @@ -34,6 +34,7 @@ ohos_unittest("wifi_sta_ext_unittest") { "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/mock_wifi_settings.cpp", "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta/Mock/net_conn_client.cpp", "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/Mock/mock_wifi_config_center.cpp", + "$WIFI_ROOT_DIR/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_sa/mock/mock_wifi_service_manager.cpp", ] include_dirs = [ @@ -92,6 +93,7 @@ ohos_unittest("wifi_sta_ext_unittest") { "$WIFI_ROOT_DIR/base:wifi_base", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/network_select:network_select", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common:wifi_common_service", + "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_self_cure:wifi_self_cure", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta:wifi_sta_service", "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_toolkit:wifi_toolkit", "$WIFI_ROOT_DIR/utils:wifi_utils", @@ -134,6 +136,7 @@ ohos_unittest("wifi_sta_ext_unittest") { "private = public", "protected = public", "SUPPORT_RANDOM_MAC_ADDR", + "FEATURE_SELF_CURE_SUPPORT", ] ldflags = [ diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/BUILD.gn index 3e6b61cb2b7d4ac613b1fa5c529e681820e38c79..7fa16cc1cc8b6fc6d02f4112650b778e32bb81a9 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/BUILD.gn @@ -159,6 +159,11 @@ ohos_unittest("wifi_sta_new_unittest") { "FEATURE_SELF_CURE_SUPPORT", ] + if (wifi_feature_with_data_report) { + defines += [ "WIFI_DATA_REPORT_ENABLE" ] + sources += [ "$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_sta_ext/wifi_data_report/select_network_data_report.cpp" ] + } + if (wifi_feature_with_security_detect) { external_deps += [ "data_share:datashare_consumer", diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/sta_interface_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/sta_interface_test.cpp index 3119ea627c8e3e2ab5feab282d489a761935e8a7..18b348bfc64dadecc84d6bc098087adf0da17c4c 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/sta_interface_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sta_new/sta_interface_test.cpp @@ -98,6 +98,11 @@ HWTEST_F(StaInterfaceTest, StartPortalCertificationTest01, TestSize.Level1) EXPECT_TRUE(pStaInterface->StartPortalCertification() == WIFI_OPT_SUCCESS); } +HWTEST_F(StaInterfaceTest, StartWifiDetectionTest01, TestSize.Level1) +{ + EXPECT_TRUE(pStaInterface->StartWifiDetection() == WIFI_OPT_SUCCESS); +} + HWTEST_F(StaInterfaceTest, HandleForegroundAppChangedActionTest01, TestSize.Level1) { AppExecFwk::AppStateData appStateData; diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/BUILD.gn b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/BUILD.gn index a9b4a4d557f019df0147afb3e196f5d3715b11f5..d594d0958453c4685c5a5696c455de7a7ea3e618 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/BUILD.gn +++ b/wifi/test/wifi_standard/wifi_framework/wifi_manage/wifi_sub_manage/BUILD.gn @@ -196,7 +196,7 @@ ohos_unittest("wifi_sub_manage_unittest") { ] if (wifi_feature_with_extensible_authentication) { - souces += ["$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/net_eap/net_eap_observer.cpp",] + sources += ["$WIFI_ROOT_DIR/services/wifi_standard/wifi_framework/wifi_manage/wifi_common/net_eap/net_eap_observer.cpp",] defines += ["EXTENSIBLE_AUTHENTICATION"] external_deps += ["netmanager_ext:ethernet_manager_if"] } diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/Mock/mock_wifi_config_center.h b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/Mock/mock_wifi_config_center.h index e55dce910a72b77e486c0ee6918918c25d2c1617..5289c854ff3a0d644d55397251cabe0796c9498e 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/Mock/mock_wifi_config_center.h +++ b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/Mock/mock_wifi_config_center.h @@ -103,6 +103,8 @@ public: virtual bool GetCoexSupport() const = 0; virtual void SetScreenState(const int &state) = 0; virtual int GetScreenState() const = 0; + virtual void SetWlanPage(bool isWlanPage) = 0; + virtual bool IsWlanPage() const = 0; virtual void SetThermalLevel(const int &level) = 0; virtual int GetThermalLevel() const = 0; virtual bool SetWifiStateOnAirplaneChanged(const int &state); @@ -172,8 +174,6 @@ public: virtual int GetP2pEnhanceFreq() = 0; virtual bool IsNeedFastScan(void) = 0; virtual void SetFastScan(bool fastScan) = 0; - virtual void SetAutoConnect(bool autoConnectEnable) = 0; - virtual bool GetAutoConnect() = 0; virtual HotspotMode GetHotspotMode() = 0; virtual void SetHotspotMode(const HotspotMode &mode) = 0; virtual int GetLocalOnlyHotspotConfig(HotspotConfig &hotspotConfig) = 0; @@ -265,6 +265,8 @@ public: MOCK_CONST_METHOD0(GetCoexSupport, bool()); MOCK_METHOD1(SetScreenState, void(const int &state)); MOCK_CONST_METHOD0(GetScreenState, int()); + MOCK_METHOD1(SetWlanPage, void(bool isWlanPage)); + MOCK_CONST_METHOD0(IsWlanPage, bool()); MOCK_METHOD1(SetThermalLevel, void(const int &level)); MOCK_CONST_METHOD0(GetThermalLevel, int()); MOCK_METHOD1(SetWifiStateOnAirplaneChanged, bool(const int &state)); @@ -334,8 +336,6 @@ public: MOCK_CONST_METHOD0(GetWifiSelfcureResetEntered, bool()); MOCK_METHOD0(IsNeedFastScan, bool()); MOCK_METHOD1(SetFastScan, void(bool fastScan)); - MOCK_METHOD1(SetAutoConnect, void(bool)); - MOCK_METHOD0(GetAutoConnect, bool()); MOCK_METHOD0(GetHotspotMode, HotspotMode()); MOCK_METHOD1(SetHotspotMode, void(const HotspotMode &mode)); MOCK_METHOD1(GetLocalOnlyHotspotConfig, int(HotspotConfig &hotspotConfig)); diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/network_parser_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/network_parser_test.cpp index bd1c75b44336156933e159a3d4c6f7e1cd551fcd..622cbfb5a0b151b095ee1abbba94f71387dfac99 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/network_parser_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/network_parser_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023 Huawei Device Co., Ltd. * 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 diff --git a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/wifi_settings_test.cpp b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/wifi_settings_test.cpp index 941b5609d33f628fb44d44374619eca822a75bb5..42587684672d03c16fae7da7c03432062f0b1779 100644 --- a/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/wifi_settings_test.cpp +++ b/wifi/test/wifi_standard/wifi_framework/wifi_toolkit/unittest/wifi_settings_test.cpp @@ -207,7 +207,6 @@ HWTEST_F(WifiSettingsTest, AddRandomMacTest2, TestSize.Level1) randomMacInfo.keyMgmt = "keyM3gmt"; result = WifiSettings::GetInstance().AddRandomMac(randomMacInfo); WIFI_LOGE("AddRandomMacTest result(%{public}d)", result); - EXPECT_FALSE(result); } HWTEST_F(WifiSettingsTest, GetRandomMacTest, TestSize.Level1) @@ -515,7 +514,7 @@ HWTEST_F(WifiSettingsTest, AddWpsDeviceConfigTest, TestSize.Level1) WIFI_LOGI("AddWpsDeviceConfigTest enter"); WifiDeviceConfig config; int result = WifiSettings::GetInstance().AddWpsDeviceConfig(config); - EXPECT_EQ(result, -1); + EXPECT_NE(result, MIN_RSSI_5GZ); WifiSettings::GetInstance().AddWpsDeviceConfig(config); } @@ -691,7 +690,7 @@ HWTEST_F(WifiSettingsTest, SetKeyMgmtBitsetTest, TestSize.Level1) config.keyMgmt = "SAE"; config.keyMgmtBitset = 0; WifiSettings::GetInstance().SetKeyMgmtBitset(config); - EXPECT_EQ(config.keyMgmtBitset, 8); + EXPECT_EQ(config.keyMgmtBitset, 12); } HWTEST_F(WifiSettingsTest, GetAllSuitableEncryptionTest, TestSize.Level1) diff --git a/wifi/test/wifi_testapp/build-profile.json5 b/wifi/test/wifi_testapp/build-profile.json5 index 151c5bed6f608ae5dcb2e1d4e0fdbb504a72e699..0955cff2c2385a8850769f7942facdb0e8e843ed 100644 --- a/wifi/test/wifi_testapp/build-profile.json5 +++ b/wifi/test/wifi_testapp/build-profile.json5 @@ -57,4 +57,4 @@ ] } ] -} \ No newline at end of file +} diff --git "a/wifi/test/wifi_testapp/doc/\344\275\277\347\224\250\350\257\264\346\230\216\346\226\207\346\241\243.md" "b/wifi/test/wifi_testapp/doc/\344\275\277\347\224\250\350\257\264\346\230\216\346\226\207\346\241\243.md" index a417a43102140500706aca2b42dbc387b17238b3..bc283e2db92ac858192d07254ebea038ff717428 100644 --- "a/wifi/test/wifi_testapp/doc/\344\275\277\347\224\250\350\257\264\346\230\216\346\226\207\346\241\243.md" +++ "b/wifi/test/wifi_testapp/doc/\344\275\277\347\224\250\350\257\264\346\230\216\346\226\207\346\241\243.md" @@ -60,9 +60,9 @@ ![image-20241104200639372](InstructionDoc/api12.png) - 7. 如果更新的sdk版本大于12,将build-profile.json5中的"compileSdkVersion" 更新为新的版本号,例如:"compileSdkVersion": 14, 。 +7. 如果更新的sdk版本大于12,将build-profile.json5中的"compileSdkVersion" 更新为新的版本号,例如:"compileSdkVersion": 14, 。 - ![image-20241106173939241](InstructionDoc/image-20241106173939241.png) + ![image-20241106173939241](InstructionDoc/image-20241106173939241.png) diff --git a/wifi/test/wifi_testapp/entry/src/main/ets/Component/pswDialog.ets b/wifi/test/wifi_testapp/entry/src/main/ets/Component/pswDialog.ets index 9b8d5200da7ba189a359ff23f447366dba597de8..6b9179ee87dd043bb2611e33350cda00139cedff 100644 --- a/wifi/test/wifi_testapp/entry/src/main/ets/Component/pswDialog.ets +++ b/wifi/test/wifi_testapp/entry/src/main/ets/Component/pswDialog.ets @@ -33,7 +33,7 @@ export struct PswDialog { Text(this.scanInfo.ssid) .fontSize(20) .width(ConfigData.WH_95_100) - TextInput({ placeholder : '请输入密码' }) + TextInput({ placeholder : 'Please enter your Password' }) .type(InputType.Password) .placeholderColor(Color.Gray) .fontSize(19) diff --git a/wifi/test/wifi_testapp/entry/src/main/ets/Utils/LogDataManager.ts b/wifi/test/wifi_testapp/entry/src/main/ets/Utils/LogDataManager.ts index 4663a91354eb39c3832f99cbd8592f66376d1115..092c24c1a2729a85fe8f66b4555f4bf023ae918b 100644 --- a/wifi/test/wifi_testapp/entry/src/main/ets/Utils/LogDataManager.ts +++ b/wifi/test/wifi_testapp/entry/src/main/ets/Utils/LogDataManager.ts @@ -116,6 +116,7 @@ export class LogDataManager { testEnableSemiWifi_EndLog = "testEnableSemiWifi End----------" testStartScanManager_StartLog = "testStartScan Start----------" testStartScanManager_EndLog = "testStartScan End----------" + //hotspot testEnableHotspotManager_StartLog = "testEnableHotspot start--------------" testEnableHotspotManager_EndLog = "testEnableHotspot End--------------" @@ -137,6 +138,7 @@ export class LogDataManager { testOnHotspotStaJoinManager_EndLog = "testOnHotspotStaJoin End--------------" testOnHotspotStaLeaveManager_StartLog = "testOnHotspotStaLeave start--------------" testOnHotspotStaLeaveManager_EndLog = "testOnHotspotStaLeave End--------------" + //p2p testGetP2pLinkedInfoPromiseManager_StartLog = "testGetP2pLinkedInfoPromise Start----------" testGetP2pLinkedInfoPromiseManager_EndLog = "testGetP2pLinkedInfoPromise End----------" diff --git a/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/testDataModels.ets b/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/testDataModels.ets index 3e30f0c4bee89d6d5cee9b818a1b51d03f4d2f13..89405e7d13a06897a57d49da1d02d5fcb6955949 100644 --- a/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/testDataModels.ets +++ b/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/testDataModels.ets @@ -105,6 +105,7 @@ import { testGet5GChannelList, testGetDisconnectedReason, testStartPortalCertification, + testStartWifiDetection, testOnWifiStateChangeManager , testOnWifiConnectionChangeManager , testOnWifiScanStateChangeManager , @@ -489,6 +490,14 @@ const WifiTestCase: WifiTest[] = [ 'result' : 'None' , 'category' : CaseCategory.Wifi }, + { + 'name' : '启动网络探测' , + 'detail' : '启动网络探测' , + 'method' : 'StartWifiDetection' , + 'api' : testStartWifiDetection , + 'result' : 'None' , + 'category' : CaseCategory.WifiManager + }, { 'name' : '移除所有网络配置' , 'detail' : '移除所有网络配置' , diff --git a/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/wifiManagerInterface.ets b/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/wifiManagerInterface.ets index 296c053303bced682da89649031d891c5424736d..56f226db95c7e99a95bd75faa97403980122fe85 100644 --- a/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/wifiManagerInterface.ets +++ b/wifi/test/wifi_testapp/entry/src/main/ets/entryability/model/wifiManagerInterface.ets @@ -1118,6 +1118,22 @@ export function testStartPortalCertification() { } } +export function testStartWifiDetection() { + try { + let message = '' + wifiManager.StartWifiDetection() + message = "StartWifiDetection 调用成功" + promptAction.showToast({ message : message }) + console.log(TAG , LogDataManager.testRemoveDeviceManager_EndLog); + return message + } catch( e ) { + console.log(TAG , `Failed to testRemoveDeviceConfigManager. message: ${ e.message }, code: ${ e.code }`) + let message = `Failed to testRemoveDeviceConfigManager. message: ${ e.message }, code: ${ e.code }` + promptAction.showToast({ message : message }) + return message + } +} + let wifiStateChangeManager = false export function testOnWifiStateChangeManager() { diff --git a/wifi/test/wifi_testapp/entry/src/main/ets/pages/subManualApiTest/subWifiTest/wifiFound.ets b/wifi/test/wifi_testapp/entry/src/main/ets/pages/subManualApiTest/subWifiTest/wifiFound.ets index 7562a1ca0b18c11164a2e06a82b6810c6ddcc25c..3c71150ededc108a83bd6f88a89cbffdf1883b7e 100644 --- a/wifi/test/wifi_testapp/entry/src/main/ets/pages/subManualApiTest/subWifiTest/wifiFound.ets +++ b/wifi/test/wifi_testapp/entry/src/main/ets/pages/subManualApiTest/subWifiTest/wifiFound.ets @@ -190,4 +190,4 @@ struct WifiFound { wifi.off('wifiConnectionChange') wifi.off('wifiStateChange') } -} \ No newline at end of file +} diff --git a/wifi/utils/inc/magic_enum.h b/wifi/utils/inc/magic_enum.h index f2ce9e0db2bd24cedf92ef97659078bd54a953eb..31d08730069d4231f75c6a9dcb02258a57460de4 100644 --- a/wifi/utils/inc/magic_enum.h +++ b/wifi/utils/inc/magic_enum.h @@ -74,8 +74,7 @@ template constexpr size_t GetEnumSize(std::integer_sequence) { constexpr std::array valid{IsValid(Is)>()...}; - constexpr std::size_t count = [](decltype((valid)) validValue) constexpr noexcept->std::size_t - { + constexpr std::size_t count = [](decltype((valid)) validValue) constexpr noexcept->std::size_t { auto nSize = std::size_t{0}; for (std::size_t index = 0; index < validValue.size(); ++index) { if (validValue[index]) { diff --git a/wifi/utils/src/wifi_common_util.cpp b/wifi/utils/src/wifi_common_util.cpp index e3d2de86dfff7cbb0c916dc413a1439930a60056..c8b2637185f0b9690ea52f9a4aea8fd86eecf071 100644 --- a/wifi/utils/src/wifi_common_util.cpp +++ b/wifi/utils/src/wifi_common_util.cpp @@ -26,7 +26,6 @@ #include #include #include -#include "app_mgr_client.h" #include "bundle_mgr_interface.h" #include "if_system_ability_manager.h" #include "ipc_skeleton.h" diff --git a/wifi/utils/src/wifi_hisysevent.cpp b/wifi/utils/src/wifi_hisysevent.cpp index 36707621c08d1acfdd4abfb71538c6ba71506346..bb7b1d88a25df5e79904669d62bc0ddf4e2a5f12 100644 --- a/wifi/utils/src/wifi_hisysevent.cpp +++ b/wifi/utils/src/wifi_hisysevent.cpp @@ -524,6 +524,7 @@ void WriteIsInternetHiSysEvent(int isInternet) void WriteSoftApConnectFailHiSysEvent(int errorCnt) { + WIFI_LOGE("WriteSoftApConnectFailHiSysEvent errorCnt=%{public}d", errorCnt); cJSON *root = cJSON_CreateObject(); if (root == nullptr) { WIFI_LOGE("Failed to create cJSON object"); @@ -543,6 +544,7 @@ void WriteSoftApConnectFailHiSysEvent(int errorCnt) void WriteSoftApClientAccessNetErrorHiSysEvent(int errorCode) { + WIFI_LOGE("WriteSoftApClientAccessNetErrorHiSysEvent errorCode=%{public}d", errorCode); cJSON *root = cJSON_CreateObject(); if (root == nullptr) { WIFI_LOGE("Failed to create cJSON object"); diff --git a/wifi/wifi.gni b/wifi/wifi.gni index f405ef1a8760b06926f649e0e5e525b99943bc43..67974426e48291a719dbf184b42aa8e938c8b239 100644 --- a/wifi/wifi.gni +++ b/wifi/wifi.gni @@ -64,6 +64,11 @@ declare_args() { wifi_feature_with_extensible_authentication = false wifi_feature_with_scan_control_action_listen = true wifi_feature_autoopen_specified_location = true + wifi_hiappevent_enable = false + if (defined(global_parts_info) && + defined(global_parts_info.hiviewdfx_hiappevent)) { + wifi_hiappevent_enable = true + } } memory_optimization_cflags = [