Merge "Support Link/Unlink Cicam to Frontend in Tuner HAL 1.1"
diff --git a/tv/tuner/1.1/IFrontend.hal b/tv/tuner/1.1/IFrontend.hal
index e9c5e19..63f0655 100644
--- a/tv/tuner/1.1/IFrontend.hal
+++ b/tv/tuner/1.1/IFrontend.hal
@@ -77,11 +77,22 @@
      * directly from the frontend.
      *
      * @param ciCamId specify CI-CAM Id to link.
+     * @return ltsId Local Transport Stream Id.
      * @return result Result status of the operation.
      *         SUCCESS if successful,
      *         UNKNOWN_ERROR if failed for other reasons.
      */
-    linkCiCam(uint32_t ciCamId) generates (Result result);
+    linkCiCam(uint32_t ciCamId) generates (Result result, uint32_t ltsId);
+
+    /**
+     * Unlink Conditional Access Modules (CAM) to Frontend.
+     *
+     * @param ciCamId specify CI-CAM Id to unlink.
+     * @return result Result status of the operation.
+     *         SUCCESS if successful,
+     *         UNKNOWN_ERROR if failed for other reasons.
+     */
+    unlinkCiCam(uint32_t ciCamId) generates (Result result);
 
     /**
      * Get the v1_1 extended statuses of the frontend.
diff --git a/tv/tuner/1.1/default/Frontend.cpp b/tv/tuner/1.1/default/Frontend.cpp
index 7c6f8c6..069456d 100644
--- a/tv/tuner/1.1/default/Frontend.cpp
+++ b/tv/tuner/1.1/default/Frontend.cpp
@@ -364,10 +364,19 @@
     return Result::SUCCESS;
 }
 
-Return<Result> Frontend::linkCiCam(uint32_t ciCamId) {
+Return<void> Frontend::linkCiCam(uint32_t ciCamId, linkCiCam_cb _hidl_cb) {
     ALOGV("%s", __FUNCTION__);
 
     mCiCamId = ciCamId;
+    _hidl_cb(Result::SUCCESS, 0 /*ltsId*/);
+
+    return Void();
+}
+
+Return<Result> Frontend::unlinkCiCam(uint32_t /*ciCamId*/) {
+    ALOGV("%s", __FUNCTION__);
+
+    mCiCamId = -1;
 
     return Result::SUCCESS;
 }
diff --git a/tv/tuner/1.1/default/Frontend.h b/tv/tuner/1.1/default/Frontend.h
index 4c35718..a28fb64 100644
--- a/tv/tuner/1.1/default/Frontend.h
+++ b/tv/tuner/1.1/default/Frontend.h
@@ -66,7 +66,9 @@
 
     virtual Return<Result> setLnb(uint32_t lnb) override;
 
-    virtual Return<Result> linkCiCam(uint32_t ciCamId) override;
+    virtual Return<void> linkCiCam(uint32_t ciCamId, linkCiCam_cb _hidl_cb) override;
+
+    virtual Return<Result> unlinkCiCam(uint32_t ciCamId) override;
 
     FrontendType getFrontendType();
 
diff --git a/tv/tuner/1.1/types.hal b/tv/tuner/1.1/types.hal
index f8fe2aa..695826a 100644
--- a/tv/tuner/1.1/types.hal
+++ b/tv/tuner/1.1/types.hal
@@ -58,6 +58,11 @@
      * be used to reset the configured ip context id.
      */
     INVALID_IP_FILTER_CONTEXT_ID = 0xFFFFFFFF,
+    /**
+     * An invalid local transport stream id used as the return value on a failed operation of
+     * IFrontend.linkCiCam.
+     */
+    INVALID_LTS_ID = 0xFFFFFFFF,
 };
 
 @export