Skip to content

Commit

Permalink
added Wifi Security Type to wifi information
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterHasse committed Oct 29, 2024
1 parent 5a7c46a commit 4831b74
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.os.Build;

import com.influxdb.client.domain.WritePrecision;
import com.influxdb.client.write.Point;
Expand All @@ -40,8 +41,9 @@ public class WifiInformation extends Information {
private int max_rx_link_speed;
private int standard;
private int channel_bandwidth;
private int security_type;

public WifiInformation(String ssid, String bssid, int rssi, int frequency, int link_speed, int tx_link_speed, int max_tx_link_speed, int rx_link_speed, int max_rx_link_speed, int standard, int channel_bandwidth, long timestamp) {
public WifiInformation(String ssid, String bssid, int rssi, int frequency, int link_speed, int tx_link_speed, int max_tx_link_speed, int rx_link_speed, int max_rx_link_speed, int standard, int channel_bandwidth, long timestamp, int security_type) {
super(timestamp);
this.ssid = ssid;
this.bssid = bssid;
Expand All @@ -54,6 +56,7 @@ public WifiInformation(String ssid, String bssid, int rssi, int frequency, int l
this.max_rx_link_speed = max_rx_link_speed;
this.standard = standard;
this.channel_bandwidth = channel_bandwidth;
this.security_type = security_type;
}

public WifiInformation(ScanResult scanResult, long timestamp) {
Expand All @@ -63,6 +66,9 @@ public WifiInformation(ScanResult scanResult, long timestamp) {
rssi = scanResult.level;
frequency = scanResult.frequency;
channel_bandwidth = scanResult.channelWidth;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
scanResult.getSecurityTypes();
}
}

public WifiInformation(WifiInfo wifiInfo, long timestamp) {
Expand All @@ -77,9 +83,55 @@ public WifiInformation(WifiInfo wifiInfo, long timestamp) {
max_rx_link_speed = wifiInfo.getMaxSupportedRxLinkSpeedMbps();
rx_link_speed = wifiInfo.getTxLinkSpeedMbps();
standard = wifiInfo.getWifiStandard();
security_type = wifiInfo.getCurrentSecurityType();
}

public int getSecurity_type() {
return security_type;
}

public void setSecurity_type(int security_type) {
this.security_type = security_type;
}

public String getWifiSecurityTypeString(int type) {
switch (type) {
case WifiInfo.SECURITY_TYPE_UNKNOWN:
return "Unknown";
case WifiInfo.SECURITY_TYPE_OPEN:
return "Open";
case WifiInfo.SECURITY_TYPE_WEP:
return "WEP";
case WifiInfo.SECURITY_TYPE_PSK:
return "PSK";
case WifiInfo.SECURITY_TYPE_EAP:
return "EAP";
case WifiInfo.SECURITY_TYPE_SAE:
return "SAE";
case WifiInfo.SECURITY_TYPE_EAP_WPA3_ENTERPRISE_192_BIT:
return "WPA3 EP 192Bit";
case WifiInfo.SECURITY_TYPE_OWE:
return "OWE";
case WifiInfo.SECURITY_TYPE_WAPI_PSK:
return "WAPI PSK";
case WifiInfo.SECURITY_TYPE_WAPI_CERT:
return "WAPI Cert";
case WifiInfo.SECURITY_TYPE_EAP_WPA3_ENTERPRISE:
return "EAP WPA3 EP";
case WifiInfo.SECURITY_TYPE_OSEN:
return "OSEN";
case WifiInfo.SECURITY_TYPE_PASSPOINT_R1_R2:
return "Passpoint R1 R2";
case WifiInfo.SECURITY_TYPE_PASSPOINT_R3:
return "Passpoint R3";
default:
return "Unknown";
}
}

public String getSecurityTypeString() {
return getWifiSecurityTypeString(security_type);
}

public String getWifiStandardString(int standard) {
switch (standard) {
Expand Down Expand Up @@ -125,7 +177,7 @@ public String getChannelBandwidthStringFromInt(int channel_bandwidth) {
}
}

public String getChannelBandwithString(){
public String getChannelBandwithString() {
return getChannelBandwidthStringFromInt(channel_bandwidth);
}

Expand Down Expand Up @@ -213,11 +265,16 @@ public int getChannel_bandwidth() {
return channel_bandwidth;
}

public void setChannel_bandwidth(int channel_bandwidth) {
this.channel_bandwidth = channel_bandwidth;
}

public void setChannel_width(int channel_bandwidth) {
this.channel_bandwidth = channel_bandwidth;
}

/** Return a influx point representation of the wifi information
/**
* Return a influx point representation of the wifi information
*
* @return Influx Point
*/
Expand All @@ -235,6 +292,7 @@ public com.influxdb.client.write.Point getWifiInformationPoint() {
point.addField("Max Supported RX Speed", getMax_rx_link_speed());
point.addField("Standard", getStandardString());
point.addField("Channel Width", getChannelBandwithString());
point.addField("Security Type", getSecurityTypeString());
return point;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,9 @@ private CardView get_wifi_card_view() {
{getString(R.string.rx_link_speed), Integer.toString(wi.getRx_link_speed())},
{getString(R.string.max_rx_link_speed), Integer.toString(wi.getMax_rx_link_speed())},
{getString(R.string.standard), wi.getStandardString()},
{getString(R.string.channel_bandwidth), wi.getChannelBandwithString()}
{getString(R.string.channel_bandwidth), wi.getChannelBandwithString()},
{getString(R.string.wifi_security_type), wi.getSecurityTypeString()}

}, true);


Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,6 @@
<string name="max_rx_link_speed">Max Supported RX Speed</string>
<string name="standard">Standard</string>
<string name="channel_bandwidth">Channel Bandwidth</string>
<string name="wifi_security_type">Security Type</string>

</resources>

0 comments on commit 4831b74

Please sign in to comment.