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

Commit c7697785 authored by George Lu's avatar George Lu
Browse files

Introduce ProgramInfoCache

ProgramInfoCache will be used in a future CL by BroadcastRadioService to
perform the multiple AIDL client to single HAL fanout of ITunerSession's
"program list update" API.

This CL also addresses a few issues with some of the AIDL classes:
- RadioMetadata.equals() was not defined despite being used by RadioManager.ProgramInfo.equals().
- Added ProgramList.Identifier.isCategoryType() to provide a formal definition of how ProgramList.Filter.areCategoriesIncluded() works.

Bug: 121305828
Test: atest com.android.server.broadcastradio.hal2.ProgramInfoCacheTest
Change-Id: I50befe3b16125a50d494899ba97aa0f9b6d76913
parent 362efacb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2739,6 +2739,7 @@ package android.hardware.radio {
    method public int describeContents();
    method @android.hardware.radio.ProgramSelector.IdentifierType public int getType();
    method public long getValue();
    method public boolean isCategoryType();
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.radio.ProgramSelector.Identifier> CREATOR;
  }
+2 −0
Original line number Diff line number Diff line
@@ -352,6 +352,8 @@ public final class ProgramList implements AutoCloseable {
        /**
         * Checks, if non-tunable entries that define tree structure on the
         * program list (i.e. DAB ensembles) should be included.
         *
         * @see {@link ProgramSelector.Identifier#isCategory()}
         */
        public boolean areCategoriesIncluded() {
            return mIncludeCategories;
+13 −0
Original line number Diff line number Diff line
@@ -580,6 +580,19 @@ public final class ProgramSelector implements Parcelable {
            return mType;
        }

        /**
         * Returns whether this Identifier's type is considered a category when filtering
         * ProgramLists for category entries.
         *
         * @see {@link ProgramList.Filter#areCategoriesIncluded()}
         * @return False if this identifier's type is not tuneable (e.g. DAB ensemble or
         *         vendor-specified type). True otherwise.
         */
        public boolean isCategoryType() {
            return (mType >= IDENTIFIER_TYPE_VENDOR_START && mType <= IDENTIFIER_TYPE_VENDOR_END)
                    || mType == IDENTIFIER_TYPE_DAB_ENSEMBLE;
        }

        /**
         * Value of an identifier.
         *
+18 −0
Original line number Diff line number Diff line
@@ -257,6 +257,24 @@ public final class RadioMetadata implements Parcelable {

    private final Bundle mBundle;

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof RadioMetadata)) return false;
        Bundle otherBundle = ((RadioMetadata) obj).mBundle;
        if (!mBundle.keySet().equals(otherBundle.keySet())) {
            return false;
        }
        for (String key : mBundle.keySet()) {
            // This logic will return a false negative if we ever put Bundles into mBundle. As of
            // 2019-04-09, we only put ints, Strings, and Parcelables in, so it's fine for now.
            if (!mBundle.get(key).equals(otherBundle.get(key))) {
                return false;
            }
        }
        return true;
    }

    RadioMetadata() {
        mBundle = new Bundle();
    }
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ android_test {
        "compatibility-device-util-axt",
        "androidx.test.rules",
        "testng",
        "services.core",
    ],
    libs: ["android.test.base"],
    srcs: ["src/**/*.java"],
Loading