how to resize physical android screen from terminal/shell - android

A while ago, I was able to resize the screens on Android. For example, I had a Xoom, and was able to run a command from ADB which shrunk it down to a 7" screen (leaving a black border around it). Granted, it was a little buggy because the home/back/app-switch buttons disappeared, but I know it's possible. It's a 1 line command where I input the new screen resolution in X and Y pixels for the Xoom.
I was wondering if anyone was familiar with this, and knows how to do it.
(and if anyone says it's not possible, I can assure you it is)
(and I want to do this so I can test apps in various screen sizes on my Nexus 10, and I'd prefer not using an emulator)

An update to this answer for Jelly Bean 4.3 from Android dev Adam Powell on Google+ (link found via this SO answer):
In Android 4.3 these options moved from the "am" command (ActivityManager) to the "wm" command (WindowManager). Type "adb shell wm" for details.
So you can now run on 4.3 devices:
adb shell wm size 1280x800 or whatever size or reset
and
adb shell wm density 480 or whatever density or reset
Just make sure the screen is not currently displaying at the moment you run the command.

I believe it is:
adb shell am display-size
but i am away from a computer to try it. An example use would be:
adb shell am display-size 640x480

you can also change the resolution via android terminal, just type "wm size 720x1280" for example.

Related

Set font scale in Android emulator using adb

I'm trying to change the font size in Android emulator (Pixel) programatically with adb. The commands are executed successfully but I see no difference in the font size. What is missing?
Already tried with other numbers (2.0, 0.5 etc) as well.
$ANDROID_HOME/platform-tools/adb shell settings put global font_scale 1.5
$ANDROID_HOME/platform-tools/adb reboot

Android Emulator Screen Resolution looks higher than set

Trying to match a specific device screen in an emulated device though it seems/looks like it higher than desired.
Looking at screenshot the first is a physical device, specifically the Nabi Big Tab, a 20inch screen with a resolution of 1600 x 900
and comparing that to the emulated device it seems like the emulator is a higher resolution...
Tried
hw.lcd.density
other questions found are for pre Android Studio 3
Start the emulator and connect the physical device to input adb commands
then execute the following using -d to send the command to the device:
adb shell wm density
it should return something like with the Nabi Tab Physical density: 213
then using -e to send command to the emulator:
adb shell wm density 213
The problem with that is the screen changes and puts the navigation bar on the right side instead of the bottom of screen...
So I found the navigation bar moves when density > 200 so using 200 is as close as I have been able to figure...not to mention it is an invalid value and does cause issue...
What can I do to make the screenshots match sizes more closely/ accurately?
Start the emulator and connect the physical device to input adb commands
then execute the following using -d to send the command to the device:
adb shell wm density
it should return something like with the Nabi Tab Physical density: 213
then using -e to send command to the emulator:
adb shell wm density 213
also check that you match the device hardware buttons or lack there of
You can save the value for use at start see -> https://stackoverflow.com/a/43860845/1815624
Still not 100% a better answer is desired
From reading the following article 213 is for TVs... this may play a part...
https://www.captechconsulting.com/blogs/understanding-density-independence-in-android
Andriod Studio Ver 3: (this is for RESOLUTION adjustment):
in Studio, go to Tools -> AVD Manager -> Edit this AVD ( click the pencil icon on the right side)
then
change the device Device (right udner AVD name input box), to what ever your want. it Nexus 6P for higher resolution.
To change scale/size of AVD, just use Ctrl + up_arrow/down_arrow.

Change screen size of Genymotion programatically

There's a chance to change the screen size and density of an already created genymotion machine by going to the machine on the genymotion launcher-> configure-> Screen size - Density.
I'd like to do this through a shell command, does this command exist? How can it be called if so?
For now it is not possible.
But we will soon release features related to continuous integration and automation. A command line tool will be included on these features. It allows you to do all what you can do with your mouse, but through the command line. And it will be available to paid licenses.
Editing the screen size and resolution is part of it.
Here is a demo we gave at Droidcon Paris

ADB set display-size is incorrectly displaying portrait using landscape

I am using the adb feature to set the screensize to see how the app looks on smaller screens.
using the command :
adb shell am display-size 1200x720
in 4.3 the command is
adb shell wm size 1200x720
But it is seems to be behaving stupidly as it displays portrait view of the app in landscape view of the device.
Leaving so much screen not used and result is a smaller looking device than need be. The device is the Nexus 7
Just swap the order of the dimensions. So instead of 1200x720, use 720x1200. That should do it for you.

Get current brightness of the screen

Currently, I'm using below code to get current screen brightness
...
// for HTC Nexus One and HTC Desire
String cmd = "cat /sys/class/leds/lcd-backlight/brightness";
java.lang.Process p = Runtime.getRuntime().exec(cmd);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()),cmd.length());
...
It's ok when I use to get the brightness in HTC devices(Nexus One, Desire). But when run this code on Samsung Galaxy S, this code is invalid because the path in "cmd" is wrong on this device. The problem is I don't have Samsung Galaxy S to find out the correct path of brightness.
So could you please tell me the correct path on Samsung Galaxy S device or other ways to do this task!
Thanks,
The simplest one I could find, to get the screen brightness, using adb:
adb shell settings get system screen_brightness
I know people have given you better ways to do device brightness. Not denying that, but just out of curiosity, if you want to find the relevant files where brightness is stored, here they are:
Nexus S: /sys/devices/platform/s3cfb/spi_gpio.3/spi3.0/backlight/s5p_bl/brightness
Galaxy Y: /sys/devices/platform/aat1401-backlight.0/backlight/aat1401-backlight/brightness
Galaxy S: /sys/devices/platform/omap2_mcspi.1/spi1.0/backlight/omap_bl/actual_brightness
On the Galaxy S, there also seems to be a file named brightness, but actual_brightness seems more accurate. It is capturing the device's screen going half-bright after a certain idle time.
In a nutshell, there does not seem to be a standard path/file on Samsung devices. Of course, this is not the best way to get the brightness, but if you're curious, the above are some of the files.
The best way to figure out is from your desktop, run
adb shell ls -R /sys/devices >files.txt
and then
grep -i bright files.txt
:-)
Is there a particular reason you're not using the System.Settings class?
Like in:
Can't apply system screen brightness programmatically in Android
Adding screen brightness controls to android application

Categories

Resources