Get current brightness of the screen - android

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

Related

fireOs : Display problem on a 5.5 inch lcd

I am trying to connect a fire stick 4k max to a 5.5 inch 4k lcd (where the hdmi interface is provided by a MI-PI board). However, here's what i get :
While booting :
and a few seconds later :
The lcd is working on windows. Also, after struggling with display configuration, I managed to make the lcd work on a RPI 4, at the desired resolution (i.e. 3840x2160#30). I am pretty sure that it should also work with a fire tv 4k max, regarding to the first image which is in 4k (I think), but with rotation and wrong pixel positionning issues; I had something very similar on RPI4 before changing some parameters in /boot/config.txt file.
I am a total noob at android. I tried however to set the resolution and the density via adb shell,
but it didn't work...
I also tried to force the rotation using
adb shell settings put system user_rotation 1
but still havig the same problems... Any Ideas or suggestions? I can send some logs if needed. Thank you in advance.

Screen mirroring android things (RPI) with TeamViewer Host

I've succeeded to screen mirror the RPI running android things. What I did is:
installed TeamViewer_Host.apk via adb
Ran it on the RPI and login to my account(needed a display connected by HDMI)
connected to it by my laptop TeamViewer application
then got a very nice 1080p resolution mirrored screen
But the problem appeared when I tried to do the same thing but without the HDMI display connected and then suddenly got a poor 32x32 tiny screen on the laptop!
I tried it with Vysor app too but got the same result
My guess is that Android Things somehow detects automatically the resolution of the display and fits itself with it but when there's no display connected, it gives us a 32x32 one!
You guys have any ideas for this one?
Okay. I finally got the right way to do this.
The only thing you need to do is to adjust the resolution(while your Pi is connected to an HDMI display). After that you dont need the physical display any more and can connect to the Pi via TeamViewer.
For adjusting the resolution use this command in ADB:adb shell wm size 1080x1920 or any other resolution.

Android UI behaves differently with different display hardware

My android device behaves in a strange manner when I connect a 1366 X 768 lvds display. The UI is different from what I was getting with HDMI connected. I'm getting a different home screen with some other wallpaper and more than that the navigation keys at the bottom are missing.
It looks like based on the hardware display configuration the UI is configured.
Is there a way to override this behaviour? Please suggest some ways to tackle this..
Android Version : Lollipop 5.0.1
issue was due to a hard coded display density parameter. It was hard coded to 240. Issue is resolved when the density value is changed to 160.
$adb shell "echo qemu.sf.lcd_density=160 >> /system/build.prop"
Thanks,
Arjun.

how to resize physical android screen from terminal/shell

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.

Changing screen resolution on android devices without re booting

I tried changing the screen resolution in build.prop file in system, but it requires re booting.
I need a solution for changing screen resolution on android devices without re booting.
Thanks,
Krishna
Unfortunately that is not possible. Everytime when Android boots, it will read the build.prop file and set parameters pointed by it accordingly. After it has booted, it will not access that file dynamically to change parameters. So for any change to take effect, a reboot is compulsary, you cannot escape it.
Set resolution (e.g. 1024x768):
$ am display-size 1024x768
Reset:
$ am display-size reset
Doesn't require a reboot. This works with Android 4.2. Solution for 4.3 is mentioned by LiTTle
There is also an App for that called NOMone Resolution Changer.
Android can change the screen resolution.
I think that you need Android 4.0 and above version.
Only things you need is terminal emulator and root access.
Reproduce the following steps:
1. Open the terminal emulator app.
2. Type su.
3. Type wm.
Read the help message appeared and you will understand...
In case you want an App take a look at this on Play Store or the source from Github.

Categories

Resources