Using Headless (screen-less) Android Phone as Wireless Router
This article is machine translated which hasn’t been proofreaded by the author. The info it contains may be inaccurate. The author will do his best to get back (when he has time) and revise these articles. 🥰
For Chinese version of this article, see here.
After I changed my mobile phone, I wanted to configure a special data card with a large data rate. Conscience Unicom 15G/50 yuan, but the new network card only has a micro card, and the card slot of the new mobile phone is already full. A 4G card tray costs more than 100 yuan. To plug in my mobile router with a garbage battery… How can I say that my broken mobile phone still has a card slot for full Netcom! (And I feel bad about the money.) It is not difficult to think about it with this broken mobile phone, it is nothing more than turning on the hotspot.
I started to start with the firmware, but there are few open-source firmwares for the special version of the junk country bank, and I need to be familiar with the Android boot mechanism. Turn to software implementation. It is not difficult to find out. I have downloaded several popular Android automation software from the store, and briefly talk about my experience.
Before that, restore your phone to its best condition. Get rid of it!
The best way to factory reset is through Recovery. Use fastboot or Samsung’s Odin cable to flash the complete firmware, and then flash a twrp recovery. All mobile phones can be done after the screen is broken. twrp has an adb command line that doesn’t require authorization, and a command with the same name
After turning on the volume up key to enter twrp, on the computer side
adb shell Enter the command line and perform the following steps. The command referenced这里. I have to say that on this kind of question, stackoverflow’s answer is no different from Baidu Zhizhi. They are all written by a group of people who read other people’s tutorials. The first thing I saw was这个, exactly the same problem as I encountered. But what the hell is this high-voted answer? “Back up and change your phone.” Kick your balls.
# 恢复出厂设置 twrp wipe data twrp wipe cache reboot # 重启后等系统自动生成data分区结构，强制关机，再进入recovery # 开启 adb setprop persist.service.adb.enable 1 setprop persist.service.debuggable 1 setprop persist.sys.usb.config mtp,adb
Then authorize adb in the main system on the host. (*nix applicable)
adb push ~/.android/adbkey.pub /data/misc/adb/adb_keys
Then enter the system normally, use AndroidScreencast Project the screen via ADB, with
adb install Just install the software.
The functions to be implemented are:
- Turn on the hotspot automatically
- Force restart after network change
- Voice broadcast network status
- SMS control mobile phone switch hotspot, switch machine
Automate was the first software I used and used it for a while (until I discovered the second one), and it was the second most powerful software, but the paid version was firmly number one. It reminds me of a small graphical programming software that I played with Lego when I was a child. You can perform operations according to the diagram by drawing a flowchart, and the completion is very complete, and all can be solved by the drop-down menu. Automate is the only one of these that is really writing_ program _ In the app, a flow in it is a program, and a fiber is a thread, which can fork, subroutine, loop, and if-else. It is simply an interpreter.
The only downside is that the free version can only contain up to thirty blocks in all running fibers at the same time. It counts as one at the beginning of the program, and doubles as a fork thread. [Manual goodbye]
Two flows are used, one is an infinite loop to detect the AP status and turn it on, and the other is to listen to SMS and trigger control operations. I always feel that the endless loop is very battery-consuming… counting down for thirty seconds, getting the status, and being kind and tired all the time. Finally, a special function that only this software has is added, which is to light up the notification LED light. If there is a net, it will be green, if there is no net, it will be red.
Notice that the function is very powerful. The TTS module here can choose which channel to output to, and output to the ringtone channel to control the volume before broadcasting the voice, which is very convenient.
Both erobot and the following software are triggered based on events. There are pros and cons. The disadvantage of the event-based trigger method is that the program flow is relatively fixed, and the cycle of [trigger-trigger condition-response event] is relatively fixed. But there are many advantages. most importantly** power saving ** ! The state changes of the Android system are broadcast one by one, as long as the program is opened to receive, there is no need to actively detect the system state, this mechanism can significantly reduce power consumption.
Another advantage is obvious. The procedure implemented in this way is** fully asynchronous ** of! There is no strict main thread, only the service of this software listens to all system events and acts as a dispatcher; all actions are also executed in parallel unless explicitly specified, not to mention performance considerations, at least The definition is very, very simple and elegant. I still feel pretty messed up after finishing that flow chart…
Three commands are defined in this solution. One monitors network changes and runs automatically after booting, forcing the AP to be turned on; one accepts text messages and performs regular matching operations and executes accordingly; the last one broadcasts the network status by voice.
It’s quite troublesome to click and go from this menu, and then you can’t copy and paste… It’s so frustrating. The judgment statement for detecting the network status made people want to die, and I felt like I was about to overflow the stack😂Come and see what this menu is like.
Not the picture above, the function is the same as above. The biggest difference is that the ones look better, and the ones that are rubbish will die.
- The free version can only define 5 commands
- Each has only one trigger, one action and should be a few execution conditions (that’s still useful)
- There are much fewer function blocks than the first two, no hotspot control, no network switch, no TTS, no functions that require root, no regular matching, no custom variables, and the function of continuously sending a notification written by yourself None, what’s the point of asking people to install this software with just such a tasteless function?
- And is** The most expensive of these software! **
It’s almost the same… The only outstanding function is to trigger the profile according to time and place, but CM13 comes with it, sorry. E-Robot can also customize the positioning interval and Wi-Fi scanning time during the day and night.
What’s more, you still need money. 🙄
I just thought about this, and I didn’t pretend to be.
The Android version of IFTTT has too few functions. Its main business is to connect various Internet applications. At most, it sends notifications to the mobile phone, and it cannot fully control the functions of the mobile phone. After all, it wasn’t supposed to do it. The most important reason is still one, if the hotspots can’t be turned on, it’s too busy.
In fact, when I wrote these two small scripts, I thought of the days when py and node wrote the web. Tsk tsk, asynchrony is really elegant. With multi-threading, the program is not chaotic, and the thinking goes along the callback, which is much more refreshing than thinking about the brain-burning process of sending signals between threads.