prevent crash

pull/215/head
M66B 8 months ago
parent 70cac8ba14
commit f0b4472f03

@ -442,7 +442,8 @@ public class ConnectionHelper {
} }
static Boolean isPrivateDnsActive(Context context) { static Boolean isPrivateDnsActive(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
return null; return null;
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class); ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
if (cm == null) if (cm == null)
@ -454,10 +455,15 @@ public class ConnectionHelper {
if (props == null) if (props == null)
return null; return null;
return props.isPrivateDnsActive(); return props.isPrivateDnsActive();
} catch (Throwable ex) {
Log.e(ex);
return null;
}
} }
static String getPrivateDnsServerName(Context context) { static String getPrivateDnsServerName(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
return null; return null;
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class); ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
if (cm == null) if (cm == null)
@ -469,6 +475,10 @@ public class ConnectionHelper {
if (props == null) if (props == null)
return null; return null;
return props.getPrivateDnsServerName(); return props.getPrivateDnsServerName();
} catch (Throwable ex) {
Log.e(ex);
return null;
}
} }
static boolean isIoError(Throwable ex) { static boolean isIoError(Throwable ex) {

Loading…
Cancel
Save