adb over WiFi for Pico i.MX7D [duplicate] - adb

I have a rooted HTC Hero, and what I want to do is to enable the adbd
to listen to a port at boot time.
I tried some code found here:
setprop service.adb.tcp.port 5555
stop adbd
start adbd
in an Android shell and it works great.
I tried to change the init.rc file. I added the above code in init.rc
and I replaced it with the original file, through these commands:
adb push init.rc sdcard
adb shell
adb su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /
adb cp sdcard/init.rc /
The file is replaced successfully, but when I reboot my phone and try to connect
through:
adb connect <IP>:5555
the connection is not being established.
Any ideas?
(PS. I don't want to use the remoteADB application and a shell command like
am start -n ...
)

This will make it persistent:
setprop persist.adb.tcp.port 5555
ADB over USB might not be available after reboot. To undo this setting, do:
setprop persist.adb.tcp.port ""

You need to unpack, modify, and repack the initrd inside the boot.img. You can find more on this at:
https://groups.google.com/forum/?fromgroups=#!topic/android-platform/w37x_WCrhMM

Why don't you try using a BroadcastReceiver of the action BOOT_COMPLETED?
You can register one in you Manifest:
<receiver
android:name="com.myapp.BootCompleted"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
and in the class you can do whatever you want when boot is completed:
import java.util.*;
import android.content.*;
public class BootCompleted extends BroadcastReceiver
{
#Override
public void onReceive(Context context, Intent intent)
{
// Do the actions you want
}
}

Related

How to pass and override configuration properties from command line in Apache Flink?

We have different kerberos login authentication keytabs for our hadoop cluster. Can I pass the keytab path flink command line client rather than specify it in flink-conf.yml? Or any another approaches to specific different configuration file from different applications. Thank you very much!
You can override configuration which is there in flink-conf.yaml using dynamic properties.
While running flink command (on yarn) you can use this:
bin/flink run -m yarn-cluster -yD property_name=value User_Jar
You can override configuration in command line by setting arguments the following way:
./bin/flink run ./examples/batch/WordCount.jar \
--input file:///home/user/hamlet.txt --output file:///home/u
Then you can get this arguments in your code by using ParameterTool.
public static void main(String[] args) throws Exception {
final ParameterTool command = ParameterTool.fromArgs(args);
String inputFile = command.getRequired("input");
String outputFile = command.getRequired("output");
}
References:
https://ci.apache.org/projects/flink/flink-docs-stable/ops/cli.html

adb command - Marshmallow - change preferred network mode LTE/GSM

I am on the 6.0.1 Marshmallow OS and my previous commands to change the preferred network mode are no longer working.
Commands used in Kit Kat worked without issue:
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "SELECT * FROM global WHERE name='preferred_network_mode'"
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "update global SET value=1 WHERE name='preferred_network_mode'"
adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "select value FROM secure WHERE name='preferred_network_mode'
Commands from above entered in this OS result in output:
Error: no such table: global
I pulled the database file, which was completely empty:
adb pull /data/data/com.android.providers.settings/databases/
Is there any ADB command that I can use to change the preferred_network_mode to LTE/GSM?
After a lot of research, this was the working solution I found for Marshmallow.
The Preferred Network Mode numbers are found:
https://android.googlesource.com/platform/hardware/ril/+/master/include/telephony/ril.h#228
1 is GSM Only
11 is LTE Only
adb wait-for-devices
adb root
adb wait-for-devices
adb shell settings list global | grep pref
This returned to me both "preferred_network_mode" and "preferred_network_mode1"
adb shell settings put global preferred_network_mode 1
adb shell settings put global preferred_network_mode1 1
adb shell stop ril-daemon
adb shell start ril-daemon
For setting RAT on SUB1, run below command:
adb wait-for-devices
adb root
adb wait-for-devices
adb remount
adb shell settings put global preferred_network_mode 1
adb shell settings put global preferred_network_mode1 1
adb shell stop ril-daemon
adb shell start ril-daemon
adb shell settings put global airplane_mode_on 1
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state true
adb shell sleep 5;
adb shell settings put global airplane_mode_on 0
adb shell am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false
Now, check if RAT is set or not by running below command:
adb shell dumpsys telephony.registry | grep mServiceState
adb shell:
content update --uri content://settings/global --bind value:i:12 --where "name='preferred_network_mode'"
12 == LTE + WCDMA, for more see ril.h
dont forget to set preferred_network_mode1 and preferred_network_mode2 and preferred_network_mode3

