Turn an Android into a server (Step by step) - drafting -

IOVEIT·2023년 10월 4일
0

ㅤYour smartphone is fully equipped more than you think compared to the price. It has a lot of features you will never have in your life. Even if you're an early adopter or a tech-savvy, you will never find a way to use them ALL. We know that an Android OS is developed based on Linux Architecture, that means a lot.

ㅤIf it's possible to make it a server, it will provide a message, a call, a microphone record, and a camera by the Termux-api. You will go through a rough patch to turn it into a server. WIFI is not secure. Your mobile carrier naver gives you an static IP. There is not an application that makes it possible directly. Fotunately, all you have to buy is a USB-C LAN adapter now.

I'm not sure if termux supports libraries like FastAPI and Uvicorn so fat. Let's try step by step. I'm writing to avoid being searched in Korean. The carrier might not like turing your phone into a server.

1. Get an Android phone

2. Get a USB-C LAN adapter

3. Connect the phone to LAN

4. Find out ip address in the phone

5. Install Termux on the phone

For running it background,

(1) Install Termux:Boot in F-DROID
(2) Create the boot file (refer to below shell)
(3) Allow authorization on your phone (in case of redmi, not galaxy)

~/.termux/boot $
~/.termux/boot $ pwd
/data/data/com.termux/files/home/.termux/boot

~/.termux/boot $
~/.termux/boot $ ls -al
total 11
drwx------ 2 u0_1111 u0_1111 3488 Oct 14 08:15 .
drwx------ 3 u0_1111 u0_1111 3488 Oct 14 08:05 ..
-rwx------ 1 u0_1111 u0_1111   84 Oct 14 08:15 boot

~/.termux/boot $
~/.termux/boot $ cat boot
#!/data/data/com.termux/files/usr/bin/sh
termux-wake-lock
termux-setup-storage
sshd

안드로이드 13 Phantom Process Killer 임시 해제
https://data-science.tistory.com/117

6. Install python and libraries on Termux

~/.termux $
~/.termux $
~/.termux $ pkg install python
~/.termux $ pkg install termux-api
~/.termux $ pkg install vim

~/.termux $
~/.termux $
~/.termux $ termux-sms-send -n 01012341234 hi! this is the first message
{
  "error": "Please grant the following permission to use this command: android.permission.SEND_SMS"
}

~/.termux $
~/.termux $
~/.termux $ termux-sms-send -n 01012341234 hi! this is the first message
<If successful, there will be no response from Termux>

~/.termux $ python
Python 3.11.6 (main, Oct  4 2023, 09:27:52) [Clang 14.0.7 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>> import os
>>> os.system("termux-sms-send -n 01012341234 this is message from python")
0
>>> exit(1)

<API implementations>
<termux-battery-status : Get the status of the device battery>
<termux-sms-list : List SMS messages>
<termux-sms-send : Send a SMS message to the specified recipient number(s)>
<termux-telephony-call : Call a telephony number>
 * important issue, you're not allowed to end the call 

For more information
https://wiki.termux.com/wiki/Termux:API#Current_API_implementations

- References -

(1) 갤럭시 스마트폰 유선랜 연결 방법(이더넷 연결) https://blog.naver.com/boyinblue/221335236545

(2) Termux:API https://wiki.termux.com/wiki/Termux:API

(3) pkg or apt : use a pkg utility instead of apt directly.
https://wiki.termux.com/wiki/Package_Management#:~:text=We%20strongly%20recommend%20to%20use,%22%20or%20%22apt%20install%22.

(0) How To Build A Django Web App Using Termux And Push To GitHub
https://towardsdev.com/how-to-build-a-django-web-app-using-termux-and-push-to-github-5a5c56e23770

(0) Build a simple web app with Python, Flask, and Termux.
https://medium.com/the-andela-way/build-a-simple-text-to-speech-web-app-with-python-flask-and-termux-a51701f1fea0

Linux Deploy설치 후 오류가 많아 Termux로 수정
http://john-home.iptime.org:8085/xe/index.php?mid=board_ZoED57&document_srl=12327

profile
EnCoCookLand

0개의 댓글