[android]: Remove ACCESS_WIFI_STATE permission

This permission were needed to collect MAC addresses
for advertising.

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2021-04-04 17:29:39 +03:00
parent 725560cab9
commit fa16af99a3
2 changed files with 1 additions and 78 deletions

View file

@ -27,7 +27,6 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

View file

@ -9,8 +9,6 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
import android.text.SpannableStringBuilder;
@ -21,7 +19,6 @@ import android.util.AndroidRuntimeException;
import android.view.View;
import android.view.Window;
import android.widget.Toast;
import androidx.annotation.DimenRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -31,6 +28,7 @@ import androidx.core.app.NavUtils;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.snackbar.Snackbar;
import com.mapswithme.maps.BuildConfig;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.R;
@ -42,16 +40,12 @@ import com.mapswithme.util.log.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.net.NetworkInterface;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Currency;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
@ -386,76 +380,6 @@ public class Utils
}).show();
}
@NonNull
public static String getMacAddress(@NonNull Context context, boolean md5Decoded)
{
byte[] macBytes = null;
String address = "";
try
{
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
{
WifiManager manager = (WifiManager) context.getApplicationContext().
getSystemService(Context.WIFI_SERVICE);
if (manager == null)
return "";
WifiInfo info = manager.getConnectionInfo();
address = info.getMacAddress();
macBytes = address.getBytes();
}
else
{
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all)
{
if (!nif.getName().equalsIgnoreCase("wlan0"))
continue;
macBytes = nif.getHardwareAddress();
if (macBytes == null)
return "";
StringBuilder result = new StringBuilder();
for (int i = 0; i < macBytes.length; i++)
{
result.append(String.format("%02X", (0xFF & macBytes[i])));
if (i + 1 != macBytes.length)
result.append(":");
}
address = result.toString();
}
}
}
catch (Exception exc)
{
return "";
}
return md5Decoded ? decodeMD5(macBytes) : address;
}
@NonNull
private static String decodeMD5(@Nullable byte[] bytes)
{
if (bytes == null || bytes.length == 0)
return "";
try
{
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(bytes);
byte[] messageDigest = digest.digest();
StringBuilder hexString = new StringBuilder();
for (int i = 0; i < messageDigest.length; i++)
hexString.append(String.format("%02X", (0xFF & messageDigest[i])));
return hexString.toString();
}
catch (Exception e)
{
return "";
}
}
public static boolean isAppInstalled(@NonNull Context context, @NonNull String packageName)
{
try