How to get a response with an AT command via ADB?

I was doing what suggested here: Sending AT Commands Via ADB Android
So after I rooted my Samsung S5, I found my modem with this command: getprop rild.libargs and I got this result: -d /dev/smd0
Then I typed into my adb shell: echo -c "AT\r\n" > /dev/smd0
But nothing is returned.
I don't understand, any idea ?
I also tried other commands like: AT+CREG or AT+COPS=?, still nothing.

PuTTY command line automate serial commands from file

I am trying to connect to a serial port and send a series of commands from a file.
Firstly I have mananged to connect via the following:
PuTTY.exe -serial COM3 -sercfg 57600,8,n,1,N
E.g. I have a file called commands.txt with a series of serial commands I wished to be sent.
I tried the following however it failed to work:
PuTTY.exe -serial COM3 -sercfg 57600,8,n,1,N -m commands.txt
Any help is greatly appreciated.
Try like this :
for /f "delims=" %%a in ('type commands.txt') do PuTTY.exe -serial COM3 -sercfg 57600,8,n,1,N -m %%a
Another solution which I have used to regularly send commands to a device uses a combination of PuTTY and Autohotkey.
For the initial setup, configure a PuTTY session and save it. In my case I named is Oasis.
The following Autohotkey function can send a command to the already open PuTTY session. If PuTTY is not open it will start the saved session. oasis_putty_name() is the name of the PuTTY window once it's open, it will depend on the COM port selected. location_putty() is the location of the PuTTY executable. Both of these can be hard coded but I wanted to keep the variables separate from the functions.
; Oasis Check --------------------------------------------------
oasis_check(){
putty_name := oasis_putty_name()
; Start PuTTY if it's not already running
IfWinNotExist, %putty_name%
{
putty := location_putty()
Run %putty% -load Oasis
Sleep,1000
}
; Format Time Stamp
FormatTime, TimeString,,yyyy-MM-dd HH-mm-ss
; Record Oasis Values
ControlSend, , %TimeString%{ENTER}, %putty_name%
Sleep, 2000
ControlSend, , all?{ENTER}, %putty_name%
}
The frequency of execution can be controlled with another Autohotkey script or, as in my case, with the Windows Task Manager.

Facing a file permission error while running CakePHP in Ubuntu 10.4

