How to synchnorize files with mobile phone running LineageOS? - android

I have a mobile phone running LineageOS 16.0. I would like to organize the automatic synchronization of particular directory on mobile phone with some remote directory (e.g. exposed via FTP/SMB/SSH) on the server. Ideally would be to have an option either to make one-way (synchronize only missing files) or two-way (source and target are identical after synchronization) modes.
In particular above can be achieved by using the rsync utility. I see the following options:
Mobile phone is exposing the folder via e.g. SSH
This would require LineageOS running SSH server. In this case rsync could be run on the server (periodically or on some event).
Is SSHD server already installed on LineageOS (Native SSH server on LinageOS)? If not, is it possible to install it from a package?
Will running in the background sshd daemon drain the mobile battery?
How difficult would be to add it to startup (SSHD on LineageOS, Execute Script on Start Up)?
Mobile phone is running rsync
This requires rsync installation to LineageOS. Maybe there is ready-to-use package or will it require the compilation?
I would need an icon (or some other easy way) to execute rsync on mobile. How to organize that?
If you see other more handy/easy options, please describe how to setup/organize them.
P.S. Dropbox or any other cloud solutions is not an option (out of scope for this question).
Thanks in advance!

I use the FolderSync app for this (it supports connecting to an SSH server at scheduled intervals, although I personally use it with Nextcloud). Syncthing is also a good solution I've used in the past, although you'll need to install that on your server also (no cloud required).
Trying to run an rsync server on a phone doesn't sound appealing, but there are a couple of rsync client apps in the play store.

Related

I'm using xampp for local server and I want to test my locally hosted site to android mobile. How would I do that

I'm using xampp for local server in a 64-bit system. I want to test my locally hosted site to android mobile device to check the responsiveness without hosting it to any web server. How would I do that. Please answer soon
Make sure the Apache module in XAMPP is started up and your android phone is connected to your router(assuming that you are on a wireless network). Find the local IP address of the computer hosting the server. Mine, for example, is 192.168.1.142. This may or may not be similar to yours. Type that IP address into the phone's URL bar. You may need to append the port number to that too, depending on the server settings. For example, if XAMPP is running Apache on port 8080: 192.168.1.142:8080.
To obtain your local IP, it slightly varies depending on the Operating system.
For windows, go to command prompt and do the command ipconfig, it should appear as an entry there.
For linux-based systems, I believe you use the command ifconfig in terminal.
If you do not have a wireless access point, it may not be possible to visit it as the phone naturally does not have an ethernet port.
I think that's not possible. However you could find a free web host to try that out. Here is one:
http://www.host-ed.net
If you really don't want to use a web host, then try downloading the files to your phone/tablet and running them directly from phone/tablet. That will work if you have just plain html/php files. Otherwise browse google play to find a app that can run those files.
This was not available in 2014, but now you can get just a simple browser extension for testing your responsive design.
For Chrome you have e.g. 'Mobile simulator - responsive testing tool'
Simple free tool

Android debugging via Bluetooth

