Skip to content

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

Add-on: AirPlay Status

מקס חיים6236660d579e
diff --git a/addons/README.md b/addons/README.md
index c3f00031d..e2d79f955 100644
--- a/addons/README.md
+++ b/addons/README.md
@@ -20,6 +20,7 @@ the core bigger or change how it behaves. You install an add-on only if you want
| [TV Static](tv-static/) | An off-the-air moment each time the screen turns on: the picture opens from a bright line, snow and hiss, colour bars or an old "no signal" screen for 3 to 10 s, then fades into what was on screen; the card sets style, sound and length | [@luyzfernando08](https://github.com/luyzfernando08) | Xiaomi Mi Box S (Android TV 9), Philco by Skyworth (Android TV 14) | foreground service (screen-on watcher), start at boot, display over other apps | <img src="tv-static/screenshot.jpg" width="240" alt="TV Static on a TV"> |
| [Brightness](brightness/) | Dims the picture below the TV's own minimum over every app (and the picture settings on Realtek TVs), with a warm night mode on a schedule and a one-press normal screen | [@maxhayim](https://github.com/maxhayim) | MOKA R8G (Android 14) | overlay, foreground service, start at boot | <img src="brightness/screenshot.jpg" width="240" alt="Brightness on a TV"> |
| [Sleep Timer](sleep-timer/) | A sleep timer: 15 to 120 minutes, a one-minute countdown over what is playing with "15 more minutes", then standby; over HDMI-CEC the TV turns off with the box | [@luyzfernando08](https://github.com/luyzfernando08) | Xiaomi Mi Box S (Android TV 9) | accessibility (lock-screen action only), display over other apps, exact alarms | <img src="sleep-timer/screenshot.jpg" width="240" alt="Sleep Timer on a TV"> |
+| [AirPlay Status](airplay-status/) | How iPhones and Macs see this TV: its AirPlay name, screen mirroring offered or audio only (and why), and the other AirPlay receivers on the network | [@maxhayim](https://github.com/maxhayim) | MOKA R8G (Android 14) | network (mDNS listening only), network state | <img src="airplay-status/screenshot.jpg" width="240" alt="AirPlay Status on a TV"> |
A widget, an info tile, a storage or smart-home card: if it can live as its own small app, it can live
here. See the rules below.
diff --git a/addons/airplay-status/.gitignore b/addons/airplay-status/.gitignore
new file mode 100644
index 000000000..a7e04a21b
--- /dev/null
+++ b/addons/airplay-status/.gitignore
@@ -0,0 +1,4 @@
+.gradle/
+build/
+app/build/
+local.properties
diff --git a/addons/airplay-status/README.md b/addons/airplay-status/README.md
new file mode 100644
index 000000000..a39d71fe6
--- /dev/null
+++ b/addons/airplay-status/README.md
@@ -0,0 +1,60 @@
+# AirPlay Status
+
+How iPhones, iPads and Macs see this TV: the name it appears under, whether it offers screen mirroring or audio
+only, and the other AirPlay receivers on the network. It looks the way an iPhone does, by listening for mDNS
+announcements (`_airplay._tcp` for video and mirroring, `_raop._tcp` for audio) for six seconds while the screen
+is open. It is for TVs that run an AirPlay receiver such as
+[AirPlay Server](https://github.com/jqssun/android-airplay-server) (open source); it is not made by or affiliated
+with Apple or that project. For the [Clean Your TV](../../README.md) launcher it declares a
+[module card](../../docs/modules.md): once you answer **Show card** its tile reads "AirPlay Status" with a light
+blue glow. On any other Android TV home it is an ordinary app.
+
+![AirPlay Status on a TV](screenshot.jpg)
+
+| Row | What it shows |
+|---|---|
+| **iPhones and Macs see this TV as** | The name in the AirPlay menu, or Not seen. |
+| **Screen mirroring** | Offered, Audio only, or No. |
+| **Other AirPlay receivers here** | How many, with their names. |
+| **AirPlay Server** | Opens it, or says it isn't installed. |
+| **Look again** | Listens once more. |
+
+The line at the top explains what to do. The usual problem it catches: an AirPlay name exactly equal to the TV's
+own device name. Android 14 then refuses the second mDNS service under that name, so only the audio service is
+announced and iPhones offer no mirroring. A name that looks the same but differs (a non-breaking space) fixes it.
+
+## Permissions
+
+| Permission | Why |
+|---|---|
+| `INTERNET` | Android requires it for mDNS discovery through `NsdManager`. The app opens no connection to anything: it only listens for announcements on the home network. |
+| `ACCESS_NETWORK_STATE` | This TV's own addresses, to tell its announcement apart from other receivers'. |
+ Package visibility is limited to
+`io.github.jqssun.airplay`. Nothing is sent anywhere: it only listens on the home network, only while open. No
+background service, accounts, telemetry, ads or libraries.
+
+## Build and install
+
+JDK 17 and Android SDK platform 34 with build-tools 34.0.0, as for the launcher. From the repo root, with ADB on:
+
+```bash
+TV_HOST=<tv ip> addons/airplay-status/install.sh
+```
+
+To build only: `cd addons/airplay-status && ./gradlew assembleRelease`; the JVM tests run with
+`./gradlew testReleaseUnitTest`.
+
+## Limits
+
+- **AirPlay Server's own settings** answer only ADB (they need the `DUMP` permission), so this app can't read or
+ change them; it reports what the network sees, which is what an iPhone sees too.
+- **Networks that block mDNS** between devices (guest Wi-Fi, some mesh systems) hide receivers from this app
+ exactly as from an iPhone.
+
+## Tested on
+
+MOKA R8G (Android 14) with AirPlay Server 0.0.36, on a home app that implements the module-card spec: the card prompt and the card, the TV found under its AirPlay name with mirroring offered, and one other receiver on the network found by name. Testing found that Android requires `INTERNET` for `NsdManager` (it threw a SecurityException without it). Names in the screenshot are blurred. The JVM tests cover matching this TV's announcements, the `MAC@Name` form and the name clash.
+
+## Maintainer
+
+[@maxhayim](https://github.com/maxhayim)
diff --git a/addons/airplay-status/app/build.gradle b/addons/airplay-status/app/build.gradle
new file mode 100644
index 000000000..6851a6ee9
--- /dev/null
+++ b/addons/airplay-status/app/build.gradle
@@ -0,0 +1,36 @@
+plugins {
+ id 'com.android.application'
+}
+
+android {
+ namespace 'io.github.maxhayim.airplaystatus'
+ compileSdk 34
+
+ defaultConfig {
+ applicationId 'io.github.maxhayim.airplaystatus'
+ minSdk 26
+ targetSdk 34
+ versionCode 1
+ versionName '0.1'
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled true
+ shrinkResources true
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ // Sideloaded over ADB, never published: signed with the debug key, like the launcher.
+ signingConfig signingConfigs.debug
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
+}
+
+dependencies {
+ // No libraries in the APK. Test only: plain JVM tests in src/test.
+ testImplementation 'junit:junit:4.13.2'
+}
diff --git a/addons/airplay-status/app/proguard-rules.pro b/addons/airplay-status/app/proguard-rules.pro
new file mode 100644
index 000000000..a4435d69a
--- /dev/null
+++ b/addons/airplay-status/app/proguard-rules.pro
@@ -0,0 +1,2 @@
+# Keep class and method names: readable stack traces matter more than the last few KB in a sideloaded app.
+-dontobfuscate
diff --git a/addons/airplay-status/app/src/main/AndroidManifest.xml b/addons/airplay-status/app/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..9f5e5ed9a
--- /dev/null
+++ b/addons/airplay-status/app/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <uses-feature android:name="android.software.leanback" android:required="false" />
+ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
+
+ <!-- Android requires it for mDNS discovery (NsdManager). The app opens no connection: it only listens on the
+ home network for AirPlay announcements while its screen is open. -->
+ <uses-permission android:name="android.permission.INTERNET" />
+ <!-- This TV's own addresses, to tell its AirPlay announcement apart from other receivers'. -->
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+
+ <!-- Whether AirPlay Server is installed, and its launch intent. -->
+ <queries>
+ <package android:name="io.github.jqssun.airplay" />
+ </queries>
+
+ <application
+ android:allowBackup="false"
+ android:banner="@drawable/banner"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.DeviceDefault.NoActionBar">
+
+ <activity
+ android:name=".MainActivity"
+ android:exported="true"
+ android:launchMode="singleTask">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
+ </intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.gathin.tvhome.category.DOCK_CARD" />
+ </intent-filter>
+ <meta-data android:name="com.gathin.tvhome.card" android:resource="@xml/module_card" />
+ </activity>
+ </application>
+</manifest>
diff --git a/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/MainActivity.java b/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/MainActivity.java
new file mode 100644
index 000000000..4f155bc5c
--- /dev/null
+++ b/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/MainActivity.java
@@ -0,0 +1,222 @@
+package io.github.maxhayim.airplaystatus;
+
+import android.app.Activity;
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.ConnectivityManager;
+import android.net.LinkAddress;
+import android.net.LinkProperties;
+import android.net.Network;
+import android.net.nsd.NsdManager;
+import android.net.nsd.NsdServiceInfo;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import java.net.InetAddress;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * The tile and module card open this. It looks for AirPlay receivers the way an iPhone does (mDNS on the home
+ * network, for a few seconds while the screen is open) and says how this TV appears: its name, and whether
+ * screen mirroring is offered or audio only. Nothing runs when the screen is closed.
+ */
+public class MainActivity extends Activity {
+ private static final String TAG = "AirPlayStatus";
+ private static final String SERVER = "io.github.jqssun.airplay";
+ private static final long LOOK_MS = 6000;
+
+ private final Handler main = new Handler(Looper.getMainLooper());
+ private NsdManager nsd;
+ private final List<NsdManager.DiscoveryListener> discoveries = new ArrayList<>();
+ /** Resolved one at a time: older Android versions refuse a second resolve while one runs. */
+ private final ArrayDeque<NsdServiceInfo> toResolve = new ArrayDeque<>();
+ private boolean resolving;
+ private final List<Receivers.Seen> seen = new ArrayList<>();
+ private TextView status;
+ private Row nameRow, mirroringRow, othersRow, serverRow, againRow;
+ private boolean looking;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ nsd = getSystemService(NsdManager.class);
+ LinearLayout page = new LinearLayout(this);
+ page.setOrientation(LinearLayout.VERTICAL);
+ page.setBackgroundColor(0xFF0D1117);
+ page.setPadding(px(48), px(32), px(48), px(24));
+ TextView title = new TextView(this);
+ title.setText(R.string.app_name);
+ title.setTextSize(28);
+ title.setTextColor(0xFFFFFFFF);
+ status = new TextView(this);
+ status.setTextSize(15);
+ status.setTextColor(0xFF8B949E);
+ status.setPadding(0, 0, 0, px(16));
+ page.addView(title);
+ page.addView(status);
+ ScrollView scroll = new ScrollView(this);
+ LinearLayout rows = new LinearLayout(this);
+ rows.setOrientation(LinearLayout.VERTICAL);
+ scroll.addView(rows);
+ page.addView(scroll, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
+ setContentView(page);
+
+ nameRow = add(rows, new Row(this, "iPhones and Macs see this TV as", null, null));
+ mirroringRow = add(rows, new Row(this, "Screen mirroring", null, null));
+ othersRow = add(rows, new Row(this, "Other AirPlay receivers here", null, null));
+ serverRow = add(rows, new Row(this, "AirPlay Server", "The app that makes this TV an AirPlay receiver.",
+ this::openServer));
+ againRow = add(rows, new Row(this, "Look again", "Checks the network once more.", this::look));
+ againRow.requestFocus();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ look();
+ }
+
+ @Override
+ protected void onPause() {
+ stopLooking();
+ super.onPause();
+ }
+
+ private Row add(LinearLayout rows, Row r) {
+ rows.addView(r, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+ return r;
+ }
+
+ private void look() {
+ stopLooking();
+ seen.clear();
+ toResolve.clear();
+ looking = true;
+ status.setText("Looking on the network…");
+ for (String type : new String[]{Receivers.AIRPLAY, Receivers.RAOP}) {
+ NsdManager.DiscoveryListener l = new NsdManager.DiscoveryListener() {
+ @Override public void onServiceFound(NsdServiceInfo info) {
+ main.post(() -> {
+ toResolve.add(info);
+ resolveNext();
+ });
+ }
+ @Override public void onServiceLost(NsdServiceInfo info) { }
+ @Override public void onDiscoveryStarted(String t) { }
+ @Override public void onDiscoveryStopped(String t) { }
+ @Override public void onStartDiscoveryFailed(String t, int code) { Log.w(TAG, "discovery " + t + ": " + code); }
+ @Override public void onStopDiscoveryFailed(String t, int code) { }
+ };
+ try {
+ nsd.discoverServices(type, NsdManager.PROTOCOL_DNS_SD, l);
+ discoveries.add(l);
+ } catch (RuntimeException e) {
+ Log.w(TAG, "discovery not started: " + e.getMessage());
+ }
+ }
+ main.postDelayed(() -> {
+ stopLooking();
+ show();
+ }, LOOK_MS);
+ show();
+ }
+
+ private void stopLooking() {
+ main.removeCallbacksAndMessages(null);
+ for (NsdManager.DiscoveryListener l : discoveries) {
+ try {
+ nsd.stopServiceDiscovery(l);
+ } catch (RuntimeException ignored) {
+ // Already stopped.
+ }
+ }
+ discoveries.clear();
+ looking = false;
+ }
+
+ @SuppressWarnings("deprecation") // resolveService works on every version this app supports.
+ private void resolveNext() {
+ if (resolving || toResolve.isEmpty()) return;
+ resolving = true;
+ NsdServiceInfo info = toResolve.poll();
+ nsd.resolveService(info, new NsdManager.ResolveListener() {
+ @Override public void onServiceResolved(NsdServiceInfo r) {
+ InetAddress host = r.getHost();
+ String type = r.getServiceType() == null ? "" : r.getServiceType().replaceFirst("^\\.", "");
+ main.post(() -> {
+ seen.add(new Receivers.Seen(type, r.getServiceName(), host == null ? null : host.getHostAddress()));
+ resolving = false;
+ show();
+ resolveNext();
+ });
+ }
+
+ @Override public void onResolveFailed(NsdServiceInfo r, int code) {
+ main.post(() -> {
+ resolving = false;
+ resolveNext();
+ });
+ }
+ });
+ }
+
+ private void show() {
+ Set<String> own = ownAddresses();
+ Receivers.Mine mine = Receivers.mine(seen, own);
+ boolean installed = installed();
+ String device = Settings.Global.getString(getContentResolver(), Settings.Global.DEVICE_NAME);
+ nameRow.setValue(mine.name != null ? mine.name : looking ? "…" : "Not seen");
+ mirroringRow.setValue(mine.state == Receivers.State.MIRRORING ? "Offered"
+ : mine.state == Receivers.State.AUDIO_ONLY ? "Audio only" : looking ? "…" : "No");
+ List<String> others = Receivers.others(seen, own);
+ othersRow.setValue(others.isEmpty() ? (looking ? "…" : "None") : String.valueOf(others.size()));
+ othersRow.setDetail(others.isEmpty() ? null : String.join(", ", others));
+ serverRow.setValue(installed ? "Open" : "Not installed");
+ if (!looking) status.setText(Receivers.advice(mine, installed, device));
+ }
+
+ private Set<String> ownAddresses() {
+ Set<String> out = new HashSet<>();
+ ConnectivityManager cm = getSystemService(ConnectivityManager.class);
+ Network n = cm.getActiveNetwork();
+ LinkProperties lp = n == null ? null : cm.getLinkProperties(n);
+ if (lp != null) for (LinkAddress la : lp.getLinkAddresses()) out.add(la.getAddress().getHostAddress());
+ return out;
+ }
+
+ private boolean installed() {
+ try {
+ getPackageManager().getPackageInfo(SERVER, 0);
+ return true;
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
+ private void openServer() {
+ Intent i = getPackageManager().getLeanbackLaunchIntentForPackage(SERVER);
+ if (i == null) i = getPackageManager().getLaunchIntentForPackage(SERVER);
+ if (i == null) return;
+ try {
+ startActivity(i);
+ } catch (ActivityNotFoundException ignored) {
+ // Nothing to open.
+ }
+ }
+
+ private int px(int dp) {
+ return Math.round(dp * getResources().getDisplayMetrics().density);
+ }
+}
diff --git a/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/Receivers.java b/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/Receivers.java
new file mode 100644
index 000000000..eb6aaa02f
--- /dev/null
+++ b/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/Receivers.java
@@ -0,0 +1,104 @@
+package io.github.maxhayim.airplaystatus;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * What the network says about AirPlay, with no Android types, so the JVM tests cover it. An AirPlay receiver
+ * announces two mDNS services: _airplay._tcp (video and screen mirroring) and _raop._tcp (audio), whose name
+ * is "MAC@Name". iPhones offer mirroring only for a receiver with an _airplay service.
+ */
+final class Receivers {
+ static final String AIRPLAY = "_airplay._tcp";
+ static final String RAOP = "_raop._tcp";
+
+ /** One resolved announcement. */
+ static final class Seen {
+ final String type;
+ final String name;
+ final String host;
+
+ Seen(String type, String name, String host) {
+ this.type = type;
+ this.name = name;
+ this.host = host;
+ }
+ }
+
+ enum State { NOT_FOUND, AUDIO_ONLY, MIRRORING }
+
+ /** This TV's result, from what was seen and its own addresses. */
+ static final class Mine {
+ final State state;
+ final String name;
+
+ Mine(State state, String name) {
+ this.state = state;
+ this.name = name;
+ }
+ }
+
+ private Receivers() {
+ }
+
+ /** The name iPhones show: _raop names carry "MAC@" in front. */
+ static String display(String type, String name) {
+ if (name == null) return "";
+ if (type != null && type.startsWith(RAOP)) {
+ int at = name.indexOf('@');
+ if (at >= 0) return name.substring(at + 1);
+ }
+ return name;
+ }
+
+ static Mine mine(Collection<Seen> seen, Set<String> ownAddresses) {
+ String airplay = null, raop = null;
+ for (Seen s : seen) {
+ if (s.host == null || !ownAddresses.contains(s.host)) continue;
+ if (s.type.startsWith(AIRPLAY)) airplay = display(s.type, s.name);
+ else if (s.type.startsWith(RAOP)) raop = display(s.type, s.name);
+ }
+ if (airplay != null) return new Mine(State.MIRRORING, airplay);
+ if (raop != null) return new Mine(State.AUDIO_ONLY, raop);
+ return new Mine(State.NOT_FOUND, null);
+ }
+
+ /** Other receivers on the network by name, each once, this TV left out. */
+ static List<String> others(Collection<Seen> seen, Set<String> ownAddresses) {
+ Set<String> names = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
+ for (Seen s : seen) {
+ if (s.host != null && ownAddresses.contains(s.host)) continue;
+ String n = display(s.type, s.name);
+ if (!n.isEmpty()) names.add(n);
+ }
+ return new ArrayList<>(names);
+ }
+
+ /**
+ * Android 14 refuses a second mDNS service with exactly the TV's own name, so an AirPlay name equal to the
+ * device name usually leaves mirroring out. A lookalike (a non-breaking space) works.
+ */
+ static boolean clashes(String airplayName, String deviceName) {
+ return airplayName != null && deviceName != null
+ && airplayName.trim().toLowerCase(Locale.ROOT).equals(deviceName.trim().toLowerCase(Locale.ROOT));
+ }
+
+ static String advice(Mine m, boolean installed, String deviceName) {
+ switch (m.state) {
+ case MIRRORING:
+ return "iPhones, iPads and Macs can mirror their screen and play to this TV.";
+ case AUDIO_ONLY:
+ return clashes(m.name, deviceName)
+ ? "Audio only: the AirPlay name is the same as the TV's own name, so Android drops the"
+ + " mirroring announcement. Give AirPlay a slightly different name."
+ : "Audio only: screen mirroring isn't announced. Restarting AirPlay Server usually brings it back.";
+ default:
+ return installed ? "Not seen on the network. Open AirPlay Server and check it is running."
+ : "No AirPlay receiver on this TV. AirPlay Server (open source) adds one.";
+ }
+ }
+}
diff --git a/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/Row.java b/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/Row.java
new file mode 100644
index 000000000..c824d3c0f
--- /dev/null
+++ b/addons/airplay-status/app/src/main/java/io/github/maxhayim/airplaystatus/Row.java
@@ -0,0 +1,58 @@
+package io.github.maxhayim.airplaystatus;
+
+import android.content.Context;
+import android.view.Gravity;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+/**
+ * One settings row: a name with a line saying what it does on the left, its value on the right; OK runs it.
+ */
+final class Row extends LinearLayout {
+ private final TextView value;
+ private final TextView desc;
+
+ Row(Context context, String name, String description, Runnable onClick) {
+ super(context);
+ float dp = context.getResources().getDisplayMetrics().density;
+ setOrientation(HORIZONTAL);
+ setGravity(Gravity.CENTER_VERTICAL);
+ int ph = Math.round(16 * dp), pv = Math.round(10 * dp);
+ setPadding(ph, pv, ph, pv);
+ setBackgroundResource(R.drawable.row_background);
+ setFocusable(onClick != null);
+ setClickable(onClick != null);
+ if (onClick != null) setOnClickListener(v -> onClick.run());
+
+ LinearLayout text = new LinearLayout(context);
+ text.setOrientation(VERTICAL);
+ TextView label = new TextView(context);
+ label.setText(name);
+ label.setTextSize(17);
+ label.setTextColor(0xFFFFFFFF);
+ text.addView(label);
+ desc = new TextView(context);
+ desc.setTextSize(12);
+ desc.setTextColor(0xFF8B949E);
+ desc.setPadding(0, Math.round(2 * dp), Math.round(16 * dp), 0);
+ text.addView(desc);
+ setDetail(description);
+ addView(text, new LayoutParams(0, LayoutParams.WRAP_CONTENT, 1f));
+
+ value = new TextView(context);
+ value.setTextSize(17);
+ value.setTextColor(0xFFC9D1D9);
+ value.setGravity(Gravity.END);
+ value.setMinWidth(Math.round(90 * dp));
+ addView(value, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ }
+
+ void setDetail(String d) {
+ desc.setText(d == null ? "" : d);
+ desc.setVisibility(d == null || d.isEmpty() ? GONE : VISIBLE);
+ }
+
+ void setValue(String v) {
+ value.setText(v);
+ }
+}
diff --git a/addons/airplay-status/app/src/main/res/drawable/banner.xml b/addons/airplay-status/app/src/main/res/drawable/banner.xml
new file mode 100644
index 000000000..05117a8a5
--- /dev/null
+++ b/addons/airplay-status/app/src/main/res/drawable/banner.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 16:9 banner: a screen with a triangle under it and radio waves. Own art. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="320dp" android:height="180dp"
+ android:viewportWidth="320" android:viewportHeight="180">
+ <path android:fillColor="#101418" android:pathData="M0,0h320v180h-320z" />
+ <path android:strokeColor="#5AC8FA" android:strokeWidth="8" android:fillColor="#00000000" android:pathData="M104,40h112v74h-112z" />
+ <path android:fillColor="#5AC8FA" android:pathData="M160,104l26,36h-52z" />
+ <path android:strokeColor="#FFFFFF" android:strokeWidth="5" android:fillColor="#00000000" android:pathData="M236,60a40,40 0 0 1 0,40M250,48a58,58 0 0 1 0,64" />
+</vector>
diff --git a/addons/airplay-status/app/src/main/res/drawable/ic_foreground.xml b/addons/airplay-status/app/src/main/res/drawable/ic_foreground.xml
new file mode 100644
index 000000000..7ca386632
--- /dev/null
+++ b/addons/airplay-status/app/src/main/res/drawable/ic_foreground.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- A screen over a triangle inside the adaptive icon's safe zone. Own art. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="108dp" android:height="108dp"
+ android:viewportWidth="108" android:viewportHeight="108">
+ <path android:strokeColor="#5AC8FA" android:strokeWidth="4" android:fillColor="#00000000" android:pathData="M36,38h36v24h-36z" />
+ <path android:fillColor="#FFFFFF" android:pathData="M54,58l10,12h-20z" />
+</vector>
diff --git a/addons/airplay-status/app/src/main/res/drawable/row_background.xml b/addons/airplay-status/app/src/main/res/drawable/row_background.xml
new file mode 100644
index 000000000..03ccab9f5
--- /dev/null
+++ b/addons/airplay-status/app/src/main/res/drawable/row_background.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- A settings row: transparent until focused, then a glass highlight like the launcher's. -->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_focused="true">
+ <shape android:shape="rectangle">
+ <solid android:color="#33FFFFFF" />
+ <stroke android:width="1dp" android:color="#55FFFFFF" />
+ <corners android:radius="12dp" />
+ </shape>
+ </item>
+ <item>
+ <shape android:shape="rectangle">
+ <solid android:color="#00000000" />
+ <corners android:radius="12dp" />
+ </shape>
+ </item>
+</selector>
diff --git a/addons/airplay-status/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/addons/airplay-status/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 000000000..0a99b20b1
--- /dev/null
+++ b/addons/airplay-status/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@android:color/black" />
+ <foreground android:drawable="@drawable/ic_foreground" />
+</adaptive-icon>
diff --git a/addons/airplay-status/app/src/main/res/values/strings.xml b/addons/airplay-status/app/src/main/res/values/strings.xml
new file mode 100644
index 000000000..a594bd486
--- /dev/null
+++ b/addons/airplay-status/app/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">AirPlay Status</string>
+</resources>
diff --git a/addons/airplay-status/app/src/main/res/xml/module_card.xml b/addons/airplay-status/app/src/main/res/xml/module_card.xml
new file mode 100644
index 000000000..4639ce3e4
--- /dev/null
+++ b/addons/airplay-status/app/src/main/res/xml/module_card.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<card spec="1" label="AirPlay Status" caption="Mirroring" accent="#5AC8FA" />
diff --git a/addons/airplay-status/app/src/test/java/io/github/maxhayim/airplaystatus/ReceiversTest.java b/addons/airplay-status/app/src/test/java/io/github/maxhayim/airplaystatus/ReceiversTest.java
new file mode 100644
index 000000000..fdbbc50ad
--- /dev/null
+++ b/addons/airplay-status/app/src/test/java/io/github/maxhayim/airplaystatus/ReceiversTest.java
@@ -0,0 +1,63 @@
+package io.github.maxhayim.airplaystatus;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class ReceiversTest {
+ private static final Set<String> ME = new HashSet<>(Collections.singletonList("10.0.0.37"));
+
+ private static Receivers.Seen s(String type, String name, String host) {
+ return new Receivers.Seen(type, name, host);
+ }
+
+ @Test
+ public void raopNamesLoseTheirMac() {
+ assertEquals("HMAM TV 1", Receivers.display("_raop._tcp", "B841D9C616FB@HMAM TV 1"));
+ assertEquals("HMAM TV 1", Receivers.display("_airplay._tcp", "HMAM TV 1"));
+ }
+
+ @Test
+ public void mirroringWhenThisTvAnnouncesAirplay() {
+ Receivers.Mine m = Receivers.mine(Arrays.asList(
+ s("_raop._tcp", "AA@HMAM TV 1", "10.0.0.37"), s("_airplay._tcp", "HMAM TV 1", "10.0.0.37")), ME);
+ assertEquals(Receivers.State.MIRRORING, m.state);
+ assertEquals("HMAM TV 1", m.name);
+ }
+
+ @Test
+ public void audioOnlyWithoutTheAirplayService() {
+ Receivers.Mine m = Receivers.mine(Collections.singletonList(s("_raop._tcp", "AA@HMAM TV 1", "10.0.0.37")), ME);
+ assertEquals(Receivers.State.AUDIO_ONLY, m.state);
+ }
+
+ @Test
+ public void otherReceiversDontCountAsThisTv() {
+ List<Receivers.Seen> all = Arrays.asList(s("_airplay._tcp", "Living Room TV", "10.0.0.98"),
+ s("_raop._tcp", "BB@Living Room TV", "10.0.0.98"), s("_airplay._tcp", "Office Mac", "10.0.0.25"));
+ assertEquals(Receivers.State.NOT_FOUND, Receivers.mine(all, ME).state);
+ assertEquals(Arrays.asList("Living Room TV", "Office Mac"), Receivers.others(all, ME));
+ }
+
+ @Test
+ public void nameClash() {
+ assertTrue(Receivers.clashes("HMAM TV 1", "hmam tv 1"));
+ assertFalse("a non-breaking space is a different name", Receivers.clashes("HMAM TV 1", "HMAM TV 1"));
+ assertTrue(Receivers.advice(new Receivers.Mine(Receivers.State.AUDIO_ONLY, "TV"), true, "TV").contains("same as"));
+ }
+
+ @Test
+ public void adviceWhenMissing() {
+ Receivers.Mine none = new Receivers.Mine(Receivers.State.NOT_FOUND, null);
+ assertTrue(Receivers.advice(none, true, "TV").contains("Open AirPlay Server"));
+ assertTrue(Receivers.advice(none, false, "TV").contains("adds one"));
+ }
+}
diff --git a/addons/airplay-status/build.gradle b/addons/airplay-status/build.gradle
new file mode 100644
index 000000000..48978475f
--- /dev/null
+++ b/addons/airplay-status/build.gradle
@@ -0,0 +1,3 @@
+plugins {
+ id 'com.android.application' version '8.5.2' apply false
+}
diff --git a/addons/airplay-status/gradle.properties b/addons/airplay-status/gradle.properties
new file mode 100644
index 000000000..18825f968
--- /dev/null
+++ b/addons/airplay-status/gradle.properties
@@ -0,0 +1,3 @@
+org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
+android.useAndroidX=true
+android.nonTransitiveRClass=true
diff --git a/addons/airplay-status/gradle/wrapper/gradle-wrapper.jar b/addons/airplay-status/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..2c3521197
Binary files /dev/null and b/addons/airplay-status/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/addons/airplay-status/gradle/wrapper/gradle-wrapper.properties b/addons/airplay-status/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..77f5d0ba6
--- /dev/null
+++ b/addons/airplay-status/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,8 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
+distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/addons/airplay-status/gradlew b/addons/airplay-status/gradlew
new file mode 100755
index 000000000..f5feea6d6
--- /dev/null
+++ b/addons/airplay-status/gradlew
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/addons/airplay-status/gradlew.bat b/addons/airplay-status/gradlew.bat
new file mode 100644
index 000000000..9d21a2183
--- /dev/null
+++ b/addons/airplay-status/gradlew.bat
@@ -0,0 +1,94 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/addons/airplay-status/install.sh b/addons/airplay-status/install.sh
new file mode 100755
index 000000000..345339fba
--- /dev/null
+++ b/addons/airplay-status/install.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Build AirPlay Status and install it on the TV.
+# TV_HOST=<tv ip> addons/airplay-status/install.sh
+set -euo pipefail
+: "${TV_HOST:?set TV_HOST to the TV IP address}"
+cd "$(dirname "$0")"
+TOOLS="$(cd ../../tools && pwd)"
+PY=$TOOLS/venv/bin/python
+[ -x "$PY" ] || PY=$TOOLS/venv/Scripts/python.exe
+export MSYS_NO_PATHCONV=1
+PKG=io.github.maxhayim.airplaystatus
+# Script paths stay relative: with MSYS_NO_PATHCONV, Git Bash would hand Windows Python a /c/... path.
+tv() { "$PY" -I ../../tools/tv.py "$@"; }
+
+[ -f local.properties ] || { [ -n "${ANDROID_HOME:-}" ] && echo "sdk.dir=$ANDROID_HOME" > local.properties; } || true
+if [ -n "${JAVA_HOME:-}" ]; then export PATH="$JAVA_HOME/bin:$PATH"; fi
+./gradlew assembleRelease -q --console=plain
+
+"$PY" -I ../../tools/b64push.py app/build/outputs/apk/release/app-release.apk /data/local/tmp/airplay-status.apk
+OUT=$(tv 'pm install -r /data/local/tmp/airplay-status.apk; rm -f /data/local/tmp/airplay-status.apk')
+echo "$OUT"
+case "$OUT" in *Success*) ;; *) echo "ERROR: pm install failed" >&2; exit 1 ;; esac
+
+tv "am start -n $PKG/.MainActivity >/dev/null; echo opened"
+echo "Installed. AirPlay Status is open on the TV; press Home and answer Show card for the card."
diff --git a/addons/airplay-status/screenshot.jpg b/addons/airplay-status/screenshot.jpg
new file mode 100644
index 000000000..03fa4b9b0
Binary files /dev/null and b/addons/airplay-status/screenshot.jpg differ
diff --git a/addons/airplay-status/settings.gradle b/addons/airplay-status/settings.gradle
new file mode 100644
index 000000000..59df2f9bc
--- /dev/null
+++ b/addons/airplay-status/settings.gradle
@@ -0,0 +1,16 @@
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+rootProject.name = "airplay-status"
+include ':app'