Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

fix: open the TV tuner from the Live TV entry instead of the last source

nowaka11334c1a9d7
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index 0732c3a65..9add607e6 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
@@ -404,6 +405,7 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
TvInputManager tim = (TvInputManager) getSystemService(TV_INPUT_SERVICE);
boolean sawNonHdmi = false;
+ String tunerId = null;
if (tim != null) {
List<TvInputInfo> inputs = new ArrayList<>(tim.getTvInputList());
// HDMI ports first in port order, then AV and the rest.
@@ -413,6 +415,11 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
return String.valueOf(a.loadLabel(this)).compareToIgnoreCase(String.valueOf(b.loadLabel(this)));
});
for (TvInputInfo info : inputs) {
+ if (info.getType() == TvInputInfo.TYPE_TUNER
+ && (info.getServiceInfo().applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
+ && (tunerId == null || info.getId().compareTo(tunerId) < 0)) {
+ tunerId = info.getId();
+ }
if (!info.isPassthroughInput()) continue;
CharSequence l = info.loadLabel(this);
String label = l == null ? info.getId() : l.toString();
@@ -428,9 +435,15 @@ public class MainActivity extends Activity implements AppAdapter.TileListener {
}
}
Intent liveTv = liveTvPkg.isEmpty() ? null : getPackageManager().getLeanbackLaunchIntentForPackage(liveTvPkg);
+ if (liveTv != null && tunerId != null) {
+ liveTv = new Intent(Intent.ACTION_VIEW)
+ .setDataAndType(TvContract.buildChannelUriForPassthroughInput(tunerId), "vnd.android.cursor.item/channel")
+ .setPackage(liveTvPkg);
+ }
if (liveTv != null) {
if (rows.getChildCount() > 0) addSeparator(rows);
- addInputRow(rows, popup, R.drawable.ic_livetv, getString(R.string.live_tv), -1, () -> open(liveTv));
+ final Intent liveTvIntent = liveTv;
+ addInputRow(rows, popup, R.drawable.ic_livetv, getString(R.string.live_tv), -1, () -> open(liveTvIntent));
}
if (rows.getChildCount() == 0) {
Toast.makeText(this, R.string.no_inputs, Toast.LENGTH_SHORT).show();