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

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

Merge "Implement front-end APIs for config flags."

parents 1b119a3c ce40fe9b
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -1753,6 +1753,15 @@ package android.hardware.radio {
    field public static final int CLASS_AM_FM = 0; // 0x0
    field public static final int CLASS_DT = 2; // 0x2
    field public static final int CLASS_SAT = 1; // 0x1
    field public static final int CONFIG_DAB_DAB_LINKING = 6; // 0x6
    field public static final int CONFIG_DAB_DAB_SOFT_LINKING = 8; // 0x8
    field public static final int CONFIG_DAB_FM_LINKING = 7; // 0x7
    field public static final int CONFIG_DAB_FM_SOFT_LINKING = 9; // 0x9
    field public static final int CONFIG_FORCE_ANALOG = 2; // 0x2
    field public static final int CONFIG_FORCE_DIGITAL = 3; // 0x3
    field public static final int CONFIG_FORCE_MONO = 1; // 0x1
    field public static final int CONFIG_RDS_AF = 4; // 0x4
    field public static final int CONFIG_RDS_REG = 5; // 0x5
    field public static final int REGION_ITU_1 = 0; // 0x0
    field public static final int REGION_ITU_2 = 1; // 0x1
    field public static final int REGION_JAPAN = 3; // 0x3
@@ -1932,15 +1941,20 @@ package android.hardware.radio {
    method public abstract void close();
    method public abstract int getConfiguration(android.hardware.radio.RadioManager.BandConfig[]);
    method public abstract boolean getMute();
    method public java.util.Map<java.lang.String, java.lang.String> getParameters(java.util.List<java.lang.String>);
    method public abstract int getProgramInformation(android.hardware.radio.RadioManager.ProgramInfo[]);
    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 deprecated boolean isAnalogForced();
    method public abstract boolean isAntennaConnected();
    method public boolean isConfigFlagSet(int);
    method public boolean isConfigFlagSupported(int);
    method public abstract int scan(int, boolean);
    method public abstract void setAnalogForced(boolean);
    method public abstract deprecated void setAnalogForced(boolean);
    method public void setConfigFlag(int, boolean);
    method public abstract int setConfiguration(android.hardware.radio.RadioManager.BandConfig);
    method public abstract int setMute(boolean);
    method public java.util.Map<java.lang.String, java.lang.String> setParameters(java.util.Map<java.lang.String, java.lang.String>);
    method public abstract boolean startBackgroundScan();
    method public abstract int step(int, boolean);
    method public abstract deprecated int tune(int, int);
@@ -1966,6 +1980,7 @@ package android.hardware.radio {
    method public void onEmergencyAnnouncement(boolean);
    method public void onError(int);
    method public deprecated void onMetadataChanged(android.hardware.radio.RadioMetadata);
    method public void onParametersUpdated(java.util.Map<java.lang.String, java.lang.String>);
    method public void onProgramInfoChanged(android.hardware.radio.RadioManager.ProgramInfo);
    method public void onProgramListChanged();
    method public void onTrafficAnnouncement(boolean);
+3 −11
Original line number Diff line number Diff line
@@ -82,17 +82,9 @@ interface ITuner {
     */
    List<RadioManager.ProgramInfo> getProgramList(in Map vendorFilter);

    /**
     * @throws IllegalStateException if the switch is not supported at current
     *         configuration.
     */
    boolean isAnalogForced();

    /**
     * @throws IllegalStateException if the switch is not supported at current
     *         configuration.
     */
    void setAnalogForced(boolean isForced);
    boolean isConfigFlagSupported(int flag);
    boolean isConfigFlagSet(int flag);
    void setConfigFlag(int flag, boolean value);

    /**
     * @param parameters Vendor-specific key-value pairs, must be Map<String, String>
+65 −0
Original line number Diff line number Diff line
@@ -120,6 +120,71 @@ public class RadioManager {
     * @see BandDescriptor */
    public static final int REGION_KOREA  = 4;

    /**
     * Forces mono audio stream reception.
     *
     * Analog broadcasts can recover poor reception conditions by jointing
     * stereo channels into one. Mainly for, but not limited to AM/FM.
     */
    public static final int CONFIG_FORCE_MONO = 1;
    /**
     * Forces the analog playback for the supporting radio technology.
     *
     * User may disable digital playback for FM HD Radio or hybrid FM/DAB with
     * this option. This is purely user choice, ie. does not reflect digital-
     * analog handover state managed from the HAL implementation side.
     *
     * Some radio technologies may not support this, ie. DAB.
     */
    public static final int CONFIG_FORCE_ANALOG = 2;
    /**
     * Forces the digital playback for the supporting radio technology.
     *
     * User may disable digital-analog handover that happens with poor
     * reception conditions. With digital forced, the radio will remain silent
     * instead of switching to analog channel if it's available. This is purely
     * user choice, it does not reflect the actual state of handover.
     */
    public static final int CONFIG_FORCE_DIGITAL = 3;
    /**
     * RDS Alternative Frequencies.
     *
     * If set and the currently tuned RDS station broadcasts on multiple
     * channels, radio tuner automatically switches to the best available
     * alternative.
     */
    public static final int CONFIG_RDS_AF = 4;
    /**
     * RDS region-specific program lock-down.
     *
     * Allows user to lock to the current region as they move into the
     * other region.
     */
    public static final int CONFIG_RDS_REG = 5;
    /** Enables DAB-DAB hard- and implicit-linking (the same content). */
    public static final int CONFIG_DAB_DAB_LINKING = 6;
    /** Enables DAB-FM hard- and implicit-linking (the same content). */
    public static final int CONFIG_DAB_FM_LINKING = 7;
    /** Enables DAB-DAB soft-linking (related content). */
    public static final int CONFIG_DAB_DAB_SOFT_LINKING = 8;
    /** Enables DAB-FM soft-linking (related content). */
    public static final int CONFIG_DAB_FM_SOFT_LINKING = 9;

    /** @hide */
    @IntDef(prefix = { "CONFIG_" }, value = {
        CONFIG_FORCE_MONO,
        CONFIG_FORCE_ANALOG,
        CONFIG_FORCE_DIGITAL,
        CONFIG_RDS_AF,
        CONFIG_RDS_REG,
        CONFIG_DAB_DAB_LINKING,
        CONFIG_DAB_FM_LINKING,
        CONFIG_DAB_DAB_SOFT_LINKING,
        CONFIG_DAB_FM_SOFT_LINKING,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ConfigFlag {}

    private static void writeStringMap(@NonNull Parcel dest, @NonNull Map<String, String> map) {
        dest.writeInt(map.size());
        for (Map.Entry<String, String> entry : map.entrySet()) {
+51 −7
Original line number Diff line number Diff line
@@ -290,7 +290,9 @@ public abstract class RadioTuner {
     * @throws IllegalStateException if the switch is not supported at current
     *         configuration.
     * @return {@code true} if analog is forced, {@code false} otherwise.
     * @deprecated Use {@link isConfigFlagSet(int)} instead.
     */
    @Deprecated
    public abstract boolean isAnalogForced();

    /**
@@ -305,9 +307,49 @@ public abstract class RadioTuner {
     * @param isForced {@code true} to force analog, {@code false} for a default behaviour.
     * @throws IllegalStateException if the switch is not supported at current
     *         configuration.
     * @deprecated Use {@link setConfigFlag(int, boolean)} instead.
     */
    @Deprecated
    public abstract void setAnalogForced(boolean isForced);

    /**
     * Checks, if a given config flag is supported
     *
     * @param flag Flag to check.
     * @return True, if the flag is supported.
     */
    public boolean isConfigFlagSupported(@RadioManager.ConfigFlag int flag) {
        return false;
    }

    /**
     * Fetches the current setting of a given config flag.
     *
     * The success/failure result is consistent with isConfigFlagSupported.
     *
     * @param flag Flag to fetch.
     * @return The current value of the flag.
     * @throws IllegalStateException if the flag is not applicable right now.
     * @throws UnsupportedOperationException if the flag is not supported at all.
     */
    public boolean isConfigFlagSet(@RadioManager.ConfigFlag int flag) {
        throw new UnsupportedOperationException();
    }

    /**
     * Sets the config flag.
     *
     * The success/failure result is consistent with isConfigFlagSupported.
     *
     * @param flag Flag to set.
     * @param value The new value of a given flag.
     * @throws IllegalStateException if the flag is not applicable right now.
     * @throws UnsupportedOperationException if the flag is not supported at all.
     */
    public void setConfigFlag(@RadioManager.ConfigFlag int flag, boolean value) {
        throw new UnsupportedOperationException();
    }

    /**
     * Generic method for setting vendor-specific parameter values.
     * The framework does not interpret the parameters, they are passed
@@ -316,6 +358,7 @@ public abstract class RadioTuner {
     * Framework does not make any assumptions on the keys or values, other than
     * ones stated in VendorKeyValue documentation (a requirement of key
     * prefixes).
     * See VendorKeyValue at hardware/interfaces/broadcastradio/2.0/types.hal.
     *
     * For each pair in the result map, the key will be one of the keys
     * contained in the input (possibly with wildcards expanded), and the value
@@ -332,10 +375,11 @@ public abstract class RadioTuner {
     *
     * @param parameters Vendor-specific key-value pairs.
     * @return Operation completion status for parameters being set.
     * @hide FutureFeature
     */
    public abstract @NonNull Map<String, String>
            setParameters(@NonNull Map<String, String> parameters);
    public @NonNull Map<String, String>
            setParameters(@NonNull Map<String, String> parameters) {
        throw new UnsupportedOperationException();
    }

    /**
     * Generic method for retrieving vendor-specific parameter values.
@@ -355,10 +399,11 @@ public abstract class RadioTuner {
     *
     * @param keys Parameter keys to fetch.
     * @return Vendor-specific key-value pairs.
     * @hide FutureFeature
     */
    public abstract @NonNull Map<String, String>
            getParameters(@NonNull List<String> keys);
    public @NonNull Map<String, String>
            getParameters(@NonNull List<String> keys) {
        throw new UnsupportedOperationException();
    }

    /**
     * Get current antenna connection state for current configuration.
@@ -494,7 +539,6 @@ public abstract class RadioTuner {
         * asynchronously.
         *
         * @param parameters Vendor-specific key-value pairs.
         * @hide FutureFeature
         */
        public void onParametersUpdated(@NonNull Map<String, String> parameters) {}
    }
+22 −3
Original line number Diff line number Diff line
@@ -236,17 +236,36 @@ class TunerAdapter extends RadioTuner {

    @Override
    public boolean isAnalogForced() {
        return isConfigFlagSet(RadioManager.CONFIG_FORCE_ANALOG);
    }

    @Override
    public void setAnalogForced(boolean isForced) {
        setConfigFlag(RadioManager.CONFIG_FORCE_ANALOG, isForced);
    }

    @Override
    public boolean isConfigFlagSupported(@RadioManager.ConfigFlag int flag) {
        try {
            return mTuner.isAnalogForced();
            return mTuner.isConfigFlagSupported(flag);
        } catch (RemoteException e) {
            throw new RuntimeException("service died", e);
        }
    }

    @Override
    public void setAnalogForced(boolean isForced) {
    public boolean isConfigFlagSet(@RadioManager.ConfigFlag int flag) {
        try {
            return mTuner.isConfigFlagSet(flag);
        } catch (RemoteException e) {
            throw new RuntimeException("service died", e);
        }
    }

    @Override
    public void setConfigFlag(@RadioManager.ConfigFlag int flag, boolean value) {
        try {
            mTuner.setAnalogForced(isForced);
            mTuner.setConfigFlag(flag, value);
        } catch (RemoteException e) {
            throw new RuntimeException("service died", e);
        }
Loading