How can I turn off an Android phone in the same Ethernet remotely using a Windows computer?


Question

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.


Answer

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?


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes