Merge "Move DnsPacket to libs net" into rvc-dev am: 81f0fe48d2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11862407

Change-Id: Ia19cb44ad56e4358c63564261d481459d1386542
This commit is contained in:
Lorenzo Colitti
2020-06-18 10:34:11 +00:00
committed by Automerger Merge Worker

View File

@@ -38,6 +38,8 @@ import android.os.MessageQueue;
import android.system.ErrnoException; import android.system.ErrnoException;
import android.util.Log; import android.util.Log;
import com.android.net.module.util.DnsPacket;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@@ -97,7 +99,7 @@ public final class DnsResolver {
@interface DnsError {} @interface DnsError {}
/** /**
* Indicates that there was an error parsing the response the query. * Indicates that there was an error parsing the response the query.
* The cause of this error is available via getCause() and is a ParseException. * The cause of this error is available via getCause() and is a {@link ParseException}.
*/ */
public static final int ERROR_PARSE = 0; public static final int ERROR_PARSE = 0;
/** /**
@@ -290,8 +292,15 @@ public final class DnsResolver {
} }
try { try {
mAllAnswers.addAll(new DnsAddressAnswer(answer).getAddresses()); mAllAnswers.addAll(new DnsAddressAnswer(answer).getAddresses());
} catch (ParseException e) { } catch (DnsPacket.ParseException e) {
mDnsException = new DnsException(ERROR_PARSE, e); // Convert the com.android.net.module.util.DnsPacket.ParseException to an
// android.net.ParseException. This is the type that was used in Q and is implied
// by the public documentation of ERROR_PARSE.
//
// DnsPacket cannot throw android.net.ParseException directly because it's @hide.
ParseException pe = new ParseException(e.reason, e.getCause());
pe.setStackTrace(e.getStackTrace());
mDnsException = new DnsException(ERROR_PARSE, pe);
} }
maybeReportAnswer(); maybeReportAnswer();
} }