New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android8 #148
Android8 #148
Conversation
Referencing issue #111 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Good man page.
ares_android.h
Outdated
|
||
#endif | ||
|
||
#endif /* __JNI_COMMON_H__ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header guard comment is not matching
@bagder @daviddrysdale any feedback on this PR? |
} | ||
if (res != JNI_OK || env == NULL) | ||
goto done; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idle thought: it might be helpful to add a block comment here with the equivalent Java code to the JNI stuff below.
/*
JNI invocations below are intended to recreate the following Java snippet:
import android.net.ConnectivityManager
import android.net.LinkProperties
import java.util.List
import java.net.InetAddress
...
NetworkInfo active_network = connMgr.getActiveNetwork();
LinkProperties link_properties = connMgr.getLinkProperties(active_network);
List<InetAddress> server_list = props.getDnsServers();
for (int i = 0; i < server_list.size(); i++ {
InetAddress server = server_list.get(i);
String str = server.getHostAddress()
// append str to results
}
*/
ares_library_init_android.3
Outdated
} | ||
.Ed | ||
.SH AVAILABILITY | ||
This function was first introduced in c-ares version 1.?.?. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we'll forget to come back and update this, so maybe fill it in as 1.14.0 as a best guess?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please make a best guess to cover for us missing to update this later... =)
ares_library_init_android.3
Outdated
be present in the Android application. | ||
.PP | ||
Android older than 8 do not need to to be initalized as they | ||
are less restritive. However, this is a run time not compile time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"restrictive"
Looks good as far as I can tell -- I don't really speak Java nor Android. It does look safe for not affecting any other platforms or existing code, which is nicely reassuring. Thanks! |
I'll just second @daviddrysdale here as I don't speak any of those lingos either. It would be useful to get feedback from another actual Android user on this approach, but lacking that I think we can proceed with this PR as suggested. |
I corrected the typo and added the equivelent Java code as an example. |
… access to net.dns# system properties. (c-ares#148) As of Android 8 (Oreo) access to net.dns# has been removed (https://developer.android.com/about/versions/oreo/android-8.0-changes.html). The reasoning given is that it, "improves privacy on the platform". Currently c-ares uses this to get the list of DNS servers. Now the only way to access the DNS server list is by using the Connectivity Manager though Java. This adds the necessary JNI code to use the Connectivity Manager and pull the DNS server list. The old way using __system_property_get with net.dns# remains for compatibilty. Using the Connectivity Manager requires the ACCESS_NETWORK_STATE permission to be set on the app. Existing applications most likely are not setting this and keeping the previous method as a fallback will at the very least ensure those apps don't break on older versions of Android. They will need to add this permission for Android 8 compatibility. Included in the patch are two initalization functions which are required. The JVM must be registered as well as the Connectivity Manager itself. There is no way to get the Connectivity Manager except though Java. Either being passed down to C directly or by passing in an Android Context which can be used to get the Connectivity Manager. Examples are provided in the documentation.
As of Android 8 (Oreo) access to net.dns# has been removed (https://developer.android.com/about/versions/oreo/android-8.0-changes.html). The reasoning given is that it, "improves privacy on the platform". Currently c-ares uses this to get the list of DNS servers.
Now the only way to access the DNS server list is by using the Connectivity Manager though Java. This adds the necessary JNI code to use the Connectivity Manager and pull the DNS server list. The old way using __system_property_get with net.dns# remains for compatibilty.
Using the Connectivity Manager requires the ACCESS_NETWORK_STATE permission to be set on the app. Existing applications most likely are not setting this and keeping the previous method as a fallback will at the very least ensure those apps don't break on older versions of Android. They will need to add this permission for Android 8 compatibility.
Included in the patch are two initalization functions which are required. The JVM must be registered as well as the Connectivity Manager itself. There is no way to get the Connectivity Manager except though Java. Either being passed down to C directly or by passing in an Android Context which can be used to get the Connectivity Manager. Examples are provided in the documentation.