aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/tuner/util/TunerInputInfoUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/tv/tuner/util/TunerInputInfoUtils.java')
-rw-r--r--src/com/android/tv/tuner/util/TunerInputInfoUtils.java46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/com/android/tv/tuner/util/TunerInputInfoUtils.java b/src/com/android/tv/tuner/util/TunerInputInfoUtils.java
index fd9ec77d..5c411f64 100644
--- a/src/com/android/tv/tuner/util/TunerInputInfoUtils.java
+++ b/src/com/android/tv/tuner/util/TunerInputInfoUtils.java
@@ -25,7 +25,6 @@ import android.os.Build;
import android.support.annotation.Nullable;
import android.support.v4.os.BuildCompat;
import android.util.Log;
-import android.util.Pair;
import com.android.tv.common.feature.CommonFeatures;
import com.android.tv.tuner.R;
@@ -44,31 +43,23 @@ public class TunerInputInfoUtils {
*/
@Nullable
@TargetApi(Build.VERSION_CODES.N)
- public static TvInputInfo buildTunerInputInfo(Context context) {
- Pair<Integer, Integer> tunerTypeAndCount = TunerHal.getTunerTypeAndCount(context);
- if (tunerTypeAndCount.first == null || tunerTypeAndCount.second == 0) {
+ public static TvInputInfo buildTunerInputInfo(Context context, boolean fromBuiltInTuner) {
+ int numOfDevices = TunerHal.getTunerCount(context);
+ if (numOfDevices == 0) {
return null;
}
- int inputLabelId = 0;
- switch (tunerTypeAndCount.first) {
- case TunerHal.TUNER_TYPE_BUILT_IN:
- inputLabelId = R.string.bt_app_name;
- break;
- case TunerHal.TUNER_TYPE_USB:
- inputLabelId = R.string.ut_app_name;
- break;
- case TunerHal.TUNER_TYPE_NETWORK:
- inputLabelId = R.string.nt_app_name;
- break;
+ TvInputInfo.Builder builder = new TvInputInfo.Builder(context, new ComponentName(context,
+ TunerTvInputService.class));
+ if (fromBuiltInTuner) {
+ builder.setLabel(R.string.bt_app_name);
+ } else {
+ builder.setLabel(R.string.ut_app_name);
}
try {
- TvInputInfo.Builder builder = new TvInputInfo.Builder(context,
- new ComponentName(context, TunerTvInputService.class));
- return builder.setLabel(inputLabelId)
- .setCanRecord(CommonFeatures.DVR.isEnabled(context))
- .setTunerCount(tunerTypeAndCount.second)
+ return builder.setCanRecord(CommonFeatures.DVR.isEnabled(context))
+ .setTunerCount(numOfDevices)
.build();
- } catch (IllegalArgumentException | NullPointerException e) {
+ } catch (NullPointerException e) {
// TunerTvInputService is not enabled.
return null;
}
@@ -82,7 +73,7 @@ public class TunerInputInfoUtils {
public static void updateTunerInputInfo(Context context) {
if (BuildCompat.isAtLeastN()) {
if (DEBUG) Log.d(TAG, "updateTunerInputInfo()");
- TvInputInfo info = buildTunerInputInfo(context);
+ TvInputInfo info = buildTunerInputInfo(context, isBuiltInTuner(context));
if (info != null) {
((TvInputManager) context.getSystemService(Context.TV_INPUT_SERVICE))
.updateTvInputInfo(info);
@@ -97,4 +88,13 @@ public class TunerInputInfoUtils {
}
}
}
-} \ No newline at end of file
+
+ /**
+ * Returns if the current tuner service is for a built-in tuner.
+ *
+ * @param context {@link Context} instance
+ */
+ public static boolean isBuiltInTuner(Context context) {
+ return TunerHal.getTunerType(context) == TunerHal.TUNER_TYPE_BUILT_IN;
+ }
+}