sdk: Switch to public API getting WiFi SSID
Change-Id: Icd3f05169a8884ea981f0cf1dbf7c024c34c721e
This commit is contained in:
@@ -83,11 +83,7 @@ java_library {
|
||||
] + lineage_sdk_LOCAL_STATIC_ANDROID_LIBRARIES + lineage_sdk_LOCAL_STATIC_JAVA_LIBRARIES,
|
||||
|
||||
libs: [
|
||||
// order matters: classes in framework-wifi are resolved before framework, meaning
|
||||
// @hide APIs in framework-wifi are resolved before @SystemApi stubs in framework
|
||||
"framework-wifi.impl",
|
||||
"framework",
|
||||
|
||||
"services",
|
||||
],
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WifiSsid;
|
||||
import android.os.Message;
|
||||
import android.util.ArraySet;
|
||||
import com.android.internal.policy.IKeyguardService;
|
||||
@@ -200,6 +199,16 @@ public class ProfileManagerService extends LineageSystemService {
|
||||
if (selectProfile) mActiveProfile.doSelect(mContext, mKeyguardService);
|
||||
}
|
||||
|
||||
private String removeDoubleQuotes(String string) {
|
||||
final int length = string.length();
|
||||
if (length >= 2) {
|
||||
if (string.startsWith("\"") && string.endsWith("\"")) {
|
||||
return string.substring(1, length - 1);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
private String getActiveSSID() {
|
||||
final WifiManager wifiManager
|
||||
= (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||
@@ -207,11 +216,7 @@ public class ProfileManagerService extends LineageSystemService {
|
||||
if (wifiinfo == null) {
|
||||
return null;
|
||||
}
|
||||
final WifiSsid ssid = wifiinfo.getWifiSsid();
|
||||
if (ssid == null) {
|
||||
return null;
|
||||
}
|
||||
return ssid.toString();
|
||||
return removeDoubleQuotes(wifiinfo.getSSID());
|
||||
}
|
||||
|
||||
private class ProfilesObserver extends ContentObserver {
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.database.ContentObserver;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WifiSsid;
|
||||
import android.os.Handler;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
@@ -108,7 +107,7 @@ public class ProfileTriggerHelper extends BroadcastReceiver {
|
||||
if (NetworkInfo.DetailedState.DISCONNECTED.equals(state)) {
|
||||
checkTriggers(Profile.TriggerType.WIFI, mLastConnectedSSID,
|
||||
Profile.TriggerState.ON_DISCONNECT);
|
||||
mLastConnectedSSID = WifiSsid.NONE;
|
||||
mLastConnectedSSID = WifiManager.UNKNOWN_SSID;
|
||||
} else if (NetworkInfo.DetailedState.CONNECTED.equals(state)) {
|
||||
String ssid = getActiveSSID();
|
||||
if (ssid != null) {
|
||||
@@ -179,15 +178,21 @@ public class ProfileTriggerHelper extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private String removeDoubleQuotes(String string) {
|
||||
final int length = string.length();
|
||||
if (length >= 2) {
|
||||
if (string.startsWith("\"") && string.endsWith("\"")) {
|
||||
return string.substring(1, length - 1);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
private String getActiveSSID() {
|
||||
WifiInfo wifiinfo = mWifiManager.getConnectionInfo();
|
||||
if (wifiinfo == null) {
|
||||
return null;
|
||||
}
|
||||
WifiSsid ssid = wifiinfo.getWifiSsid();
|
||||
if (ssid == null) {
|
||||
return null;
|
||||
}
|
||||
return ssid.toString();
|
||||
return removeDoubleQuotes(wifiinfo.getSSID());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user