获取屏幕当前亮度

发布于 2024-11-15 02:12:07 字数 509 浏览 3 评论 0原文

目前,我正在使用下面的代码来获取当前的屏幕亮度,

...
// 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());
...

当我用于获取 HTC 设备(Nexus One、Desire)中的亮度时,这是可以的。但是,当在 Samsung Galaxy S 上运行此代码时,此代码无效,因为该设备上“cmd”中的路径错误。问题是我没有 Samsung Galaxy S 来找出正确的亮度路径。 那么您能否告诉我 Samsung Galaxy S 设备上的正确路径或执行此任务的其他方法! 谢谢,

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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

今天小雨转甜 2024-11-22 02:12:07

我能找到的最简单的方法是使用 adb 获取屏幕亮度:

adb shell settings get system screen_brightness

The simplest one I could find, to get the screen brightness, using adb:

adb shell settings get system screen_brightness
清风挽心 2024-11-22 02:12:07

我知道人们已经为您提供了更好的方法来提高设备亮度。不否认这一点,但只是出于好奇,如果你想找到存储亮度的相关文件,这里是:

  • 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

在 Galaxy S 上,似乎还有一个名为brightness,但 actual_brightness 似乎更准确。它捕获设备的屏幕在一定的空闲时间后变为半亮状态。

简而言之,三星设备上似乎没有标准路径/文件。当然,这不是获取亮度的最佳方法,但如果您好奇,上面是一些文件。

找出答案的最佳方法是从您的桌面运行,

adb shell ls -R /sys/devices >files.txt

然后

grep -i  bright files.txt

:-)

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

:-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文