투케이2K

893. (Android/Java) [간단 소스] 안드로이드 하위 버전 (10, Q 버전 미만) WifiConfiguration 옵션 본문

Android

893. (Android/Java) [간단 소스] 안드로이드 하위 버전 (10, Q 버전 미만) WifiConfiguration 옵션

투케이2K 2024. 11. 15. 18:36

[개발 환경 설정]

개발 툴 : AndroidStudio

개발 언어 : Java / Kotlin

 

[소스 코드]

 

// --------------------------------------------------------------------------------------
[개발 및 테스트 환경]
// --------------------------------------------------------------------------------------

- 언어 : Java

- 개발 툴 : Android Studio

- 구분 : 유틸 파일

// --------------------------------------------------------------------------------------






// --------------------------------------------------------------------------------------
[소스 코드]
// --------------------------------------------------------------------------------------

    /**
     * // --------------------------------------------------------------------------------------
     * TODO [안드로이드 하위 버전 : WifiConfiguration 추가 코드 참고]
     * // --------------------------------------------------------------------------------------
     *
     *     public static WifiConfiguration createWifiConfiguration(String ssid, String password, int type) {
     *
     *         WifiConfiguration newWifiConfiguration = new WifiConfiguration(); // [WifiConfiguration 생성]
     *
     *         // [초기 clear 작업 진행] 
     *         newWifiConfiguration.allowedAuthAlgorithms.clear();
     *         newWifiConfiguration.allowedGroupCiphers.clear();
     *         newWifiConfiguration.allowedKeyManagement.clear();
     *         newWifiConfiguration.allowedPairwiseCiphers.clear();
     *         newWifiConfiguration.allowedProtocols.clear();
     *         newWifiConfiguration.SSID = "\"" + ssid + "\"";
     *
     *         // [타입에 맞게 설정 분기 처리 수행]
     *         switch (type) {
     *             case NONE:
     *                 newWifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
     *                 break;
     *             case WEP:
     *                 newWifiConfiguration.wepKeys[0] = "\"" + password + "\"";
     *                 newWifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
     *                 newWifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
     *                 newWifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
     *                 break;
     *             case WPA:
     *                 newWifiConfiguration.preSharedKey = "\"" + password + "\"";
     *                 newWifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
     *                 newWifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
     *                 newWifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
     *                 newWifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
     *                 newWifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
     *                 newWifiConfiguration.status = WifiConfiguration.Status.ENABLED;
     *                 break;
     *             case WPA2:
     *                 newWifiConfiguration.preSharedKey = "\"" + password + "\"";
     *                 newWifiConfiguration.status = WifiConfiguration.Status.ENABLED;
     *                 newWifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
     *                 newWifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
     *                 newWifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
     *                 newWifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
     *                 newWifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
     *                 newWifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
     * //                newWifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
     *                 newWifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
     *                 break;
     *             default:
     *                 return null;
     *         }
     *         return newWifiConfiguration; // [리턴 값 반환]
     *     }
     *
     * // --------------------------------------------------------------------------------------
     * */

// --------------------------------------------------------------------------------------

 

반응형
Comments