Implement generic vendor-specific parameters.

This commit covers HAL changes only.

Bug: 65862441
Test: it builds
Change-Id: Ibd20e2a1db826a0dc3ade4fb9bd1cb830ee11f8d
diff --git a/broadcastradio/1.2/ITuner.hal b/broadcastradio/1.2/ITuner.hal
index ee8a45d..cc966fc 100644
--- a/broadcastradio/1.2/ITuner.hal
+++ b/broadcastradio/1.2/ITuner.hal
@@ -19,4 +19,50 @@
 import @1.1::ITuner;
 
 interface ITuner extends @1.1::ITuner {
+    /**
+     * Generic method for setting vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * Framework does not make any assumptions on the keys or values, other than
+     * ones stated in VendorKeyValue documentation (a requirement of key
+     * prefixes).
+     *
+     * Results vector may not contain a result for each parameter being set,
+     * it can even be empty.
+     *
+     * Application and HAL must not use keys with unknown prefix. In particular,
+     * it must not place a key-value pair in results vector for unknown key from
+     * parameters vector - instead, an unknown key should simply be ignored.
+     * In other words, results vector may contain a subset of parameter keys
+     * (however, the framework doesn't enforce a strict subset - the only
+     * formal requirement is vendor domain prefix for keys).
+     *
+     * @param parameters Vendor-specific key-value pairs.
+     * @return results Operation completion status for parameters being set.
+     *                 Value format for result status is vendor-specific.
+     */
+    setParameters(vec<VendorKeyValue> parameters)
+            generates (vec<VendorKeyValue> results);
+
+    /**
+     * Generic method for retrieving vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * Framework does not cache set/get requests, so it's allowed for
+     * getParameter to return a different value than previous setParameter call.
+     *
+     * The syntax and semantics of keys are up to the vendor (as long as prefix
+     * rules are obeyed). For instance, vendors may include some form of
+     * wildcard support. In such case, result vector may be of different size
+     * than requested keys vector. However, wildcards are not recognized by
+     * framework and they are passed as-is to the HAL implementation.
+     *
+     * Unknown keys must be ignored and not placed into results vector.
+     *
+     * @param keys Parameter keys to fetch.
+     * @return parameters Vendor-specific key-value pairs.
+     */
+    getParameters(vec<string> keys) generates (vec<VendorKeyValue> parameters);
 };
diff --git a/broadcastradio/1.2/ITunerCallback.hal b/broadcastradio/1.2/ITunerCallback.hal
index 223a571..4e3d0a5 100644
--- a/broadcastradio/1.2/ITunerCallback.hal
+++ b/broadcastradio/1.2/ITunerCallback.hal
@@ -19,4 +19,18 @@
 import @1.1::ITunerCallback;
 
 interface ITunerCallback extends @1.1::ITunerCallback {
+    /**
+     * Generic callback for passing updates to vendor-specific parameter values.
+     * The framework does not interpret the parameters, they are passed
+     * in an opaque manner between a vendor application and HAL.
+     *
+     * It's up to the HAL implementation if and how to implement this callback,
+     * as long as it obeys the prefix rule. In particular, only selected keys
+     * may be notified this way. However, setParameters must not trigger
+     * this callback, while an internal event can change parameters
+     * asynchronously.
+     *
+     * @param parameters Vendor-specific key-value pairs.
+     */
+    oneway parametersUpdated(vec<VendorKeyValue> parameters);
 };
diff --git a/broadcastradio/1.2/default/Tuner.cpp b/broadcastradio/1.2/default/Tuner.cpp
index f5fb643..70418cf 100644
--- a/broadcastradio/1.2/default/Tuner.cpp
+++ b/broadcastradio/1.2/default/Tuner.cpp
@@ -382,6 +382,22 @@
     return {};
 }
 
+Return<void> Tuner::setParameters(const hidl_vec<VendorKeyValue>& /* parameters */,
+        setParameters_cb _hidl_cb) {
+    ALOGV("%s", __func__);
+
+    _hidl_cb({});
+    return {};
+}
+
+Return<void> Tuner::getParameters(const hidl_vec<hidl_string>& /* keys */,
+        getParameters_cb _hidl_cb) {
+    ALOGV("%s", __func__);
+
+    _hidl_cb({});
+    return {};
+}
+
 }  // namespace implementation
 }  // namespace V1_2
 }  // namespace broadcastradio
diff --git a/broadcastradio/1.2/default/Tuner.h b/broadcastradio/1.2/default/Tuner.h
index 3cf077b..7e68354 100644
--- a/broadcastradio/1.2/default/Tuner.h
+++ b/broadcastradio/1.2/default/Tuner.h
@@ -49,6 +49,10 @@
                                         getProgramList_cb _hidl_cb) override;
     virtual Return<Result> setAnalogForced(bool isForced) override;
     virtual Return<void> isAnalogForced(isAnalogForced_cb _hidl_cb) override;
+    virtual Return<void> setParameters(const hidl_vec<V1_1::VendorKeyValue>& parameters,
+                                       setParameters_cb _hidl_cb) override;
+    virtual Return<void> getParameters(const hidl_vec<hidl_string>& keys,
+                                       getParameters_cb _hidl_cb) override;
 
    private:
     std::mutex mMut;