Skip to content

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

docs: how a launcher reads other apps' Continue watching rows

Alexis Ricoe169a1201f35
diff --git a/docs/modules.md b/docs/modules.md
index 8397b93d9..593a1ea6d 100644
--- a/docs/modules.md
+++ b/docs/modules.md
@@ -108,3 +108,6 @@ Publish the APK's own SHA-256 next to it as well.
Retro, an NES library for the TV, declares a card exactly as above:
<https://github.com/udhaykumarbala/tv-vibehack-retro>.
+
+A launcher that wants other apps' Continue watching rows can read them, see
+[`docs/watch-next.md`](watch-next.md).
diff --git a/docs/watch-next.md b/docs/watch-next.md
new file mode 100644
index 000000000..0e7a66713
--- /dev/null
+++ b/docs/watch-next.md
@@ -0,0 +1,19 @@
+# Reading Continue watching
+
+A launcher can show the rows other apps publish to the system's Continue watching (Watch Next)
+and preview channels. They live in the TV provider, behind `TvContract.WatchNextPrograms` and
+`TvContract.PreviewPrograms`.
+
+- **Permission:** `android.permission.READ_TV_LISTINGS`, a runtime permission. Request it with
+ the normal dialog, or grant it from a shell: `pm grant <package> android.permission.READ_TV_LISTINGS`.
+- **Not needed:** `com.android.providers.tv.permission.ACCESS_ALL_EPG_DATA` is
+ `signature|privileged`, so a sideloaded app cannot hold it. With only `READ_TV_LISTINGS` a query returns
+ the caller's own rows plus every row marked `searchable`.
+- **Query without a selection:** a caller without `ACCESS_ALL_EPG_DATA` gets a `SecurityException`
+ when it passes one. Read the whole table and filter in code.
+- **Some apps publish nothing.** Rows exist only if the app writes them and marks them
+ searchable, and some apps do neither, so query on the target TV before relying on an app.
+
+Source: `createSqlParams()` in `packages/providers/TvProvider/src/com/android/providers/tv/TvProvider.java`
+(AOSP) holds the `READ_TV_LISTINGS` and `searchable` logic; both permissions are defined in that
+module's `AndroidManifest.xml`.