(Context context)
| 442 | } |
| 443 | |
| 444 | private static List<String> _getDnsServers(Context context) { |
| 445 | List<String> result = new ArrayList<>(); |
| 446 | |
| 447 | try { |
| 448 | ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class); |
| 449 | if (cm == null) |
| 450 | return result; |
| 451 | |
| 452 | Network active = ConnectionHelper.getActiveNetwork(context); |
| 453 | if (active == null) |
| 454 | return result; |
| 455 | |
| 456 | LinkProperties props = cm.getLinkProperties(active); |
| 457 | if (props == null) |
| 458 | return result; |
| 459 | |
| 460 | List<InetAddress> dns = props.getDnsServers(); |
| 461 | for (int i = 0; i < dns.size(); i++) |
| 462 | result.add(dns.get(i).getHostAddress()); |
| 463 | } catch (Throwable ex) { |
| 464 | Log.e(ex); |
| 465 | } |
| 466 | |
| 467 | return result; |
| 468 | } |
| 469 | |
| 470 | static void clear(Context context) { |
| 471 | try { |
no test coverage detected