Migrate to Android 10
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
eb45b4b1bd
commit
d2b9de740d
@ -6,17 +6,17 @@ apply from: 'nonnull.gradle'
|
|||||||
final def keystorePropertiesFile = rootProject.file("keystore.properties")
|
final def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||||
|
|
||||||
android {
|
android {
|
||||||
buildToolsVersion '28.0.3'
|
buildToolsVersion '29.0.2'
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
compileSdkVersion 28
|
compileSdkVersion 29
|
||||||
dataBinding.enabled true
|
dataBinding.enabled true
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'com.wireguard.android'
|
applicationId 'com.wireguard.android'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 29
|
||||||
versionCode 451
|
versionCode 451
|
||||||
versionName '0.0.20190708'
|
versionName '0.0.20190708'
|
||||||
buildConfigField 'int', 'MIN_SDK_VERSION', "$minSdkVersion.apiLevel"
|
buildConfigField 'int', 'MIN_SDK_VERSION', "$minSdkVersion.apiLevel"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package com.wireguard.config;
|
package com.wireguard.config;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
@ -15,9 +16,12 @@ import java.net.InetAddress;
|
|||||||
* Utility methods for creating instances of {@link InetAddress}.
|
* Utility methods for creating instances of {@link InetAddress}.
|
||||||
*/
|
*/
|
||||||
public final class InetAddresses {
|
public final class InetAddresses {
|
||||||
private static final Method PARSER_METHOD;
|
private static Method PARSER_METHOD;
|
||||||
|
|
||||||
static {
|
|
||||||
|
private static Method getParserMethod() {
|
||||||
|
if (PARSER_METHOD != null)
|
||||||
|
return PARSER_METHOD;
|
||||||
try {
|
try {
|
||||||
// This method is only present on Android.
|
// This method is only present on Android.
|
||||||
// noinspection JavaReflectionMemberAccess
|
// noinspection JavaReflectionMemberAccess
|
||||||
@ -25,6 +29,7 @@ public final class InetAddresses {
|
|||||||
} catch (final NoSuchMethodException e) {
|
} catch (final NoSuchMethodException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
return PARSER_METHOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InetAddresses() {
|
private InetAddresses() {
|
||||||
@ -41,7 +46,10 @@ public final class InetAddresses {
|
|||||||
if (address.isEmpty())
|
if (address.isEmpty())
|
||||||
throw new ParseException(InetAddress.class, address, "Empty address");
|
throw new ParseException(InetAddress.class, address, "Empty address");
|
||||||
try {
|
try {
|
||||||
return (InetAddress) PARSER_METHOD.invoke(null, address);
|
if (Build.VERSION.SDK_INT < 29)
|
||||||
|
return (InetAddress) getParserMethod().invoke(null, address);
|
||||||
|
else
|
||||||
|
return android.net.InetAddresses.parseNumericAddress(address);
|
||||||
} catch (final IllegalAccessException | InvocationTargetException e) {
|
} catch (final IllegalAccessException | InvocationTargetException e) {
|
||||||
final Throwable cause = e.getCause();
|
final Throwable cause = e.getCause();
|
||||||
// Re-throw parsing exceptions with the original type, as callers might try to catch
|
// Re-throw parsing exceptions with the original type, as callers might try to catch
|
||||||
|
Loading…
Reference in New Issue
Block a user