I have installed CakePHP 2.0 framwork using steps below:
1. Start the terminal
2. sudo mkdir /var/www/cakephp
3.sudo cp -r ~/cakephp/* /var/www/cakephp
Change tmp folder permisssion
4. sudo chmod -R 777 cakephp/app/tmp
Enable mod-rewrite
5. sudo a2enmod rewrite
Open file /etc/apache2/sites-enabled/000-default and change AllowOverride None to AllowOverride All
6. sudo vim /etc/apache2/sites-enabled/000-default
Restart Apache
7. sudo /etc/init.d/apache2 restart
I opened my browser and typed address http://localhost/cakephp/ and I seaw this error message:
Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache in /var/www
/cakephp/lib/Cake/Cache/Cache.php on line 310
Warning: _cake_core_ cache was unable to
write 'cake_dev_en-us' to File cache in /var/www/cakephp/lib/Cake/Cache/Cache.php on line 310
Warning: /var/www/cakephp/app/tmp/cache/persistent/ is not writable in /var/www/cakephp
/lib/Cake/Cache/Engine/FileEngine.php on line 320
Warning: /var/www/cakephp/app/tmp/cache
/models/ is not writable in /var/www/cakephp/lib/Cake/Cache/Engine/FileEngine.php on line 320
Warning: /var/www/cakephp/app/tmp/cache/ is not writable in /var/www/cakephp/lib/Cake
/Cache/Engine/FileEngine.php on line 320
The command sudo chmod -R 777 cakephp/app/tmp only made tmp writable, you should make cache and it's subdirectories writable as well, otherwise Cake can't write the cache files to the cache directory in tmp.
So, these directories should be writable:
cakephp/app/tmp/cache
cakephp/app/tmp/cache/persistent
cakephp/app/tmp/cache/models
Make sure the log directory is writable as well: cakephp/app/tmp/logs.
I've faced similar problems. Here are a couple of things that helped me:
If you don't want to use the "sledgehammer" approach of chmod 777 (you may want to avoid it on production, for instance), the CakePHP installation instructions provide details on how to use ACL instead:
For Cake 2: http://book.cakephp.org/2.0/en/installation.html#permissions
For Cake 3: http://book.cakephp.org/3.0/en/installation.html#permissions
Note that you'll probably need to use sudo for the setfacl commands given there.
However, in my experience (CakePHP 2), those commands aren't enough. These commands give your webserver user access to the cache etc, but anything you run from the command line (like the cake command) will probably be running as your user rather than the webserver user.
Therefore, you should run the setfacl commands linked to above a second time, replacing ${HTTPDUSER} with your user name. If you're not sure what your username is, type whoami to find it.
I have encountered a very similar problem with cachePhp 3.
Warning (512): /cache/persistent/ is not writable [CORE/src/Cache/Engine/FileEngine.php, line 439]
Warning (512): Cache engine Cake\Cache\Engine\FileEngine is not properly configured. [CORE/src/Cache/Cache.php, line 177]
Because I am new in CakePhp, I have debuged the file with problem - CORE/src/Cache/Engine/FileEngine.php.
Here is function like next:
protected function _active()
{
$dir = new SplFileInfo($this->_config['path']);
$path = $dir->getPathname();
$success = true;
if (!is_dir($path)) {
//#codingStandardsIgnoreStart
$success = #mkdir($path, 0775, true);
//#codingStandardsIgnoreEnd
}
$isWritableDir = ($dir->isDir() && $dir->isWritable());
if (!$success || ($this->_init && !$isWritableDir)) {
$this->_init = false;
trigger_error(sprintf(
'%s is not writable',
$this->_config['path']
), E_USER_WARNING);
}
return $success;
}
It checks if cache directory is writable and get data about path form $this->_config['path'] variable. This variable is initialized by default from .env file (if you use it), and it has lines like next:
export CACHE_DEFAULT_URL="File://tmp/cache/?prefix=${APP_NAME}_default&duration=${CACHE_DURATION}"
export CACHE_CAKECORE_URL="File://tmp/cache/persistent?prefix=${APP_NAME}_cake_core&serialize=true&duration=${CACHE_DURATION}"
export CACHE_CAKEMODEL_URL="File://tmp/cache/models?prefix=${APP_NAME}_cake_model&serialize=true&duration=${CACHE_DURATION}"
I have changed all File: to Null:, like next:
export CACHE_DEFAULT_URL="Null://tmp/cache/?prefix=${APP_NAME}_default&duration=${CACHE_DURATION}"
export CACHE_CAKECORE_URL="Null://tmp/cache/persistent?prefix=${APP_NAME}_cake_core&serialize=true&duration=${CACHE_DURATION}"
export CACHE_CAKEMODEL_URL="Null://tmp/cache/models?prefix=${APP_NAME}_cake_model&serialize=true&duration=${CACHE_DURATION}"
export CACHE_DRV_DEFLT = "Null"
export CACHE_DRV_MODEL = "Null"
export CACHE_DRV_CORE = "Null"
And it helps, my problem was fixed. Probably it will be helpfull for someone. Enjoy!
Using chmod -R 777 /var/www/cakephp/app/tmp/ i.e. making folder execuatble will solve this issue.
I even faced similar issue while testing cron i.e. shell which exists in app/Console/Command/ folder. When we execute a cron multiple time, tmp/ folder permission is overwritten and permission error will come in picture at this point which can be avoided by making tmp/ folder executable recursively.
As a temporary fix, if you want to use the provided .env file and permissions did not solve your issue modify the .env file to use absolute path that points to your app directory
export CACHE_FOLDER="/var/www/absolute_path_to_my_cakephp_app/"
export CACHE_DURATION="+2 minutes"
export CACHE_DEFAULT_URL="file://${CACHE_FOLDER}tmp/cache/?prefix=${APP_NAME}_default&duration=${CACHE_DURATION}"
export CACHE_CAKECORE_URL="file://${CACHE_FOLDER}tmp/cache/persistent?prefix=${APP_NAME}_cake_core&serialize=true&duration=${CACHE_DURATION}"
export CACHE_CAKEMODEL_URL="file://${CACHE_FOLDER}tmp/cache/models?prefix=${APP_NAME}_cake_model&serialize=true&duration=${CACHE_DURATION}"
“chmod -R 777 tmp/cache” if tmp folder is not exists then create tmp file using mkdir tmp and mkdir tmp/cache
chmod -R 777 logs
chmod -R 777 tmp/sessions
chmod -R 777 tmp/tests
chcon -R -t httpd_sys_content_rw_t 'tmp'
chcon -R -t httpd_sys_content_rw_t 'logs'

Resources