How to get NFC status through ADB shell command? - appium-android

I am automating an app in that I am turning on NFC through shell command:SVC NFC enable
Now I need to check it's statuswhether NFC has been turned on or not ?
Anyway I can do it through adb shell.

Related

Problems communicating with MOVESENSE using adb

I have tried to follow the instructions from Movesense on how to do Whiteboard communication using ADB. This does not work as expected.
On a sidenote - I'm just trying to set up a handful of sensors to start some heart rate and movement measurement and store data to the logbook. After 30-40 minutes, I want to stop measurements and fetch the data from each device. My first dream was that I could do this using Whiteboard over BLE (from Matlab, Python, LabVIEW, ...) without having to use ADB or similar solutions. But I guess this was a bit too optimistic.
Setup
Installed the adb tools: OK
Enabled USB debugging on an Android phone: OK
Tested that adb can install apps and handle the phone: OK
Installed sampleapp-debug-1.5.1.apk:
Tried to install using adb: OK
Tried to install by copying the file to the phone and installing it there: OK
I got a message saying that the sample app was not compiled for the current version of Android (I'm using a Samsung S10e running One UI version 4.0 and Android version 12, security fix level 01.02.2022).
Im working on an Intel Mac running Big Sur 11.6.5 with plenty of resources.
What I've tried so far
First of all, I start the app and connect to the MOVESENSE device.
When trying the example commands from Movesense, I get:
Switch on LED:
fjp#fMac-19 sensorsw % adb shell am broadcast -a android.intent.action.MOVESENSE --es type put --es path Component/Led --es value '''{\"isOn\":true}'''
Broadcasting: Intent { act=android.intent.action.MOVESENSE flg=0x400000 (has extras) }
Broadcast completed: result=0
Get Info
Get Info does only work if I place curly braces between the quotas. See results below for both variants.
fjp#fMac-19 sensorsw % adb shell am broadcast -a android.intent.action.MOVESENSE --es type get --es path Info --es value ''''''
Exception occurred while executing 'broadcast':
java.lang.IllegalArgumentException: Argument expected after "value"
at com.android.modules.utils.BasicShellCommandHandler.getNextArgRequired(BasicShellCommandHandler.java:295)
at android.content.Intent.parseCommandArgs(Intent.java:8329)
at com.android.server.am.ActivityManagerShellCommand.makeIntent(ActivityManagerShellCommand.java:367)
at com.android.server.am.ActivityManagerShellCommand.runSendBroadcast(ActivityManagerShellCommand.java:788)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:214)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:10429)
at android.os.Binder.shellCommand(Binder.java:986)
at android.os.Binder.onTransact(Binder.java:860)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:6049)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3034)
at android.os.Binder.execTransactInternal(Binder.java:1220)
at android.os.Binder.execTransact(Binder.java:1179)
fjp#fMac-19 sensorsw % adb shell am broadcast -a android.intent.action.MOVESENSE --es type get --es path Info --es value '''{}'''
Broadcasting: Intent { act=android.intent.action.MOVESENSE flg=0x400000 (has extras) }
Broadcast completed: result=0
The suspects
Is my problems due to an old version of the Android app? I could not find anything newer than 1.5.1.
I tried to poke around a bit in the phone using adb shell dumpsys activity services | grep android.intent.action, and got a load of results, I then started to look for MOVESENSE as well using adb shell dumpsys activity services | grep MOVESENSE, and got no hits. I'm on thin ice here, but could it be that there should be an android.intent.action.MOVESENSE in there someplace?
After a lot of trial and error, I have finally found a solution.
The solution
I found aBitbucket directory with a lot of precompiled Android apps.
The file Showcaseapp-debug_adb-bridge-build.apk is the one you want. Here is what you do:
Download Showcaseapp-debug_adb-bridge-build.apk, and place it in your directory of choice.
On your Android device, uninstall the Showcase app if you have installed it already.
Install the app using ADB on your computer: adb install Showcaseapp-debug_adb-bridge-build.apk.
Start the app on your Android device and connect to the Movesense device.
Try a command like:
Switch LED on: adb shell am broadcast -a android.intent.action.MOVESENSE --es type put --es path Component/Led --es value '''{\"isOn\":true}'''
Switch LED off: adb shell am broadcast -a android.intent.action.MOVESENSE --es type put --es path Component/Led --es value '''{\"isOn\":false}'''
A final note
In a perfect world, Movesense would make wbcmd capable of using theBLE device built into most/all PCs, be it Windows, Linux, or Mac. Or even perfecter (is that a word?), make a variant that used TCP/IP instead of standard in/out.

Huawei E3331 is not detected as modem (to send sms)

