Test an NTP server from android command line - android

I have read that what I am trying to do can be done on linux systems using the ntpdate command:
ntpdate -d time.google.com
which should return a valid time but should not if you give it an address that isn't an ntp server.
Problem is... the ntpdate command is not available on android.
How can I do this from an android system?

Related

Hyperledger Indy pool connecting android error -> InvalidStateException: The SDK library experienced an unexpected internal error

I have a one question.
I’m trying to connect the Android app to the indy pool, but I see error( Timeout happens for ledger operation) source(https://github.com/jSh4rk/SampleIndyWallet)
I installed indy in AWS(ubuntu 16.04 lts) and after running node with docker
When running docker I entered the command
docker build --build-arg pool_ip=172.31.37.144 -f ci/indy-pool.dockerfile -t indy_pool
because I want 172.31.37.144 to be private ip address of my docker container:
docker run -itd -p 172.31.37.144:9701-9708:9701-9708 -t indy_pool
In SampleIndyWallet's file MainActivity.java I changed the string ip to public IP of my container.
However, I get error org.hyperledger.indy.sdk.InvalidStateException: The SDK library experienced an unexpected internal error in the process of opening connection to the pool.
In order to connect to Hyperledger Indy from anywhere, as you might already know, you need genesis file. Genesis file specifies IP addresses of the network Nodes and their associated cryptographic data (signatures, public keys...).
When building Indy pool docker with command as you've posted
docker build --build-arg pool_ip=172.31.37.144 -f ci/indy-pool.dockerfile -t indy_pool
it's important to specify correct pool_ip. The pool_ip will become part of genesis file. And when you supply genesis file to indySDK, it will take these IPs and try to establish connection with them. If you are getting error such as PoolTimeout, it's likely because these IPs are not reachable from the environment you run IndySDK at.
So by building image as above you are saying: "Clients connecting to container made of this image will have to be able to reach the container via address 172.31.37.144". That might work if you are trying to connect to the pool from other docker container within the same network. But if application is running on your localhost, 172.31.37.144 will not connect anywhere as that's only internal IP address within the docker network.
As I understood, you want to run Indy network in pool and connect to the pool from application running on your host. The easiest way is to make the network reachable on your localhost / 127.0.0.1 by exposing the ports. Let's first build indy network container which will have 127.0.0.1 in its genesis transactions.
docker build --build-arg pool_ip=127.0.0.1 -f ci/indy-pool.dockerfile -t indy_pool
Now let's read genesis file of your image and store it locally.
docker exec indy_pool cat '/var/lib/indy/sandbox/pool_transactions_genesis' > ~/my_genesis.txn
Next you'll start the pool similarly as you've been doing it, but no need to specify internal ip address of container - it doesn't matter.
docker run -itd -p 9701-9708:9701-9708 -t indy_pool
Now you when you start your application and try to connect to the pool, you'll have to specify path to genesis file we created on your localhost.

android: run cmd on server

i want run command line on server from android application to see the processor usage, hard disk usage, and ram usage, to notify android app's user
i have server access, but i don't know how to run command on server from application
and all of theme must run without any api if not possible we can create 1 or 2 api(s)
i just check ping of server from mobile devices, but i can't run cmd yet
thanks for your help
that's the cmd line to get processor usage:
wmic cpu get loadpercentage
That command doesn't work in Android. It is a Windows command.

Running / controlling an emulator on remote server

I use couple of Android apps on daily bases, and it's very time consuming.
I want to somehow automatize the process.
The idea is to install some sort of emulator on the server, and program that emulator through some programming language to run the apps on the server when its needed.
I'm a web developer, I work with PHP, nodejs, python,
not really familiar with mobile space.
Is there any solution out there to do what I want?
I search around and found Appium but I'm not sure if it would do what I want.
Please note these apps don't have a public 'api' for me to use.
Also I only have remote access to server via 'ssh terminal', so solutions with 'GUI' dependency wont work for me.
You can use some emulator, like Bluestacks and then run a script to run apps and then use macro tool to emulate clicks in the games or apps
check this link for the macro tool in bluestacks : https://www.bluestacks.com/blog/bluestacks-exclusives/combo-key-bluestacks-record-replay-action-single-key-en.html
Or you can write a script which uses adb commands to run and control the app.
For example.
to run apps. adb shell am start -n com.android.settings/.Settings
this command will open the settings app in the emulator.
to send touch events you can use : adb shell input touch <x> <Y>
adb shell input keyevent <keycode> to send keycodes
I'm assuming that you want to automate native Android apps.
Short answer: Appium will be good solution for you.
On your remote server you will need:
Android SDK and Simulator
Python 2.7 installed
Appium server/node (install using node.js npm )
With everything installed you will be able to start Appium Nodes on your server and run Appium scripts against them.
I suggest using CI server of choise for automating this process. It should make starting your test trough ssh terminal easier / 100% automated.
I never used Selenium/Appium in python, so I can't really help you with Appium tests code examples, but I'm sure there are a lot of basic tutorials for python.
You must install AppiumServer and android sdk/simulator in the remote server. I am going to show how it can be done in java. Hope you can convert it into javascript code.
Check the ip Address of your remote server using ipconfig
Start your appium server in the remote server
>appium -a "ip address of remote server" -p 4732 --session-override
Start the emulator in the remote server.
Define and initialize DesiredCapabilities and AppiumDriver in your code like following.
AppiumDriver<MobileElement> driver;
DesiredCapabilities caps= new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "android device");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 300);
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
caps.setCapability("appPackage", "enter your appPackage");
caps.setCapability("appActivity", "enter your appActivity");
driver= new AndroidDriver<MobileElement>(new URL("remote server ip address" + ":4732/wd/hub"), caps);
Make sure both device are in the same network. you must get response while pinging to the remote server ip address

