Tailscale does not autostart after AndroidTV system restart
What are you trying to do?
Autstart Tailscale after Android TV reboots
How should we solve this?
Option to autostart tailscale
What is the impact of not solving this?
no workaround atm
Anything else?
would be really helpful to get this feature
It would be great to have an autostart option on android devices that don't have access to Always-on VPN. For example, firestick.
I did some quick hacking and it should be possible. The following adds a listener on BOOT_COMPLETED and starts the VPN. It's working for me, but in a real version it should be configurable.
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 327951b..6aa3ead 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
<!-- Disable input emulation on ChromeOS -->
@@ -56,10 +57,14 @@
</activity>
<receiver android:name="IPNReceiver"
android:exported="true"
+ android:enabled="true"
+ android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
>
<intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="com.tailscale.ipn.CONNECT_VPN" />
<action android:name="com.tailscale.ipn.DISCONNECT_VPN" />
+ <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service android:name=".IPNService"
diff --git a/android/src/main/java/com/tailscale/ipn/IPNReceiver.java b/android/src/main/java/com/tailscale/ipn/IPNReceiver.java
index a0f7f32..5571d7e 100644
--- a/android/src/main/java/com/tailscale/ipn/IPNReceiver.java
+++ b/android/src/main/java/com/tailscale/ipn/IPNReceiver.java
@@ -21,6 +21,12 @@ public class IPNReceiver extends BroadcastReceiver {
workManager.enqueue(new OneTimeWorkRequest.Builder(StartVPNWorker.class).build());
} else if (intent.getAction() == "com.tailscale.ipn.DISCONNECT_VPN") {
workManager.enqueue(new OneTimeWorkRequest.Builder(StopVPNWorker.class).build());
+ } else if (intent.getAction() == Intent.ACTION_BOOT_COMPLETED) {
+ Intent i = new Intent(context, IPNActivity.class);
+ i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(i);
+
+ workManager.enqueue(new OneTimeWorkRequest.Builder(StartVPNWorker.class).build());
}
}
}
The existing actions for connect/disconnect weren't working either until the activity was started (broadcast from adb shell). This makes me wonder how it works in tasker?
@kjvalencik I am wondering this myself. I have googleTV's in all my airbnb's.. Sometimes I need to remote in and update app logins or troubleshoot things when people staying have issues with it. I use vysor adb to do this with the help of Tailscale but I have no way to get the Tailscale app to autostart or auto-connect when it's opened.
I would really appreciate this also. I use Nvidia shield's and the auto start feature would be great. The iOS app has recently had an on demand setting added, which works really well. The android TV app could use a bit of love next ;)
@kjvalencik can you link to your apk? :)
Any news on this? Any simple workaround?
@kjvalencik: I noticed your workaround for Firestick, thanks! However, on the Firestick I noticed that it first shows some recommended ads immediately after boot/restart. Only after dismissing the initial ad the app autostarts. Is there a workaround for this? Is the initial ad also caused by an app, and can the app somehow have a higher priority on startup and start before the ad?
I haven't noticed that issue. I have auto play and personalized ads disabled.
Which device do you have? I have a 4k max.
@kjvalencik:
I have auto play and personalized ads disabled.
I disabled both options in recommended content section.
Which device do you have? I have a 4k max.
The device in my case is a FireTV Stick Lite.
The same applies for the Nokia Streaming Box 8000.
Any time line for this? It's really annoying that it doesn't auto-start after a reboot, in my case an nVidia Shield TV Pro.
FYI: Using the latest tailscale available on Firestick (1.66) works perfectly. I just removed and plugged in several times and always keep the latest state and exit node too. So, in my case: The enabled + Exit node works after a cold/hard reboot.
Also, using same apk version 1.66 I sideloaded on an Android TV (Sony Bravia 2020) and it works as on the firestick
FYI: Using the latest tailscale available on Firestick (1.66) works perfectly. I just removed and plugged in several times and always keep the latest state and exit node too. So, in my case: The enabled + Exit node works after a cold/hard reboot.
Also, using same apk version 1.66 I sideloaded on an Android TV (Sony Bravia 2020) and it works as on the firestick
This kind of works for a google tv (onn 4k streaming box) with no option in android settings for always-on VPN. Unfortunately it won't auto connect on boot, you still have to open the app, but you don't have to scroll up the the slider to connect once in the app. Would really love an auto connect option. I saw a comment from the tailscale devs a few weeks ago that the tailscale app should be in the play store for TVos devices soon (can't find that post ATM, sorry), so hopefully they address this issue with that release.
The FireTV now has an official version in the Amazon Appstore. It works perfectly, a small cosmetic bug is that there are big black borders on the left and right. The only annoying thing that is still not fixed is the autostart feature, at the moment you have to open the app by hand for it to connect automatically. Apps like Adguard connect automatically after rebooting FireTV, but I have no idea how they do it.
This can be remedied by using adb. More info here https://github.com/tailscale/tailscale/issues/510#issuecomment-2220310581
From the last issue, here again summarized and explained for everyone after successful testing.
tl;dr:
To enable the Always-On VPN feature for Tailscale:
adb shell settings put secure always_on_vpn_app com.tailscale.ipn
Explanation:
With an ADB command it is possible to enable the Always-On VPN feature of Android for Tailscale. This feature should be available since Android 7 or FireOS 6.
The following steps are required to enable it:
-
install ADB (Android Debug Bridge).
-
change to the ADB directory using the Windows CMD or the Windows or Linux Terminal using the CD command.
-
find out the (local) IP address of your Android TV or FireTV. Enable ADB debugging in the TV device settings.
-
run the following command and replace "IP" with the (local) IP of your device (for Windows, add ".exe" after "adb") and then allow the connection on the TV:
adb connect IP
- run the following command
adb shell settings put secure always_on_vpn_app com.tailscale.ipn
The issue mentions two other commands, but as far as I know they are not necessary because they are already disabled by default, but for the sake of completeness I list them here. The first disables the VPN lockdown feature, i.e. no data can be transferred without an active VPN connection. If this were active (set to 1) and no exit node was set up in Tailscale, Internet access would no longer work, which is logical since Tailscale does not normally route normal Internet connections outside its own tailnet. The second command removes all applications that are exempt from the VPN lockdown feature from the whitelist.
adb shell settings put secure always_on_vpn_lockdown 0
adb shell settings put secure always_on_vpn_lockdown_whitelist ''
Have a nice day everyone! ❤️