$ lsusb
Bus 001 Device 014: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem (Mass Storage Mode)
$ gammu-detect
; Configuration file generated by gammu-detect.
; Please check The Gammu Manual for more information.
[gammu]
device = /dev/ttyS2
name = Phone on serial port 2
connection = at
The modem is detected as mass storage. I want the modem to be detected as Modem/Networkcard
I have searched and tried and finally this worked for me
Solution 1:
- /etc/mode_switch.config and turn on the following flag:
DisableSwitching=1
Go to following folder and create the 12d1:14fe file
$ cd /etc/usb_modeswitch.d/
$ sudo tar -xzvf /usr/share/usb_modeswitch/configPack.tar.gz 12d1:14fe
Edit 12d1:14fe file and add following lines and save it
DefaultVendor=0x12d1
DefaultProduct=0x14fe
TargetVendor=0x12d1
TargetProduct=0x1506
MessageContent="55534243123456780000000000000011062000000100000000000000000000"
If you remove the USB dongle and reconnect it. You have to run following command to bring it back in modem mode
sudo usb_modeswitch -c /etc/usb_modeswitch.d/12d1\:14fe
To auto detect the USB dongle as modem when it is connected then set following rule
sudo touch /etc/udev/rules.d/huawei_e3331.rules
Then create add following rules to file and save it
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="14fe", RUN+="/usr/sbin/usb_modeswitch -v 0x12d1 -p 0x14fe -V 0x12d1 -P 0x1506 -M '55534243123456780000000000000011062000000100000000000000000000'"
$ gammu-detect > .gammurc
$ sudo gammu-detect > .gammurc
$ gammu identify
Device : /dev/ttyUSB0
Manufacturer : Huawei
Model : unknown (E3331)
Firmware : 21.146.07.01.158
IMEI : 869************
SIM IMSI : 412************
$ echo "test" | sudo gammu sendsms TEXT 070*******
you will receive a test message
First of all, make sure that your mobile card has 3G permission, that is, 186 mobile phone number, and other 2G mobile phone numbers can also have 3G permission;
Anyway, it is the Unicom card of Waupaca brand;
Second, isn't there a PC Suite in the software of connecting the mobile phone to the computer? In the middle of the software installation, you will be asked if you want to install the driver, which must be confirmed. After that, if you uninstall the software, you can version it, but you can't uninstall the driver;
Connect the phone cable to the USB port of the computer. There will be an Android adapter in the computer manager, which means the driver is installed;
When the mobile phone is connected to the computer, it can't turn on the U-disk mode;
Run daily up for Android on the computer... Just click Connect right
It takes a lot of traffic

how can i reset service usb to serial driver that listed in lsmod without reboot system?

I have one usb_to_serial that connected my usb
and installed by this command
modprobe usbserial vendor=0x67b product=0x2303
and connect to other devices via console
and when use of the screen for connecting to console for example
screen /dev/ttyUSB0 9600
i can stop the session by the this command
fuser -k /dev/ttyUSB0
but when connect to other device console my console empty show
my question is when i reboot the system and connecting the first device via Console any thing is ok but when i need to connect to other device then must be reboot the os thus can to connect new device! there is any method that don`t required to reboot and only reset the usbserial service without reboot?
thanks for help
now me found a method to restart service usbconsole
if you have same problem then can to try kill process by
pkill -f /dev/ttyUSB0 ; screen /dev/ttyUSB0 9600
by this command you kill prior session on Serial Console and create new session for them

Read Battery Percentage of iPhone via WLAN

I found an app that shows the battery percentage of my iPhone in the menu bar (iBetterCharge). The iPhone is not connected via USB or Bluetooth (it is only connected to the same network as my Macbook).
My question is: How can I get this information? The device shows up in IOReg, but only because I connected my phone via Bluetooth once.
This can be done by using the unix application "libimobiledevice". I'm not sure that it works with all versions of iOS.
//install it:
brew install libimobiledevice
//list all device
idevice_id --list // list available device UDIDs. Normally, we have to plug the device at least once to get its UUID.
//get the current syslog of device that we want to check
idevicesyslog -u <device udid>
//do some text search to get the battery info
//or running ideviceinfo (I don't know if it works wirelessly)
//run 'ideviceinfo --help' to see how it works
ideviceinfo -u <device udid> --domain com.apple.mobile.battery
More read at:
https://www.theiphonewiki.com/wiki/MobileDevice_Library

Setting brightness of tv through cec-client

I am running cec-client on my linux machine and currently using it to turn off and on the TV. is there a command for seting the tv brightness??
I have a Samsung tv
I guess there is no command to set brightness.
Check out all the supported commands here -
https://github.com/Pulse-Eight/libcec/blob/master/src/testclient/main.cpp#L309-L347