Updated ResponderLocation.toCivicLocationSparseArray() to return SparseArray<String>
Bug: 147924426 Test: atest android.net.wifi.rtt.ResponderLocationTest#testLcrTestCivicLocationSparseArray: PASSED (0ms) Change-Id: Icbcf0c926646ef522ede846db93df85592bec631
This commit is contained in:
@@ -31794,7 +31794,7 @@ package android.net.wifi.rtt {
|
||||
method public boolean isLciSubelementValid();
|
||||
method public boolean isZaxisSubelementValid();
|
||||
method @Nullable public android.location.Address toCivicLocationAddress();
|
||||
method @Nullable public android.util.SparseArray toCivicLocationSparseArray();
|
||||
method @Nullable public android.util.SparseArray<java.lang.String> toCivicLocationSparseArray();
|
||||
method @NonNull public android.location.Location toLocation();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final int ALTITUDE_FLOORS = 2; // 0x2
|
||||
|
||||
@@ -21,6 +21,7 @@ import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.SystemApi;
|
||||
import android.location.Address;
|
||||
import android.location.Location;
|
||||
@@ -1367,7 +1368,8 @@ public final class ResponderLocation implements Parcelable {
|
||||
*
|
||||
*/
|
||||
@Nullable
|
||||
public SparseArray toCivicLocationSparseArray() {
|
||||
@SuppressLint("ChangedType")
|
||||
public SparseArray<String> toCivicLocationSparseArray() {
|
||||
if (mCivicLocation != null && mCivicLocation.isValid()) {
|
||||
return mCivicLocation.toSparseArray();
|
||||
} else {
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.location.Address;
|
||||
import android.location.Location;
|
||||
import android.net.MacAddress;
|
||||
import android.os.Parcel;
|
||||
import android.util.SparseArray;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
@@ -504,6 +505,30 @@ public class ResponderLocationTest {
|
||||
assertEquals("US", address.getAddressLine(4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a Civic Location sparseArray can be extracted from a valid lcr buffer.
|
||||
*/
|
||||
@Test
|
||||
public void testLcrTestCivicLocationSparseArray() {
|
||||
byte[] testLciBuffer = concatenateArrays(sTestLciIeHeader, sTestLciSE);
|
||||
byte[] testLcrBuffer =
|
||||
concatenateArrays(sTestLcrBufferHeader, sTestCivicLocationSEWithAddress);
|
||||
ResponderLocation responderLocation = new ResponderLocation(testLciBuffer, testLcrBuffer);
|
||||
|
||||
boolean valid = responderLocation.isValid();
|
||||
SparseArray<String> civicLocationSparseArray = responderLocation
|
||||
.toCivicLocationSparseArray();
|
||||
|
||||
assertTrue(valid);
|
||||
assertEquals("15", civicLocationSparseArray.get(CivicLocationKeys.HNO));
|
||||
assertEquals("Alto",
|
||||
civicLocationSparseArray.get(CivicLocationKeys.PRIMARY_ROAD_NAME));
|
||||
assertEquals("Road",
|
||||
civicLocationSparseArray.get(CivicLocationKeys.STREET_NAME_POST_MODIFIER));
|
||||
assertEquals("Mtn View", civicLocationSparseArray.get(CivicLocationKeys.CITY));
|
||||
assertEquals("94043", civicLocationSparseArray.get(CivicLocationKeys.POSTAL_CODE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a URL can be extracted from a valid lcr buffer with a map image subelement.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user