Qt execute external executable program? - android

I am writing a Qt program to connect with Android devices.
I know that I should execute the adb first, and the connection is based on TCP, so I need to run
./adb forward tcp:xxport tcp:xxport
How to run this line in Qt ? I have copy the adb to my project file.
I develop this on Linux, and would run on Windows XP , so prefer cross-platform plan (only works on Windows XP is fine also).

QProcess p;
p.start(adbBinaryPath(), {"forward", "tcp:xxport", "tcp:xxport"});
To run adb you can use QProcess. Note that you need compiled adb binary for each windows and linux platforms.

Related

Lldb debugging using lldb-server on android?

I currently dont have a pc. I have two rooted devices Arm64 host device with Debian rootfs and the device to be debugged which contains the lldb-server binary armv7. I am trying to remote debug my android device using lldb. I pulled the lldb-server binary from àndroid ndk24 and put it in /data/local/tmp. Installed Debian Sid on Another term and apt installed lldb.
I then wifi hotspoted the client device(one with lldb-server) using the host with the linux rootfs.
The commands i ran on server device
./data/local/tmp/lldb-server platform --listen "*:2000"  --server
Checked using netstat and the lldb-server had bound to all addresses(0.0.0.0:2000)
On host(client lldb) device in debian sid terminal i ran:
apt install lldb
lldb
platform select remote-android
platform connect connect://192.168.201.132:2000
Then i get error failed connect port.
However, using Gdb and gdbserver everything worked perfectly. I have tried installing lldb on debian buster but same result and even ran the lldb-server binary on the host(device with debian sid) but same result. Right now im stuck here. How do I solve this?
Help will be greatly appreciated. Thank you.
I dont know why, but lldb-server platform command is broken(mabe in my case) and should have used lldb-server gdbserver like this:
On lldb-server gdbserver command, the stub doesnt allow connections from other ips except the one it is bound to so do this:
iptables -I INPUT -t nat -p tcp -d 192.168.43.1 --dport 2000 -j SNAT --to-source 192.168.43.1:50000
./data/local/tmp/lldb-server g 192.168.43.1:2000
On lldb client do
gdb-remote 192.168.43.1:2000
Then do normal remote debugging.

How to run a C program in adb shell?

So adb shell gives one a linux terminal into an android phone, when it is connected to a computer. One can run all the standard linux commands like ls and cat inside the android phone, and explore the android filesystem using the adb shell.
Now I wonder, is it possible to use a C/C++ compiler such as clang or gcc to compile and execute a C/C++ program in the android phone, as on linux? I am not talking about android app development here, I mean a linux command line C/C++ program for android. Also, can I use the C standard library and linux system calls such as fork(), exec(), kill(), and working with file descriptors, in the android adb shell, just as I would do it on linux?
Yes. You can . For that you need copy your compiler exe's to android file system. From there you can easily call. Same time make sure that all pre-builed libs in android PATH folder.

Testing changes made to AOSP code (package android.media) on an emulator

I downloaded AOSP on Ubuntu, made changes and built it for x86_64 (lunch aosp_x86_64-eng).
The changes are in package android.media.
Can I test the changes on the emulator on Ubuntu? Do I need to build the emulator?
(I am not using Android Studio. I build AOSP and start the emulator on the command line.)
Option 1: the framework and push the jar
make framework
adb root
adb remount
adb sync
adb reboot
Option 2:
Full make and flash via fastboot

Connect obdsim to Torque(android app) Ubuntu

Am trying to connect odbsim through bluetooth with my Samsung S4. After successfully pairing my devices with ubuntu, my results connecting obdsim with phone is never happened.
Whenever I tried running the command obdsim -b it always throwing error:
SimPort name: Not yet connected
I tried connecting it with windows too, with the help of com0com serial port, but couldn't succeded. And in windows, obdsim -b results in invalid options.
Please help me to connect the simulator with android device.
Thanks,
Boopathy.
I had the same problem on Linux and I resolved it installing some libraries and recompiling OBDSim.
I will put here the whole process to make a guide for new users like me.
Download OBDSim:
wget http://icculus.org/obdgpslogger/downloads/obdgpslogger-0.16.tar.gz
Or get the most recent version from: http://icculus.org/obdgpslogger/
Install OBDSim:
tar -zxvf obdgpslogger-0.16.tar.gz
cd obdgpslogger-0.16
mkdir build
cd build
I have to install only these libraries, but in your case keep attention to warning messages of cmake and install all that it ask you to install:
sudo apt-get install libbluetooth-dev libfltk1.1-dev libfltk1.1 fltk1.1-doc fluid fftw3-dev libgps-dev libftdi-dev
cmake ..
make obdsim
cd ../bin/
Run OBDSim:
./obdsim -b -g gui_fltk
Now you have OBDSim running, but you need a channel to communicate it with your app. You need a serial port working as a bluetooth interface.
Creating the serial->bluetooth interface:
sudo rfcomm bind 0 00:00:00:00:00:00 1 # Change this MAC address, putting the MAC of your device
sudo sdptool add SP
You can discover the MAC address of your device by using hcitool:
hcitool scan
It only works when the bluetooth configuration "Visible to all nearby Bluetooth devices" is on in your device.
I have used almost the same method described here and here and it worked. It worked without using com0com.
Pair the android device with the computer.
In Torque app, go to Settings -> OBD2 Adaptor Settings -> Choose Bluetooth Device. Select
your Computer Name.
Set the incoming COM Port of bluetooth as COM#Number . Assume it
is COM10 (Use https://www.verizon.com/support/knowledge-base-20605/)
Use obdsimwindows-2011-06-11 build. Can be downloaded from
http://icculus.org/obdgpslogger/downloads/obdsimwindows-latest.zip
Run obdsim.exe -w COM10
Run the Torque app and see whether it connects automatically.
-g option is used to give a generator type. By default it is gui_fltk which is the GUI interface.

gdbserver - command not found

I would like to perform debug operations on the Android open source platform.
I am trying to run "gdbserver :5039 --attach" in my terminal but I keep receiving "command not found".
I have built the Android OS using the "full_crespo-userdebug" configuration, which according to the android docs, should provide me with root access on my Nexus S phone?
How can I set things up so that I can debug?
You can copy it from "$NDK_HOME/prebuild/$PLATFORM/gdbserver/gdbserver"
then use adb to push it to device and make it executable
To debug an android device you first need to run gdbserver on the device.
gdbserver :5039 --attach pid
then in your gingerbread source folder you need to run
source build/envsetup.sh
this will allow you to now run
gdbclient
which should connect to the gdbserver on device

Categories

Resources