As in title: How can I turn off an Android phone in the same Ethernet remotely using a Windows computer?
They are in the same Local Area Network and connected to the same router, the Android phone is connected to the router via WiFi and the Windows computer is connected to the router via a cable.
I have tried numerous times to get a solution using Google search with different keywords, and objectively Google isn't very competent in understanding complex sentences and I can't get what I am looking for, see for yourself what the results Google gave: Google: How can I turn off an Android phone in the same Ethernet remotely using a Windows computer?, most of the results are exactly the opposite of what I intended to achieve.
I want to connect to the phone wirelessly and send commands through WiFi.
I figure I need to use either Telnet or SSH to do this, log into the Android device remotely and use Android terminal commands to shutdown the phone.
Unfortunately I have tried telnet and here is the result:
C:\Windows\System32>telnet 192.168.1.3 Connecting To 192.168.1.3...Could not open connection to the host, on port 23: Connect failed
I know what this means, this is because telnet port is not open and the telnet server isn't online on the Android phone by default.
So naturally I need to install some application on the Android phone that runs the telnet/SSH server and opens the telnet/SSH port, and setup a login and password, so I can connect to the phone remotely and it has to somehow execute the commands.
The phone isn't rooted, but I have Android Studio and the phone does have USB Debugging, what tweaks do I need to make in order to enable remote logging?
And I don't know how to use Android terminal, is there even a command line interface shell on Android? I don't have any experience with this, however from what I have learned Android is based on Linux and I have some experience in Ubuntu 20.04 LTS WSL, I know I can use these commands:
sudo power off shutdown -h now
Android must use something similar.
How can I achieve this?
The suggested duplicate: How can I shutdown my Android phone using an adb command? doesn't answer my question because it shuts down the phone through USB while I have explicitly stated in my question that I want to shutdown the phone wirelessly through WiFi connection.
Xeнεi Ξэnвϵς 2021-02-08 12:24:59Z
这回答了你的问题了吗？ Robert 2021-02-08 12:22:10Z, License: CC BY-SA 4.0
链接重复中的解决方案仅使用adb在shell中执行命令。如果您能找到某种方法，而不使用USB（adbirifers / ssh），而不是它们的工作方式比较相同。 Firelord 2021-02-08 13:08:09Z, License: CC BY-SA 4.0
Does this answer your question? Robert 2021-02-08 12:22:10Z, License: CC BY-SA 4.0
The solutions in the linked duplicate merely uses adb to execute commands in a shell. If you can find a way to do that without using usb (adb wireless /ssh) than they would work pretty much the same way Firelord 2021-02-08 13:08:09Z, License: CC BY-SA 4.0
警告：adb over ip真的等同于Telnet，这意味着它的数据在网络级别的纯文本中完全不受保护。因此，您应该仅在安全网络中使用亚行。
Shutdown as a command requires root
The simple answer is you can't perform a shell command from within an app for shutdown an Android system unless your device is rooted.
For performing the shutdown command on Android special permissions are required. When triggering a shutdown via UI the command is internally forwarded to a component that has the permissions to shutdown the system.
But regular apps (and therefore this applies also to all processes like telnet or ssh started in the context of an app) don't have this permission and thus can't shutdown the system.
Workaround: shutdown via adb over IP
Executing the command shutdown -p via adb should power off your phone.The problem is that adb by by default only available via USB connection (if you have enabled developer options and adb). The only workaround would be to connect your phone after booting to a PC and enable adb access via IP. This would be then allow a sort of telnet (via "adb connect IP" instead of telnet).
Warning: ADB over IP is really equivalent to telnet which means that it's data is transmitted totally unprotected in plain text on network level. Therefore you should use adb over IP only in safe networks.
See also this question: How can I shutdown my Android phone using an adb command?