Skip to content

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

Launcher: open package-name app launches (market://launch?id=…) after launcherx is disabled (#1059)

Kyler Wilson2141d052a853
diff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xml
index 80124b58a..ea1598f3f 100644
--- a/launcher/app/src/main/AndroidManifest.xml
+++ b/launcher/app/src/main/AndroidManifest.xml
@@ -149,6 +149,22 @@
android:resource="@xml/home_key_service" />
</service>
+ <!-- market://launch?id=<package>: package-name app launches from the Android TV Remote service
+ (Home Assistant android_tv_remote), normally served by the stock launcher. -->
+ <activity
+ android:name=".AppLaunchActivity"
+ android:exported="true"
+ android:excludeFromRecents="true"
+ android:noHistory="true"
+ android:theme="@android:style/Theme.NoDisplay">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.BROWSABLE" />
+ <data android:scheme="market" android:host="launch" />
+ </intent-filter>
+ </activity>
+
<!-- The same clock, started by Home itself after home_idle_clock_minutes without input. -->
<activity
android:name=".ClockActivity"
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppLaunchActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/AppLaunchActivity.java
new file mode 100644
index 000000000..1a9f6158b
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppLaunchActivity.java
@@ -0,0 +1,28 @@
+package com.gathin.tvhome;
+
+import android.app.Activity;
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+
+/** Handles market://launch?id=<package> (Android TV Remote "launch app" by package name), which the
+ * stock launcher normally serves: opens the app's TV launch intent, then the phone launch intent. */
+public class AppLaunchActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle state) {
+ super.onCreate(state);
+ try {
+ Uri data = getIntent().getData();
+ String pkg = data == null ? null : data.getQueryParameter("id");
+ if (pkg != null) {
+ Intent launch = getPackageManager().getLeanbackLaunchIntentForPackage(pkg);
+ if (launch == null) launch = getPackageManager().getLaunchIntentForPackage(pkg);
+ if (launch != null) startActivity(launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+ }
+ } catch (ActivityNotFoundException | SecurityException ignored) {
+ } finally {
+ finish();
+ }
+ }
+}