Fix wifi option

This commit is contained in:
Alessandro Ferro 2022-09-30 08:54:13 +02:00
parent 2c23b000e9
commit 2b341a177c
5 changed files with 15 additions and 3 deletions

View File

@ -11,7 +11,7 @@
</map> </map>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

6
src/.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application <application
android:allowBackup="true" android:allowBackup="true"

View File

@ -45,7 +45,8 @@ public class MainActivity extends AppCompatActivity {
Manifest.permission.SEND_SMS, Manifest.permission.SEND_SMS,
Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.CALL_PHONE Manifest.permission.CALL_PHONE,
Manifest.permission.ACCESS_WIFI_STATE
}, },
Utils.PERMISSION_MULTIPLE Utils.PERMISSION_MULTIPLE
); );

View File

@ -235,6 +235,7 @@ public class SmsHandler {
context.startActivity(intent); context.startActivity(intent);
} }
// wifi
else if(providedOption.equals(Utils.WIFI_OPTION)){ else if(providedOption.equals(Utils.WIFI_OPTION)){
StringBuilder responseSms = new StringBuilder(); StringBuilder responseSms = new StringBuilder();
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
@ -247,7 +248,10 @@ public class SmsHandler {
responseSms.append("Yes\n"); responseSms.append("Yes\n");
WifiInfo wifiInfo = wifiManager.getConnectionInfo(); WifiInfo wifiInfo = wifiManager.getConnectionInfo();
responseSms.append("SSID: ").append(wifiInfo.getSSID()).append("\n"); String ssid = (wifiInfo.getSSID().equals(WifiManager.UNKNOWN_SSID))?
"Not connected or unknown" : wifiInfo.getSSID();
responseSms.append("SSID: ").append(ssid).append("\n");
responseSms.append("BSSID: ").append(wifiInfo.getBSSID()).append("\n"); responseSms.append("BSSID: ").append(wifiInfo.getBSSID()).append("\n");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
responseSms.append("Strength: ").append(wifiManager.calculateSignalLevel(wifiInfo.getRssi())) responseSms.append("Strength: ").append(wifiManager.calculateSignalLevel(wifiInfo.getRssi()))