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

Commit df0e8296 authored by Hongguang Chen's avatar Hongguang Chen Committed by Android (Google) Code Review
Browse files

Merge "Add isLnaSupported API"

parents 77eb98c8 7fd495d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7269,6 +7269,7 @@ package android.media.tv.tuner {
    method @NonNull public java.util.List<android.media.tv.tuner.frontend.FrontendStatusReadiness> getFrontendStatusReadiness(@NonNull int[]);
    method @IntRange(from=0xffffffff) public int getMaxNumberOfFrontends(int);
    method @RequiresPermission("android.permission.TUNER_RESOURCE_ACCESS") public boolean hasUnusedFrontend(int);
    method public boolean isLnaSupported();
    method public boolean isLowestPriority(int);
    method @Nullable @RequiresPermission(android.Manifest.permission.ACCESS_TV_DESCRAMBLER) public android.media.tv.tuner.Descrambler openDescrambler();
    method @Nullable public android.media.tv.tuner.dvr.DvrPlayback openDvrPlayback(long, @NonNull java.util.concurrent.Executor, @NonNull android.media.tv.tuner.dvr.OnPlaybackStatusChangedListener);
+23 −1
Original line number Diff line number Diff line
@@ -998,6 +998,7 @@ public class Tuner implements AutoCloseable {
    private native int nativeScan(int settingsType, FrontendSettings settings, int scanType);
    private native int nativeStopScan();
    private native int nativeSetLnb(Lnb lnb);
    private native boolean nativeIsLnaSupported();
    private native int nativeSetLna(boolean enable);
    private native FrontendStatus nativeGetFrontendStatus(int[] statusTypes);
    private native Integer nativeGetAvSyncHwId(Filter filter);
@@ -1381,12 +1382,33 @@ public class Tuner implements AutoCloseable {
        }
    }

    /**
     * Is Low Noise Amplifier (LNA) supported by the Tuner.
     *
     * <p>This API is only supported by Tuner HAL 3.0 or higher.
     * Unsupported version would throw UnsupportedOperationException. Use
     * {@link TunerVersionChecker#getTunerVersion()} to check the version.
     *
     * @return {@code true} if supported, otherwise {@code false}.
     * @throws UnsupportedOperationException if the Tuner HAL version is lower than 3.0
     * @see android.media.tv.tuner.TunerVersionChecker#TUNER_VERSION_3_0
     */
    public boolean isLnaSupported() {
        if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
                TunerVersionChecker.TUNER_VERSION_3_0, "isLnaSupported")) {
            throw new UnsupportedOperationException("Tuner HAL version "
                    + TunerVersionChecker.getTunerVersion() + " doesn't support this method.");
        }
        return nativeIsLnaSupported();
    }

    /**
     * Enable or Disable Low Noise Amplifier (LNA).
     *
     * @param enable {@code true} to activate LNA module; {@code false} to deactivate LNA.
     *
     * @return result status of the operation.
     * @return result status of the operation. {@link #RESULT_UNAVAILABLE} if the device doesn't
     *         support LNA.
     */
    @Result
    public int setLnaEnabled(boolean enable) {
+13 −0
Original line number Diff line number Diff line
@@ -1819,6 +1819,13 @@ int JTuner::setLnb(sp<LnbClient> lnbClient) {
    return (int)result;
}

bool JTuner::isLnaSupported() {
    if (sTunerClient == nullptr) {
        return (int)Result::NOT_INITIALIZED;
    }
    return sTunerClient->isLnaSupported();
}

int JTuner::setLna(bool enable) {
    if (sTunerClient == nullptr) {
        return (int)Result::NOT_INITIALIZED;
@@ -3562,6 +3569,11 @@ static int android_media_tv_Tuner_set_lnb(JNIEnv *env, jobject thiz, jobject lnb
    return tuner->setLnb(lnbClient);
}

static bool android_media_tv_Tuner_is_lna_supported(JNIEnv *env, jobject thiz) {
    sp<JTuner> tuner = getTuner(env, thiz);
    return tuner->isLnaSupported();
}

static int android_media_tv_Tuner_set_lna(JNIEnv *env, jobject thiz, jboolean enable) {
    sp<JTuner> tuner = getTuner(env, thiz);
    return tuner->setLna(enable);
@@ -4810,6 +4822,7 @@ static const JNINativeMethod gTunerMethods[] = {
            (void *)android_media_tv_Tuner_scan },
    { "nativeStopScan", "()I", (void *)android_media_tv_Tuner_stop_scan },
    { "nativeSetLnb", "(Landroid/media/tv/tuner/Lnb;)I", (void *)android_media_tv_Tuner_set_lnb },
    { "nativeIsLnaSupported", "()Z", (void *)android_media_tv_Tuner_is_lna_supported },
    { "nativeSetLna", "(Z)I", (void *)android_media_tv_Tuner_set_lna },
    { "nativeGetFrontendStatus", "([I)Landroid/media/tv/tuner/frontend/FrontendStatus;",
            (void *)android_media_tv_Tuner_get_frontend_status },
+1 −0
Original line number Diff line number Diff line
@@ -189,6 +189,7 @@ struct JTuner : public RefBase {
    int scan(const FrontendSettings& settings, FrontendScanType scanType);
    int stopScan();
    int setLnb(sp<LnbClient> lnbClient);
    bool isLnaSupported();
    int setLna(bool enable);
    jobject openLnbByHandle(int handle);
    jobject openLnbByName(jstring name);
+13 −0
Original line number Diff line number Diff line
@@ -210,4 +210,17 @@ int TunerClient::getMaxNumberOfFrontends(FrontendType frontendType) {
    return -1;
}

bool TunerClient::isLnaSupported() {
    if (mTunerService != nullptr) {
        bool lnaSupported;
        Status s = mTunerService->isLnaSupported(&lnaSupported);
        if (!s.isOk()) {
            return false;
        }
        return lnaSupported;
    }

    return false;
}

}  // namespace android
Loading