how access current and focused window in android adb - adb

I am using Android API 30 adb
adb shell dumpsys window windows
but it is not showing
mCurrentFocused and mFocused app
Kindly help me out

I think you can try this:
dumpsys window | grep -E "mCurrentFocus

Related

Skype URI through adb, can't turn video on by default

I am trying to start a video call on Skype using their URI API, but the video is turned off when the call starts.
They give a clear example how to use it:
skype:skype.test.user.1?call&video=true
I am using adb to send the command, so I am using the command:
adb shell am start -a android.intent.action.VIEW -d "skype:someuser?call&video=true"
This successfully initiates the call, but with video off. I have tried adding the extra parameter using the Android adb extra parameters:
--es extra_key extra_string_value
So my full command is
adb shell am start -a android.intent.action.VIEW --es "video" "true" -d skype:someuser?call
but this doesn't make the trick.
Figured out the solution thanks to this related answer.
The solution is simply to escape the ampersand (&) character inside the quotes!
So, the final command that worked for me is:
adb shell am start -a android.intent.action.VIEW -d "skype:someuser?call\&video=true"

How to know that IMS registration is happened in SIM1 or SIM2 via adb logs for android device

How to know that IMS registration is happened in SIM1 or SIM2 via ADB logs.
If i have attached SIM1 to VoLTE and SIM2 to 3G , from runtime ADB logs how can i verify that.
I need a solution to create for my automation script, so it can detect the IMS registration during runtime.
You can capture the output using following command:
adb shell logcat | grep ims_reg_state

what is the key_code to enable or disable wifi via adb for non rooted device

I have a non rooted Samsung device , i want to enable/disable wi-fi settings for my usages via adb.To open wifi for non rooted device via adb i ran below command
adb -s 4d0075754fdb41cd shell am start -n com.android.settings/.wifi.WifiSettings
By default the wifi is coming as diabled , i want to enable/disable it
I tried with Keyevent , however this did not helped much
adb shell input keyevent 22
The wi-fi slider looks like below , i tried with all available key_code .
Can anyone point me a way to get the correct keycode here!!
You can try adb -s $PHONESERIAL shell "svc wifi enable" if you just want to turn on the wifi with adb.
Was already answered here : android adb turn on wifi via adb
You placed appium tag, so if you using appium, try running:
adb -s $device_id shell am broadcast -a io.appium.settings.wifi --es setstatus enable
adb -s $device_id shell am broadcast -a io.appium.settings.wifi --es setstatus disable

Android Things: take a screenshot

How do you take a screenshot via ADB for Android Things? I have tried:
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png
adb shell rm /sdcard/screen.png
and
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
I couldn't make screepcap work in Android Things Developer Preview. The command results in a 0-size file.
That said, I recommend the following two options: either use the framebuffer or record a video (screenrecord seems to work) and convert it to an image later on by proper tool. I'll consider the first option, so the steps would be:
Pull the framebuffer to the host machine. Note that you need to start adbd as root in order to pass a permission check:
adb root
adb pull /dev/graphics/fb0 screenshot
Convert the raw binary to image by the tool you prefer. I'm using ffmpeg. The command below might not work for you due to different screen resolution or pixel format. If so, make proper changes.
ffmpeg -f rawvideo -pix_fmt rgb565 -s 800x480 -i screenshot screenshot.png
Seems, because of old limited OpenGL version in Android Things, described by Tatsuhiko Arai here there is no possibility to get screenshot via ADB, but You can record video (e.g. from Android Studio, or via ADB commands) and than grab frame from it, for example via ffmpeg:
ffmpeg -i device-2017-01-23-193539.mp4 -r 1 screen-%04d.png
where device-2017-01-23-193539.mp4 - name of recorded (via Android Studio) file .
I've tried exactly this code with a little bit change like below (but no matter) and it works well. The image is in my platform-tools directory now.
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png screen.png
adb shell rm /sdcard/screen.png

how to update adb drivers for android phones?

I am having difficulties in my android application because i want to run my project in my android device. I tried to install some drivers for my phone but still, it can't update the drivers and my phone is not recognized even in adb devices. Please help. Thanks.
Run android update adb
Run adb kill-server
Run adb start-server
At this point, calling adb devices started returning devices again.
Now run or debug your project to test it on your device.
If you use Windows
If you don't have the android and adb set as windows environment variables, just go to
C:\Program Files\Android\sdk\platform-tools
(in explorer press Shift+RightClick in the white part and open command window) and use the following commands: ..\tools\android.bat update adb adb kill-server adb start-server
For android phones,
Turn on Developer mode on settings
For Oculus devices,
Open Oculus App in your android/ios device
Make sure the oculus device is connected via bluetooth
Goto Settings, Click on oculus device name
From Dropdown menu, click More Settings -> Developer Mode and turn it on
I was able to find ADB required version 1.0.40 from here and it works like a charm:
D:\Setups\XXXXX\Lineage FP3\platform-tools_28.0.1(ADB_1.0.40)>adb devices
List of devices attached
A2XXXXXXXXX1 unauthorized

Resources