I have a rooted android device. I want to interact with wpa_supplicant through wpa_cli, but wpa_cli was not installed. I installed my own wpa_cli using termux, however, I was not able to connect with the running wpa_supplicant. What I am searching for is:
Is there a way to interact with wpa_supplicant on android if wpa_cli is missing?
If not, how to build my own wpa_cli knowing that I already installed the cli provided termux, but it did not work?
Do note that when I use the -p argument with the wpa_cli provided by termux, it produces an association error and not a connection error. -p is used to explicitly provide the location of the control sockets.
I also tried to use iw to perform the association task, however, the phone connects to the target wifi and then disconnects directly.
All that I am planning to do is to connect to wifi using its SSID programmatically on my android phone.
Thank you for your help!
Related
I am trying to reverse-forward port through ADB, but it just returns cryptic error of error: closed. Normal forwarding works. Session snippet:
$ adb forward tcp:59778 tcp:59778
$ adb forward --list
015d2109ce0c1a0f tcp:59778 tcp:59778
$ adb forward --remove-all
$ adb forward --list
$ adb reverse --list
error: closed
error: closed
$ adb reverse tcp:59778 tcp:59778
error: closed
error: closed
I am connecting via USB to non-rooted Nexus 7 2012 Android 4.4.4 from Windows 7 Pro x64 on Boot Camp.
adb reverse was introduced in Android 5.0
Since adb reverse is not supported in Android versions lower than 5.0, you need to use an alternative method, for example connecting via Wi-Fi instead. If you are using React Native, Facebook has added official documentation to connect to the development server via Wi-Fi. Quoting the instructions for MacOS, but they also have them for Linux and Windows:
Method 2: Connect via Wi-Fi
You can also connect to the development server over Wi-Fi. You'll first need to install the app on your device using a USB cable, but once that has been done you can debug wirelessly by following these instructions. You'll need your development machine's current IP address before proceeding.
You can find the IP address in System Preferences → Network.
Make sure your laptop and your phone are on the same Wi-Fi network.
Open your React Native app on your device.
You'll see a red screen with an error. This is OK. The following steps will fix that.
Open the in-app Developer menu.
Go to Dev Settings → Debug server host for device.
Type in your machine's IP address and the port of the local dev server (e.g. 10.0.1.1:8081).
Go back to the Developer menu and select Reload JS.
Follow these steps carefully.
Note: All commands need to run inside a project only.
Run this command first:
npm react-native start
Open another window in the same project and run:
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
This will create index.android.bundle in the assets folder
Run:
npm react-native run-android
Now you can get apk in the build folder which will work fine.
adb reverse requires Android 5.0+. For devices previous to that, you'll need to use a workaround like so.
If you have busybox installed on your Android device (most Genymotion images do), you can emulate adb reverse using this incantation:
adb shell busybox nc -ll -p {guest port} -e busybox nc {host IP} {host port}
In this case, "guest" is the Android OS running in the emulator and "host" is the computer running the emulator.
cause of adb reverse isnt working on android prior 5 you could propably use adb forward with a service listening on android and tunneling other connections through this inbound connection. I am doing this mostly with ssh, but you would need an ssh server on android. you than can connect using ssh -R incommingreverseportonandroid:hostyouwanttoforwardto:portyouwanttoforwardto sshuseronandroid#localhost -p portyouhaveusedforadbforwaqrdtoaccessandroidssshserver
but i dont know how to enable an ssh server on android and maybe there is a better way cause ssh uses encryption which isnt needed over usb and using up cpu.
i am using this way with my server to share a service when i am forced behind a nat...
hope someone will find a way to bring this teoretical way into practical possibility
Just use 10.0.2.2 instead of localhost/127.0.0.1 for your hostname. It will directly try to connect to the port on the host machine (same affect as reverse).
Usually we use windows/linux machines to pull logcat info from an android device.
Is it possible to use android tablet/phone to act as host and get the logs from another android phone connected to it?
This is possible. The host Android device needs to be defined as a USB host. Then, once a connection is established, all of the same commands can be run, assuming that ADB is installed on the host device.
See here for more discussion on USB Host Mode support and compatible cables: https://android.stackexchange.com/questions/36887/how-can-i-determine-if-my-device-has-usb-host-mode-otg-support
It is useful to have a terminal program, such as Terminal IDE to issue commands from, and using busybox to provide additional commands would also be beneficial.
ADB comes as part of the AOSP source, so it a device is based off AOSP, then it will possibly include ADB. ADB source is located in /system/core/adb in the AOSP source tree.
Here is an example of a session where a Nitrogen6X (host) running a custom AOSP is used to connect to a Galaxy S3 cellphone (client). Note the use of Busybox and ADB, both of which are installed on the host. Busybox also happens to be installed on the client, but this is not necessary:
Thus in order to pull logs, just use regular ADB commands (e.g. to copy files), or run logcat, as indicated below:
I want to use adb to install apps to my Android-based TV from an Android phone rather than a computer.
So I decide to read adb source code, port the adb code and compile it to a library file (libadb.so) and then invoke it by JNI from within an Android app.
When I test this apk on my telephone, the adb server fails with can not bind 'tcp:5037' port.
I thought the failure to open that port might be a conflict with the existing implementation of ADB which might be using it, so I removed that. It didn't work. I tried to change to other ports, such as 4097,or 6066. It still didn't work. I have no further ideas how to solve this problem.
Android enforces its Internet Permission via a modification to the Linux Kernel which checks that a process is a member of an associated unix group before allowing it to open sockets in the AF_INET domain.
Such membership is inherited, so native code executed, either as a JNI library or by invoking a distinct executable, will only be able to perform network operations if it is either run as a privileged user automatically having this membership (such as adb's "shell" account, or as root on an engineering build) or run under the identify of an application package having the Internet permission in its manifest.
There may be a number of additional challenges with your goal (and it is unclear why the stock adb client on the device is not workable for you), but the immediate solution to your present problem is to run your customized adb tool from an application with Internet permission.
This question already has answers here:
How can I deploy and execute an application on a device connected to a remote system?
(4 answers)
Closed 4 years ago.
I need to access the android phone connected to remote windows/linux machine to run automation script. is there any way we can execute adb commands?
Please suggest me..
Here is the answer,
to access android devices remotely, phone has to be rooted to get full control.
We need to execute the command –>
adb tcpip port_number
from the machine which connects the device via USB cable, (port may be any odd port between 5554 to 6000, which should not conflict with other ports assigned) in order to assign a specific port to connected device.
Then from any computer , we can connect like
adb connect ip_addres_of_phone:port number
in your shell script
adb shell "command"
maybe adb command will be not available, to have that command available you have to download the android SDK and then add in your path environment variable
;/android-sdk-path/tools;/android-sdk-path/platform-tools
WARNING dont replace your path environment variable with that but add it to the end of the current string.
You need to download a vnc client on your pc (such as UltraVNC or TightVNC) and a vnc server on your android device.
As vnc server, try alpha vnc lite from the Play Store. It doesn’t require root and works on almost all Android devices out of the box.
I need to write a script for Android, to be downloaded using ADB, and which performs the following actions on the phone:
Turn off the protocol stack (equivalent to the AT command AT+CFUN=0\n)
Turn on the protocol stack (equivalent to the AT command AT+CFUN=1\n)
Establish PDP context
With devices that identify as COM-ports this is easy - just open the COM port and send the appropriate AT command. But how do I do this with an Android device?
Script manager on android market should provide some direction, as well as a catalyst for using, writing, and scheduling such scripts.