Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f57d9a7 authored by Roy Want's avatar Roy Want Committed by Android (Google) Code Review
Browse files

Merge "Updated ResponderLocation.toCivicLocationSparseArray() to return SparseArray<String>"

parents 2f3f0cf6 81ba3e35
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31821,7 +31821,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
+3 −1
Original line number Diff line number Diff line
@@ -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 {
+25 −0
Original line number Diff line number Diff line
@@ -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.
     */