aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/tuner/util/TunerInputInfoUtils.java
diff options
context:
space:
mode:
authorNick Chalko <nchalko@google.com>2017-05-09 14:07:44 -0700
committerNick Chalko <nchalko@google.com>2017-05-10 09:49:18 -0700
commit0550a7221be0581b0bd421a9d70400ff8699a6e7 (patch)
tree14d9836ff9283690321c166560ee3450792236ad /src/com/android/tv/tuner/util/TunerInputInfoUtils.java
parent430c2be3b91676005fdd243553e38acff8dfc3de (diff)
downloadTV-0550a7221be0581b0bd421a9d70400ff8699a6e7.tar.gz
hash 550cbec17259717c5453f6be1eb05736ba10ef1d Bug: 37849928 Test: tested on vendor branch Change-Id: I82190481d2bcef2b89e78414b6b92ed97720749d Merged-In: I4199ec04cacb4a78be58b85302a39d917658dc28
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 5c411f64..fd9ec77d 100644
--- a/src/com/android/tv/tuner/util/TunerInputInfoUtils.java
+++ b/src/com/android/tv/tuner/util/TunerInputInfoUtils.java
@@ -25,6 +25,7 @@ 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;
@@ -43,23 +44,31 @@ public class TunerInputInfoUtils {
*/
@Nullable
@TargetApi(Build.VERSION_CODES.N)
- public static TvInputInfo buildTunerInputInfo(Context context, boolean fromBuiltInTuner) {
- int numOfDevices = TunerHal.getTunerCount(context);
- if (numOfDevices == 0) {
+ public static TvInputInfo buildTunerInputInfo(Context context) {
+ Pair<Integer, Integer> tunerTypeAndCount = TunerHal.getTunerTypeAndCount(context);
+ if (tunerTypeAndCount.first == null || tunerTypeAndCount.second == 0) {
return null;
}
- 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);
+ 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;
}
try {
- return builder.setCanRecord(CommonFeatures.DVR.isEnabled(context))
- .setTunerCount(numOfDevices)
+ TvInputInfo.Builder builder = new TvInputInfo.Builder(context,
+ new ComponentName(context, TunerTvInputService.class));
+ return builder.setLabel(inputLabelId)
+ .setCanRecord(CommonFeatures.DVR.isEnabled(context))
+ .setTunerCount(tunerTypeAndCount.second)
.build();
- } catch (NullPointerException e) {
+ } catch (IllegalArgumentException | NullPointerException e) {
// TunerTvInputService is not enabled.
return null;
}
@@ -73,7 +82,7 @@ public class TunerInputInfoUtils {
public static void updateTunerInputInfo(Context context) {
if (BuildCompat.isAtLeastN()) {
if (DEBUG) Log.d(TAG, "updateTunerInputInfo()");
- TvInputInfo info = buildTunerInputInfo(context, isBuiltInTuner(context));
+ TvInputInfo info = buildTunerInputInfo(context);
if (info != null) {
((TvInputManager) context.getSystemService(Context.TV_INPUT_SERVICE))
.updateTvInputInfo(info);
@@ -88,13 +97,4 @@ public class TunerInputInfoUtils {
}
}
}
-
- /**
- * 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;
- }
-}
+} \ No newline at end of file