1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.tv.settings.connectivity;
17 
18 import android.net.wifi.ScanResult;
19 import android.net.wifi.WifiConfiguration;
20 import android.text.TextUtils;
21 
22 import androidx.annotation.StringRes;
23 import com.android.tv.settings.R;
24 
25 import com.android.tv.settings.library.network.AccessPoint;
26 import com.android.wifitrackerlib.WifiEntry;
27 
28 /** Helper class for Wifi configuration. */
29 class WifiUtils {
30     @StringRes
getConnectionStatus(WifiEntry wifiEntry)31     static int getConnectionStatus(WifiEntry wifiEntry) {
32         if (wifiEntry.canSignIn()) {
33             return R.string.wifi_captive_portal;
34         } else if (wifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED) {
35             return wifiEntry.hasInternetAccess()
36                     ? R.string.connected : R.string.wifi_no_internet;
37         } else if (wifiEntry.shouldEditBeforeConnect()) {
38             return R.string.wifi_bad_password;
39         } else if (wifiEntry.isSaved()) {
40             return R.string.wifi_saved;
41         }
42         return R.string.not_connected;
43     }
44 
WifiUtils()45     private WifiUtils() {}
46 }
47