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

Commit b4dcdd5f authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Android (Google) Code Review
Browse files

Merge "Pass vendor-specific info as map." into oc-mr1-dev

parents 850ec9b2 0f1776d0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -17392,7 +17392,7 @@ package android.hardware.radio {
    method public java.lang.String getProduct();
    method public java.lang.String getSerial();
    method public java.lang.String getServiceName();
    method public java.lang.String getVendorInfo();
    method public java.util.Map<java.lang.String, java.lang.String> getVendorInfo();
    method public java.lang.String getVersion();
    method public boolean isBackgroundScanningSupported();
    method public boolean isCaptureSupported();
@@ -17409,7 +17409,7 @@ package android.hardware.radio {
    method public android.hardware.radio.ProgramSelector getSelector();
    method public int getSignalStrength();
    method public deprecated int getSubChannel();
    method public java.lang.String getVendorInfo();
    method public java.util.Map<java.lang.String, java.lang.String> getVendorInfo();
    method public boolean isDigital();
    method public boolean isLive();
    method public boolean isMuted();
@@ -17473,7 +17473,7 @@ package android.hardware.radio {
    method public abstract int getConfiguration(android.hardware.radio.RadioManager.BandConfig[]);
    method public abstract boolean getMute();
    method public abstract int getProgramInformation(android.hardware.radio.RadioManager.ProgramInfo[]);
    method public abstract java.util.List<android.hardware.radio.RadioManager.ProgramInfo> getProgramList(java.lang.String);
    method public abstract java.util.List<android.hardware.radio.RadioManager.ProgramInfo> getProgramList(java.util.Map<java.lang.String, java.lang.String>);
    method public abstract boolean hasControl();
    method public abstract boolean isAnalogForced();
    method public abstract boolean isAntennaConnected();
+2 −1
Original line number Diff line number Diff line
@@ -74,12 +74,13 @@ interface ITuner {
    boolean startBackgroundScan();

    /**
     * @param vendorFilter Vendor-specific filter, must be Map<String, String>
     * @returns the list, or null if scan is in progress
     * @throws IllegalArgumentException if invalid arguments are passed
     * @throws IllegalStateException if the scan has not been started, client may
     *         call startBackgroundScan to fix this.
     */
    List<RadioManager.ProgramInfo> getProgramList(String filter);
    List<RadioManager.ProgramInfo> getProgramList(in Map vendorFilter);

    /**
     * @throws IllegalStateException if the switch is not supported at current
+49 −28
Original line number Diff line number Diff line
@@ -35,7 +35,9 @@ import android.util.Log;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

@@ -117,6 +119,25 @@ public class RadioManager {
     * @see BandDescriptor */
    public static final int REGION_KOREA  = 4;

    private static void writeStringMap(@NonNull Parcel dest, @NonNull Map<String, String> map) {
        dest.writeInt(map.size());
        for (Map.Entry<String, String> entry : map.entrySet()) {
            dest.writeString(entry.getKey());
            dest.writeString(entry.getValue());
        }
    }

    private static @NonNull Map<String, String> readStringMap(@NonNull Parcel in) {
        int size = in.readInt();
        Map<String, String> map = new HashMap<>();
        while (size-- > 0) {
            String key = in.readString();
            String value = in.readString();
            map.put(key, value);
        }
        return map;
    }

    /*****************************************************************************
     * Lists properties, options and radio bands supported by a given broadcast radio module.
     * Each module has a unique ID used to address it when calling RadioManager APIs.
@@ -138,14 +159,14 @@ public class RadioManager {
        private final boolean mIsBgScanSupported;
        private final Set<Integer> mSupportedProgramTypes;
        private final Set<Integer> mSupportedIdentifierTypes;
        private final String mVendorInfo;
        @NonNull private final Map<String, String> mVendorInfo;

        ModuleProperties(int id, String serviceName, int classId, String implementor,
                String product, String version, String serial, int numTuners, int numAudioSources,
                boolean isCaptureSupported, BandDescriptor[] bands, boolean isBgScanSupported,
                @ProgramSelector.ProgramType int[] supportedProgramTypes,
                @ProgramSelector.IdentifierType int[] supportedIdentifierTypes,
                String vendorInfo) {
                Map<String, String> vendorInfo) {
            mId = id;
            mServiceName = TextUtils.isEmpty(serviceName) ? "default" : serviceName;
            mClassId = classId;
@@ -160,7 +181,7 @@ public class RadioManager {
            mIsBgScanSupported = isBgScanSupported;
            mSupportedProgramTypes = arrayToSet(supportedProgramTypes);
            mSupportedIdentifierTypes = arrayToSet(supportedIdentifierTypes);
            mVendorInfo = vendorInfo;
            mVendorInfo = (vendorInfo == null) ? new HashMap<>() : vendorInfo;
        }

        private static Set<Integer> arrayToSet(int[] arr) {
@@ -287,17 +308,17 @@ public class RadioManager {
        }

        /**
         * Opaque vendor-specific string, passed from HAL without changes.
         * Format of this string can vary across vendors.
         * A map of vendor-specific opaque strings, passed from HAL without changes.
         * Format of these strings can vary across vendors.
         *
         * It may be used for extra features, that's not supported by a platform,
         * for example: "preset-slots=6;ultra-hd-capable=false".
         * for example: preset-slots=6; ultra-hd-capable=false.
         *
         * Client application MUST verify vendor/product name from the
         * ModuleProperties class before doing any interpretation of this value.
         * Keys must be prefixed with unique vendor Java-style namespace,
         * eg. 'com.somecompany.parameter1'.
         */
        public @NonNull String getVendorInfo() {
            return mVendorInfo == null ? "" : mVendorInfo;
        public @NonNull Map<String, String> getVendorInfo() {
            return mVendorInfo;
        }

        /** List of descriptors for all bands supported by this module.
@@ -327,7 +348,7 @@ public class RadioManager {
            mIsBgScanSupported = in.readInt() == 1;
            mSupportedProgramTypes = arrayToSet(in.createIntArray());
            mSupportedIdentifierTypes = arrayToSet(in.createIntArray());
            mVendorInfo = in.readString();
            mVendorInfo = readStringMap(in);
        }

        public static final Parcelable.Creator<ModuleProperties> CREATOR
@@ -357,7 +378,7 @@ public class RadioManager {
            dest.writeInt(mIsBgScanSupported ? 1 : 0);
            dest.writeIntArray(setToArray(mSupportedProgramTypes));
            dest.writeIntArray(setToArray(mSupportedIdentifierTypes));
            dest.writeString(mVendorInfo);
            writeStringMap(dest, mVendorInfo);
        }

        @Override
@@ -394,7 +415,7 @@ public class RadioManager {
            result = prime * result + (mIsCaptureSupported ? 1 : 0);
            result = prime * result + Arrays.hashCode(mBands);
            result = prime * result + (mIsBgScanSupported ? 1 : 0);
            result = prime * result + ((mVendorInfo == null) ? 0 : mVendorInfo.hashCode());
            result = prime * result + mVendorInfo.hashCode();
            return result;
        }

@@ -440,7 +461,7 @@ public class RadioManager {
                return false;
            if (mIsBgScanSupported != other.isBackgroundScanningSupported())
                return false;
            if (!TextUtils.equals(mVendorInfo, other.mVendorInfo)) return false;
            if (!mVendorInfo.equals(other.mVendorInfo)) return false;
            return true;
        }
    }
@@ -1324,11 +1345,11 @@ public class RadioManager {
        private final int mFlags;
        private final int mSignalStrength;
        private final RadioMetadata mMetadata;
        private final String mVendorInfo;
        @NonNull private final Map<String, String> mVendorInfo;

        ProgramInfo(@NonNull ProgramSelector selector, boolean tuned, boolean stereo,
                boolean digital, int signalStrength, RadioMetadata metadata, int flags,
                String vendorInfo) {
                Map<String, String> vendorInfo) {
            mSelector = selector;
            mTuned = tuned;
            mStereo = stereo;
@@ -1336,7 +1357,7 @@ public class RadioManager {
            mFlags = flags;
            mSignalStrength = signalStrength;
            mMetadata = metadata;
            mVendorInfo = vendorInfo;
            mVendorInfo = (vendorInfo == null) ? new HashMap<>() : vendorInfo;
        }

        /**
@@ -1447,17 +1468,17 @@ public class RadioManager {
        }

        /**
         * Opaque vendor-specific string, passed from HAL without changes.
         * Format of this string can vary across vendors.
         * A map of vendor-specific opaque strings, passed from HAL without changes.
         * Format of these strings can vary across vendors.
         *
         * It may be used for extra features, that's not supported by a platform,
         * for example: "paid-service=true;bitrate=320kbps".
         * for example: paid-service=true; bitrate=320kbps.
         *
         * Client application MUST verify vendor/product name from the
         * ModuleProperties class before doing any interpretation of this value.
         * Keys must be prefixed with unique vendor Java-style namespace,
         * eg. 'com.somecompany.parameter1'.
         */
        public @NonNull String getVendorInfo() {
            return mVendorInfo == null ? "" : mVendorInfo;
        public @NonNull Map<String, String> getVendorInfo() {
            return mVendorInfo;
        }

        private ProgramInfo(Parcel in) {
@@ -1472,7 +1493,7 @@ public class RadioManager {
                mMetadata = null;
            }
            mFlags = in.readInt();
            mVendorInfo = in.readString();
            mVendorInfo = readStringMap(in);
        }

        public static final Parcelable.Creator<ProgramInfo> CREATOR
@@ -1500,7 +1521,7 @@ public class RadioManager {
                mMetadata.writeToParcel(dest, flags);
            }
            dest.writeInt(mFlags);
            dest.writeString(mVendorInfo);
            writeStringMap(dest, mVendorInfo);
        }

        @Override
@@ -1528,7 +1549,7 @@ public class RadioManager {
            result = prime * result + mFlags;
            result = prime * result + mSignalStrength;
            result = prime * result + ((mMetadata == null) ? 0 : mMetadata.hashCode());
            result = prime * result + ((mVendorInfo == null) ? 0 : mVendorInfo.hashCode());
            result = prime * result + mVendorInfo.hashCode();
            return result;
        }

@@ -1555,7 +1576,7 @@ public class RadioManager {
                    return false;
            } else if (!mMetadata.equals(other.getMetadata()))
                return false;
            if (!TextUtils.equals(mVendorInfo, other.mVendorInfo)) return false;
            if (!mVendorInfo.equals(other.mVendorInfo)) return false;
            return true;
        }
    }
+8 −5
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.graphics.Bitmap;
import android.os.Handler;

import java.util.List;
import java.util.Map;

/**
 * RadioTuner interface provides methods to control a radio tuner on the device: selecting and
@@ -270,16 +271,18 @@ public abstract class RadioTuner {
    /**
     * Get the list of discovered radio stations.
     *
     * To get the full list, set filter to null or empty string. Otherwise, client application
     * must verify vendor product/name before setting this parameter to anything else.
     * To get the full list, set filter to null or empty map.
     * Keys must be prefixed with unique vendor Java-style namespace,
     * eg. 'com.somecompany.parameter1'.
     *
     * @param filter vendor-specific selector for radio stations.
     * @param vendorFilter vendor-specific selector for radio stations.
     * @return a list of radio stations.
     * @throws IllegalStateException if the scan is in progress or has not been started,
     *         startBackgroundScan() call may fix it.
     * @throws IllegalArgumentException if the filter argument is not valid.
     * @throws IllegalArgumentException if the vendorFilter argument is not valid.
     */
    public abstract @NonNull List<RadioManager.ProgramInfo> getProgramList(@Nullable String filter);
    public abstract @NonNull List<RadioManager.ProgramInfo>
            getProgramList(@Nullable Map<String, String> vendorFilter);

    /**
     * Checks, if the analog playback is forced, see setAnalogForced.
+4 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.RemoteException;
import android.util.Log;

import java.util.List;
import java.util.Map;

/**
 * Implements the RadioTuner interface by forwarding calls to radio service.
@@ -222,9 +223,10 @@ class TunerAdapter extends RadioTuner {
    }

    @Override
    public @NonNull List<RadioManager.ProgramInfo> getProgramList(@Nullable String filter) {
    public @NonNull List<RadioManager.ProgramInfo>
            getProgramList(@Nullable Map<String, String> vendorFilter) {
        try {
            return mTuner.getProgramList(filter);
            return mTuner.getProgramList(vendorFilter);
        } catch (RemoteException e) {
            throw new RuntimeException("service died", e);
        }
Loading