How to run AT commands in Android terminal as root user?

I have root my Android mobile (Spice MI 270). I want to run AT commands. But whenever I try to run any AT command form shell, it is giving messages as 'AT not found'. My whole purpose of routing is to give AT commands to modem.
How should I proceed?
Thanks.
You can use the program atinout which will allow you to easily send AT commands from the commands line. Example to hang up a call:
$ echo ATH | atinout - /dev/ttyACM0 -
ATH
OK
$
You need to find the name of the serial device for android (on desktop linux it is typically /dev/ttyACM0 but Android use something different as far as I remember).

What is the ADB?

I keep reading tutorials where I'm supposed to enter something into the ADB command line and that it's in my Android sdk/platform-tools. So I find it, click on it, and a black screen comes up for about 2 seconds and while it's up, it scrolls through a bunch of text. So how am I supposed to use this "adb"?
It is called the Android Debug Bridge, and the Android Developers Site documentation does a better job of explaining it than I can:
http://developer.android.com/guide/developing/tools/adb.html
If you are looking for the adb command line, navigate to <sdk>/platform-tools/ and run
adb.exe shell
from the command line.
Pretty sure that is well documented since day 1 on the Android Debug Bridge
Android Debug Bridge (adb) is a versatile command line tool that lets
you communicate with an emulator instance or connected Android-powered
device. It is a client-server program that includes three components:
A client, which runs on your development machine. You can invoke a
client from a shell by issuing an adb command. Other Android tools
such as the ADT plugin and DDMS also create adb clients. A server,
which runs as a background process on your development machine. The
server manages communication between the client and the adb daemon
running on an emulator or device. A daemon, which runs as a background
process on each emulator or device instance.
So plain old English, ADB can be found on %ANDROID_HOME%/platform-toos/, and it's this magical command line that allows you to comunicate with your mobile device, either a physical or a Virtual device (AVD), so whenever you deploy you are passing the application through the device thanks to the ADB on a specific client port on your computer to the daemon port on the device.
Interesting things you can do with it?
Logcat: ./adb logcat allows you to see the log trace of each proces.
Install: ./adb install allows you to install apk to the device.
Killing:./adb kill-sever
Starting:./adb stat-server
Enter SQLite3: adb -s your_device shell
Use the monkey: adb shell monkey -v -p your.app.package 500 to
generate random events
And a lot more! Read the documentation it's beatiful and self-explanatory.

Categories

Resources