I was using earlier adb to debug Android applications over wifi, usb - it was great.
Right now I am wondering if it is possible to connect phone with adb via bluetooth.
I did a quick research but didn't find anything - have you tried it already ?
It is not supported by the current adb software, however you could probably make it possible if you have a rooted device (or possibly even if not - see below) either by modifying adb or by using bluetooth to tunnel a channel it does support, such as tcp.
You would need to obtain the source for the adb program - the same source is used to build both the PC and the device versions. First step is to just build it with unmodified functionality, which may take a fair amount of build system modification unless you do so as a part of a complete android source build (the way it was intended to be done)
Then you would modify it to add a bluetooth channel as an option and install it on the device (why you need root) and in your path on the PC. You'd think you could run it from an alternate location on the PC, and you likely can as long as you use it from the command line, but if your fire up DDMS it may kill off the running adb server and launch a new one using the default in the path, so ultimately you'll have to put your modified version there.
IF you can already get your device to accept adb connections over tcp (possible with root, perhaps possible in some cases without) there is another option, which is to not modify ADB (or at least not modify the device side) and instead come up with something running on the device which accepts bluetooth connections and forwards the traffic via local loopback to the tcp port on which the stock adb is operating. This would save the trouble of having to rebuild adb.
If you have some kind of tethering or similar network-over-bluetooth solution, you might even be able to leverage that to carry adb-over-tcp-over-bluetooth without writing any code.
Finally note that it is not 100% essential that the adb daemon run as a more privileged userid or be installed in place of the official one - you can run an adb daemon as an ordinary application and do many of the expected things with it. However, whichever adb daemon is running first will grab the unix domain java debug socket, and so only that adb daemon will be able to provide the full java debug services. More primitive things like logcat, shell, running process list, push/pull, etc will at least partially work without this, provided that your adb daemon doesn't quit (modification may be required) when it is unable to claim the debug socket. If you can kill the official adb daemon and exploit a race condition, you may be able to get an unofficial one started before it restarts - you would probably need to have a script or program to do this and run it with setsid from the official adb shell, meaning you'd need to connect via USB first. At that point, you'd also be able to start your unofficial adb daemon running as the same userid as the official one.
You may want to spend some time estimating or testing if the performance (speed) will be satisfactory before investing in a lot of time setting this up for real.
I know this is a bit old but I seem to have found a post that does this. All credit goes to the author of fomori.org for finding this and making the information available. Today it helped me, maybe tomorrow I'll help you by making it easier to find.
Source

Streaming Audio Via SSH to an Android Device

