diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-01-10 21:35:33 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-01-10 21:35:33 +0000 |
commit | 9672b8e28d2bfc41133d12c6b735b6c09ba80d65 (patch) | |
tree | 54b39a9f0dd09168a33e8668f758d0a531849b70 | |
parent | 80f89bbdc737202bcb4934e392ea54618ea28206 (diff) | |
parent | 9bf17c66671c447eb7d7fa4a3b28e4bc4b824bee (diff) |
Merge "Move LNB and constants"
-rw-r--r-- | media/java/android/media/tv/tuner/Lnb.java | 202 | ||||
-rw-r--r-- | media/java/android/media/tv/tuner/Tuner.java | 104 | ||||
-rw-r--r-- | media/java/android/media/tv/tuner/TunerConstants.java | 81 | ||||
-rw-r--r-- | media/java/android/media/tv/tuner/frontend/FrontendStatus.java | 4 |
4 files changed, 233 insertions, 158 deletions
diff --git a/media/java/android/media/tv/tuner/Lnb.java b/media/java/android/media/tv/tuner/Lnb.java new file mode 100644 index 000000000000..f181b49239d7 --- /dev/null +++ b/media/java/android/media/tv/tuner/Lnb.java @@ -0,0 +1,202 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.media.tv.tuner; + +import android.annotation.IntDef; +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.RequiresPermission; +import android.content.Context; +import android.hardware.tv.tuner.V1_0.Constants; +import android.media.tv.tuner.Tuner.LnbCallback; +import android.media.tv.tuner.TunerConstants.Result; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * LNB (low-noise block downconverter) for satellite tuner. + * + * A Tuner LNB (low-noise block downconverter) is used by satellite frontend to receive the + * microwave signal from the satellite, amplify it, and downconvert the frequency to a lower + * frequency. + * + * @hide + */ +public class Lnb implements AutoCloseable { + /** @hide */ + @IntDef({VOLTAGE_NONE, VOLTAGE_5V, VOLTAGE_11V, VOLTAGE_12V, VOLTAGE_13V, VOLTAGE_14V, + VOLTAGE_15V, VOLTAGE_18V, VOLTAGE_19V}) + @Retention(RetentionPolicy.SOURCE) + public @interface Voltage {} + + /** + * LNB power voltage not set. + */ + public static final int VOLTAGE_NONE = Constants.LnbVoltage.NONE; + /** + * LNB power voltage 5V. + */ + public static final int VOLTAGE_5V = Constants.LnbVoltage.VOLTAGE_5V; + /** + * LNB power voltage 11V. + */ + public static final int VOLTAGE_11V = Constants.LnbVoltage.VOLTAGE_11V; + /** + * LNB power voltage 12V. + */ + public static final int VOLTAGE_12V = Constants.LnbVoltage.VOLTAGE_12V; + /** + * LNB power voltage 13V. + */ + public static final int VOLTAGE_13V = Constants.LnbVoltage.VOLTAGE_13V; + /** + * LNB power voltage 14V. + */ + public static final int VOLTAGE_14V = Constants.LnbVoltage.VOLTAGE_14V; + /** + * LNB power voltage 15V. + */ + public static final int VOLTAGE_15V = Constants.LnbVoltage.VOLTAGE_15V; + /** + * LNB power voltage 18V. + */ + public static final int VOLTAGE_18V = Constants.LnbVoltage.VOLTAGE_18V; + /** + * LNB power voltage 19V. + */ + public static final int VOLTAGE_19V = Constants.LnbVoltage.VOLTAGE_19V; + + /** @hide */ + @IntDef({TONE_NONE, TONE_CONTINUOUS}) + @Retention(RetentionPolicy.SOURCE) + public @interface Tone {} + + /** + * LNB tone mode not set. + */ + public static final int TONE_NONE = Constants.LnbTone.NONE; + /** + * LNB continuous tone mode. + */ + public static final int TONE_CONTINUOUS = Constants.LnbTone.CONTINUOUS; + + /** @hide */ + @IntDef({POSITION_UNDEFINED, POSITION_A, POSITION_B}) + @Retention(RetentionPolicy.SOURCE) + public @interface Position {} + + /** + * LNB position is not defined. + */ + public static final int POSITION_UNDEFINED = Constants.LnbPosition.UNDEFINED; + /** + * Position A of two-band LNBs + */ + public static final int POSITION_A = Constants.LnbPosition.POSITION_A; + /** + * Position B of two-band LNBs + */ + public static final int POSITION_B = Constants.LnbPosition.POSITION_B; + + int mId; + LnbCallback mCallback; + Context mContext; + + private native int nativeSetVoltage(int voltage); + private native int nativeSetTone(int tone); + private native int nativeSetSatellitePosition(int position); + private native int nativeSendDiseqcMessage(byte[] message); + private native int nativeClose(); + + Lnb(int id) { + mId = id; + } + + /** @hide */ + public void setCallback(@Nullable LnbCallback callback) { + mCallback = callback; + if (mCallback == null) { + return; + } + } + + /** + * Sets the LNB's power voltage. + * + * @param voltage the power voltage constant the Lnb to use. + * @return result status of the operation. + */ + @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) + @Result + public int setVoltage(@Voltage int voltage) { + TunerUtils.checkTunerPermission(mContext); + return nativeSetVoltage(voltage); + } + + /** + * Sets the LNB's tone mode. + * + * @param tone the tone mode the Lnb to use. + * @return result status of the operation. + */ + @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) + @Result + public int setTone(@Tone int tone) { + TunerUtils.checkTunerPermission(mContext); + return nativeSetTone(tone); + } + + /** + * Selects the LNB's position. + * + * @param position the position the Lnb to use. + * @return result status of the operation. + */ + @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) + @Result + public int setSatellitePosition(@Position int position) { + TunerUtils.checkTunerPermission(mContext); + return nativeSetSatellitePosition(position); + } + + /** + * Sends DiSEqC (Digital Satellite Equipment Control) message. + * + * The response message from the device comes back through callback onDiseqcMessage. + * + * @param message a byte array of data for DiSEqC message which is specified by EUTELSAT Bus + * Functional Specification Version 4.2. + * + * @return result status of the operation. + */ + @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) + @Result + public int sendDiseqcMessage(@NonNull byte[] message) { + TunerUtils.checkTunerPermission(mContext); + return nativeSendDiseqcMessage(message); + } + + /** + * Releases the LNB instance. + */ + @RequiresPermission(android.Manifest.permission.ACCESS_TV_TUNER) + public void close() { + TunerUtils.checkTunerPermission(mContext); + nativeClose(); + } +} diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java index 962a7f6d58f6..f8b46b305216 100644 --- a/media/java/android/media/tv/tuner/Tuner.java +++ b/media/java/android/media/tv/tuner/Tuner.java @@ -24,9 +24,6 @@ import android.content.Context; import android.media.tv.tuner.TunerConstants.FilterStatus; import android.media.tv.tuner.TunerConstants.FilterSubtype; import android.media.tv.tuner.TunerConstants.FrontendScanType; -import android.media.tv.tuner.TunerConstants.LnbPosition; -import android.media.tv.tuner.TunerConstants.LnbTone; -import android.media.tv.tuner.TunerConstants.LnbVoltage; import android.media.tv.tuner.TunerConstants.Result; import android.media.tv.tuner.filter.FilterConfiguration.FilterType; import android.media.tv.tuner.filter.FilterEvent; @@ -219,11 +216,6 @@ public final class Tuner implements AutoCloseable { } break; } - case MSG_ON_LNB_EVENT: { - if (mLnb != null && mLnb.mCallback != null) { - mLnb.mCallback.onEvent(msg.arg1); - } - } default: // fall through } @@ -474,102 +466,6 @@ public final class Tuner implements AutoCloseable { return filter; } - /** - * Open a time filter instance. - * - * It is used to open time filter of demux. - * - * @return a time filter instance. - * @hide - */ - public TimeFilter openTimeFilter() { - return nativeOpenTimeFilter(); - } - - /** @hide */ - public class Lnb { - private int mId; - private LnbCallback mCallback; - - private native int nativeSetVoltage(int voltage); - private native int nativeSetTone(int tone); - private native int nativeSetSatellitePosition(int position); - private native int nativeSendDiseqcMessage(byte[] message); - private native int nativeClose(); - - private Lnb(int id) { - mId = id; - } - - public void setCallback(@Nullable LnbCallback callback) { - mCallback = callback; - if (mCallback == null) { - return; - } - if (mHandler == null) { - mHandler = createEventHandler(); - } - } - - /** - * Sets the LNB's power voltage. - * - * @param voltage the power voltage the Lnb to use. - * @return result status of the operation. - */ - @Result - public int setVoltage(@LnbVoltage int voltage) { - return nativeSetVoltage(voltage); - } - - /** - * Sets the LNB's tone mode. - * - * @param tone the tone mode the Lnb to use. - * @return result status of the operation. - */ - @Result - public int setTone(@LnbTone int tone) { - return nativeSetTone(tone); - } - - /** - * Selects the LNB's position. - * - * @param position the position the Lnb to use. - * @return result status of the operation. - */ - @Result - public int setSatellitePosition(@LnbPosition int position) { - return nativeSetSatellitePosition(position); - } - - /** - * Sends DiSEqC (Digital Satellite Equipment Control) message. - * - * The response message from the device comes back through callback onDiseqcMessage. - * - * @param message a byte array of data for DiSEqC message which is specified by EUTELSAT Bus - * Functional Specification Version 4.2. - * - * @return result status of the operation. - */ - @Result - public int sendDiseqcMessage(byte[] message) { - return nativeSendDiseqcMessage(message); - } - - /** - * Releases the LNB instance - * - * @return result status of the operation. - */ - @Result - public int close() { - return nativeClose(); - } - } - private List<Integer> getLnbIds() { mLnbIds = nativeGetLnbIds(); return mLnbIds; diff --git a/media/java/android/media/tv/tuner/TunerConstants.java b/media/java/android/media/tv/tuner/TunerConstants.java index bbaa5180aece..203eff8187b2 100644 --- a/media/java/android/media/tv/tuner/TunerConstants.java +++ b/media/java/android/media/tv/tuner/TunerConstants.java @@ -1263,68 +1263,45 @@ public final class TunerConstants { /** @hide */ - @IntDef({LNB_VOLTAGE_NONE, LNB_VOLTAGE_5V, LNB_VOLTAGE_11V, LNB_VOLTAGE_12V, LNB_VOLTAGE_13V, - LNB_VOLTAGE_14V, LNB_VOLTAGE_15V, LNB_VOLTAGE_18V, LNB_VOLTAGE_19V}) - @Retention(RetentionPolicy.SOURCE) - public @interface LnbVoltage {} - /** @hide */ - public static final int LNB_VOLTAGE_NONE = Constants.LnbVoltage.NONE; - /** @hide */ - public static final int LNB_VOLTAGE_5V = Constants.LnbVoltage.VOLTAGE_5V; - /** @hide */ - public static final int LNB_VOLTAGE_11V = Constants.LnbVoltage.VOLTAGE_11V; - /** @hide */ - public static final int LNB_VOLTAGE_12V = Constants.LnbVoltage.VOLTAGE_12V; - /** @hide */ - public static final int LNB_VOLTAGE_13V = Constants.LnbVoltage.VOLTAGE_13V; - /** @hide */ - public static final int LNB_VOLTAGE_14V = Constants.LnbVoltage.VOLTAGE_14V; - /** @hide */ - public static final int LNB_VOLTAGE_15V = Constants.LnbVoltage.VOLTAGE_15V; - /** @hide */ - public static final int LNB_VOLTAGE_18V = Constants.LnbVoltage.VOLTAGE_18V; - /** @hide */ - public static final int LNB_VOLTAGE_19V = Constants.LnbVoltage.VOLTAGE_19V; - - /** @hide */ - @IntDef({LNB_TONE_NONE, LNB_TONE_CONTINUOUS}) - @Retention(RetentionPolicy.SOURCE) - public @interface LnbTone {} - /** @hide */ - public static final int LNB_TONE_NONE = Constants.LnbTone.NONE; - /** @hide */ - public static final int LNB_TONE_CONTINUOUS = Constants.LnbTone.CONTINUOUS; - - /** @hide */ - @IntDef({LNB_POSITION_UNDEFINED, LNB_POSITION_A, LNB_POSITION_B}) - @Retention(RetentionPolicy.SOURCE) - public @interface LnbPosition {} - /** @hide */ - public static final int LNB_POSITION_UNDEFINED = Constants.LnbPosition.UNDEFINED; - /** @hide */ - public static final int LNB_POSITION_A = Constants.LnbPosition.POSITION_A; - /** @hide */ - public static final int LNB_POSITION_B = Constants.LnbPosition.POSITION_B; - - - /** @hide */ @IntDef({RESULT_SUCCESS, RESULT_UNAVAILABLE, RESULT_NOT_INITIALIZED, RESULT_INVALID_STATE, RESULT_INVALID_ARGUMENT, RESULT_OUT_OF_MEMORY, RESULT_UNKNOWN_ERROR}) @Retention(RetentionPolicy.SOURCE) public @interface Result {} - /** @hide */ + + /** + * Operation succeeded. + * @hide + */ public static final int RESULT_SUCCESS = Constants.Result.SUCCESS; - /** @hide */ + /** + * Operation failed because the corresponding resources are not available. + * @hide + */ public static final int RESULT_UNAVAILABLE = Constants.Result.UNAVAILABLE; - /** @hide */ + /** + * Operation failed because the corresponding resources are not initialized. + * @hide + */ public static final int RESULT_NOT_INITIALIZED = Constants.Result.NOT_INITIALIZED; - /** @hide */ + /** + * Operation failed because it's not in a valid state. + * @hide + */ public static final int RESULT_INVALID_STATE = Constants.Result.INVALID_STATE; - /** @hide */ + /** + * Operation failed because there are invalid arguments. + * @hide + */ public static final int RESULT_INVALID_ARGUMENT = Constants.Result.INVALID_ARGUMENT; - /** @hide */ + /** + * Memory allocation failed. + * @hide + */ public static final int RESULT_OUT_OF_MEMORY = Constants.Result.OUT_OF_MEMORY; - /** @hide */ + /** + * Operation failed due to unknown errors. + * @hide + */ public static final int RESULT_UNKNOWN_ERROR = Constants.Result.UNKNOWN_ERROR; private TunerConstants() { diff --git a/media/java/android/media/tv/tuner/frontend/FrontendStatus.java b/media/java/android/media/tv/tuner/frontend/FrontendStatus.java index 89ec536a1d6c..fb5d62afd2f2 100644 --- a/media/java/android/media/tv/tuner/frontend/FrontendStatus.java +++ b/media/java/android/media/tv/tuner/frontend/FrontendStatus.java @@ -16,13 +16,13 @@ package android.media.tv.tuner.frontend; +import android.media.tv.tuner.Lnb; import android.media.tv.tuner.TunerConstants; import android.media.tv.tuner.TunerConstants.FrontendDvbcSpectralInversion; import android.media.tv.tuner.TunerConstants.FrontendDvbtHierarchy; import android.media.tv.tuner.TunerConstants.FrontendInnerFec; import android.media.tv.tuner.TunerConstants.FrontendModulation; import android.media.tv.tuner.TunerConstants.FrontendStatusType; -import android.media.tv.tuner.TunerConstants.LnbVoltage; /** * Frontend status @@ -128,7 +128,7 @@ public class FrontendStatus { return (int) mValue; } /** Power Voltage Type for LNB. */ - @LnbVoltage + @Lnb.Voltage public int getLnbVoltage() { if (mType != TunerConstants.FRONTEND_STATUS_TYPE_LNB_VOLTAGE) { throw new IllegalStateException(); |