I'm able to securely stream audio from one PC to another via SSH using:
ssh <username>#<host> 'dd bs=1k if=/dev/audio' > /dev/audio
Is there any similar way to do this from a terminal running on an Android phone? I tried testing this from a terminal emulator running on a Droid X, but the standard "/dev/audio" device is missing.
Note, I realize this could probably be accomplished by writing a custom app, but I'd like to avoid that overhead.
Another way would be to install a streaming server (i.e. icecast) on the Linux box and connect to it from your Android using any Internet Radio Client.
IIRC, icecast support authentication and SSL.
No, there is no way to do this. By default android phones do not run SSH, nor do they have /dev/audio available (I'm actually uncertain where the audio path on most android devices terminates).
I see a custom app in your future.

Monitor network activity in Android Phones

I would like to monitor network traffic of my Android Phone. I was thinking using tcpdump for Android, but I'm not sure if I have to cross-compile for the phone.
Another question is the following, If I want to monitor the trafic data for a certain application, there's any command for doing that?
TCPDUMP is one of my favourite tools for analyzing network, but if you find difficult to cross-compile tcpdump for android, I'd recomend you to use some applications from the market.
These are the applications I was talking about:
Shark: Is small version of wireshark for Android phones). This program will create a *.pcap and you can read the file on PC with wireshark.
Shark Reader : This program allows you to read the *.pcap directly in your Android phone.
Shark app works with rooted devices, so if you want to install it, be sure that you have your device already rooted.
Good luck ;)
If you are doing it from the emulator you can do it like this:
Run emulator -tcpdump emulator.cap -avd my_avd to write all the emulator's traffic to a local file on your PC and then open it in wireshark
There is a similar post that might help HERE
Note: tcpdump requires root privileges, so you'll have to root your phone if not done already. Here's an ARM binary of tcpdump (this works for my Samsung Captivate). If you prefer to build your own binary, instructions are here (yes, you'd likely need to cross compile).
Also, check out Shark For Root (an Android packet capture tool based on tcpdump).
I don't believe tcpdump can monitor traffic by specific process ID. The strace method that Chris Stratton refers to seems like more effort than its worth. It would be simpler to monitor specific IPs and ports used by the target process. If that info isn't known, capture all traffic during a period of process activity and then sift through the resulting pcap with Wireshark.
For Android Phones(Without Root):- you can use this application tPacketCapture this will capture the network trafic for your device when you enable the capture.
See this url for more details about network sniffing without rooting your device.
Once you have the file which is in .pcap format you can use this file and analyze the traffic using any traffic analyzer like Wireshark.
Also see this post for further ideas on Capturing mobile phone traffic on wireshark
The DDMS tool included in the Android SDK includes a tool for monitoring network traffic. It does not provide the kind of detail you get from tcpdump and similar low level tools, but it is still very useful.
Oficial documentation: http://developer.android.com/tools/debugging/ddms.html#network
Preconditions: adb and wireshark are installed on your computer and you have a rooted android device.
Download tcpdump to ~/Downloads
adb push ~/Downloads/tcpdump /sdcard/
adb shell
su root
mv /sdcard/tcpdump /data/local/
cd /data/local/
chmod +x tcpdump
./tcpdump -vv -i any -s 0 -w /sdcard/dump.pcap
Ctrl+C once you've captured enough data.
exit
exit
adb pull /sdcard/dump.pcap ~/Downloads/
Now you can open the pcap file using Wireshark.
As for your question about monitoring specific processes, find the bundle id of your app, let's call it com.android.myapp
ps | grep com.android.myapp
copy the first number you see from the output. Let's call it 1234. If you see no output, you need to start the app. If you still don't see the app via ps try using top.
Download strace to ~/Downloads and put into /data/local using the same way you did for tcpdump above.
cd /data/local
./strace -p 1234 -f -e trace=network -o /sdcard/strace.txt
Now you can look at strace.txt for ip addresses, and filter your wireshark log for those IPs.
You would need to root the phone and cross compile tcpdump or use someone else's already compiled version.
You might find it easier to do these experiments with the emulator, in which case you could do the monitoring from the hosting pc. If you must use a real device, another option would be to put it on a wifi network hanging off of a secondary interface on a linux box running tcpdump.
I don't know off the top of my head how you would go about filtering by a specific process. One suggestion I found in some quick googling is to use strace on the subject process instead of tcpdump on the system.
Without root, you can use debug proxies like Charlesproxy&Co.
Packet Capture is the best tool to track network data on the android.
DOesnot need any root access and easy to read and save the calls based on application.
Check this out
Try this application
https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture
We can view all networking communications .. even SSL encrypted communications.
The common approach is to call "cat /proc/net/netstat" as described here:
Android network stats

Easily install Android Application from computer?

A client is releasing a product (employee training/guide), and have contracted us to create a companion application for the Android OS.
Being a global entity that routinely has employees in areas without network access, they are releasing their product via CD.
They would like the ability for their users to optionally install this companion application to their personal Android devices (their own cell phones/tablets etc).
Since some will be in areas without network/internet access, they would really like the ability for an installer to be on this CD to install the Android application.
I am somewhat familiar with being able to install applications onto Android using ADB, but was under the impression this would require root.
Is there a method by which an application could be installed from a computer, in such a way that a non-tech savvy user could use it (IE classic installer application, just different target).
Don't want to be asking these people to root their devices, install ADB and so forth.
I think the ADB route is asking for trouble as you're reliant on the right drivers being present on the machine. Sometimes it'll work fine, sometimes it won't.
You could potentially provide the APK on an SD card for the phone, but there's no consistent app to use to open the APK from the phone, so that's unlikely to be any better.
Surely if they are using phones they do SOMETIMES have network access? I suspect you're going to struggle to find a nice solution, and although not ideal maybe better to just require that users install the app when they do get a connection?
Going down that route, you could provide the APK via email, a web link, Android Market, or any alternative market.
Do remember that the cost of a solution isn't just building it, but the support too. My sense is when you're looking at the possibility you might have to help users install the right driver, you need to look for a better solution as that's the road to hell.
I am somewhat familiar with being able to install applications onto Android using ADB, but was under the impression this would require root.
No.
Is there a method by which an application could be installed from a computer, in such a way that a non-tech savvy user could use it (IE classic installer application, just different target).
There is the Sideload Wonder Machine, but I haven't tried it, and it is Windows-specific. It also would still require adb-compatible drivers, which the user may or may not have installed on their Windows machine.
Otherwise, there are no network-less options at this time that I am aware of.
Well, there is still another option that nobody mentioned, which does not involve dealing with USB drivers. BTW, this is only a Windows problem, in most Linux distros ADB works out-of-the-box.
This option is through WiFi:
configure Tethering & portable hotspot
connect the computer to the hotspot
start some kind of web server on the computer (apache will do, probably microapache could be of help if using Windows)
on the phone open the URL containing the APK (the IP was given by the hotspot)
download
install
Voila !

Categories

Resources