How to set brightness through ADB on nexus 7 - android

I found some info on the web:
echo 1 /sys/devices/platform/flashlight.0/leds/flashlight/brightness
But on my Nexus 7 (flashed an AOSP), I couldn't find that directory.
Any idea about which file should I write to? Is this doable?
After ls /sys/devices/platform, I got:
LID
alarm
arm-pmu.0
bcm4330_rfkill
bcmdhd_wlan.1
bluesleep
fiq_debugger.0
fsl-tegra-udc
gpio-keys.0
grouper_misc
leds-gpio
oprofile-perf.0
power
power.0
pwm-backlight
ram_console
reg-dummy
reg-fixed-voltage.1
reg-fixed-voltage.10
reg-fixed-voltage.11
reg-fixed-voltage.2
reg-fixed-voltage.3
reg-fixed-voltage.4
reg-fixed-voltage.6
reg-fixed-voltage.8
regulatory.0
sdhci-tegra.2
sdhci-tegra.3
serial8250
snd-soc-dummy
spdif-dit.0
spdif-dit.1
spi_tegra.0
spi_tegra.3
tegra-ehci.1
tegra-i2c.0
tegra-i2c.1
tegra-i2c.2
tegra-i2c.3
tegra-i2c.4
tegra-nvmap
tegra-otg
tegra-pcm-audio
tegra-se
tegra-snd-rt5640.0
tegra30-ahub
tegra30-dam.0
tegra30-dam.1
tegra30-dam.2
tegra30-hda
tegra30-i2s.1
tegra30-i2s.3
tegra30-i2s.4
tegra30-spdif
tegra_camera
tegra_pwm.0
tegra_rtc
tegra_smmu
tegra_uart.1
tegra_uart.2
tegra_uart.3
tegra_uart.4
tegra_wdt
uevent

There is a new binary shipping with Android Jellybean 4.2, which can be used to directly read/write to the system settings provider, accessible via command line.
For example: in order to increase brightness of the screen, use below command:
adb shell settings put system screen_brightness 200
Read more about SCREEN_BRIGHTNESS Note that the range of values is [0 - 255]

The range of values is not necessarily from 0 - 255. On my OnePlus for example
it ranges from 0-2047. If you want to know yours just set the brightness slider to max and
then type: adb shell settings get system screen_brightness.

You should use the pwm-backlight!

You can use this adb command to set screen brightness
adb shell settings put system screen_brightness 255
and if your device has auto brightness setting then use this command first
adb shell settings put system screen_brightness_mode 0

This did not work for the latest Nexus 7 (2013) for me. But this answer explains the way to find what you are looking for on any version: https://stackoverflow.com/a/13492336
However we need to note that in order to change any of this you need to have root access.

Related

How init.rc setprop works

I have android 8 from nxp and using it on sabresd board.
I am trying to change dpi settings through setprop settings
So I have put this iside init.${hardware}.rc on boot event
# Set the density to 160dpi, default 128dpi is not good
# Set the density to 128 dpi for 480x800, 7 inch.
setprop ro.sf.lcd_density 128
The device works fine and if I do this
wm density
Physical density:128
Now I put this dpi setting in kernel command line
androidboot.sf.lcd_density=128
but I do not see device to be in 128 dpi setting. Also
wm density
Physical density:160
Now this baffles me.Who gave 160dpi settings?
How putting setprop in init.$hardware.rc affects the display but not in kernel command line.
Who really processes setprop.
I tried putting prints like this
on boot
exec /system/bin/echo "Trigger test E"
I saw nothing, so does that mean boot event never happened?
In android framework there is a file called
display file
that contains default dpi if none is specified.
This file have this setting,
public static final int DENSITY_MEDIUM = 160;
Which is used if no dpi is specified.

Can android app write to /sys/ without root permissions?

My phone's display backlight even after setting to minimum hurts me in dark. I checked the valid range of values for the file /sys/class/leds/lcd-backlight/brightness and found it takes 0 - 255 . 0 is display off, 1 is minimum brightness, and 255 is maximum brightness.
The android system display settings when set to minimum sets the sys file value to 5 which hurts my eyes in dark. I echoed the value 1 from root terminal and it sets brighness to lowest value that makes my eyes comfortable in dark.
The sys file is owned by user system and group system and its permissions are -rw-r--r-- .
I need my app to write to /sys/class/leds/lcd-backlight/brightness to set the display brightness to a very minimum value. If I use su command in app, I can modify the file. But I want to do the same without superuser permission. Is there some sort of permission that allows me to modify the file?
What are the possible ways to modify the /sys file without root permissions?
You don't need user permissions to change the screen's brightness. Just do this:
WindowManager.LayoutParams
layoutParams = getWindow().getAttributes();
layoutParams.screenBrightness = BackLightValue;
getWindow().setAttributes(layoutParams);
The variable BackLightValue is used to set the brightness to auto but you can change it to whatever you need

Android Touchscreen IDC

I'm struggling with calibration of a touchscreen on Android plataform.
It is an USB Single-Touch Touchscreen from vendor 0dfc and product 0001 as checked with dmesg:
<6>[ 4118.091541] input: USB Touchscreen 0dfc:0001 as /devices/platform/usb20_host/usb2/2-1/2-1.3/2-1.3:1.0/input/input23
I'm pushing the Vendor_0dfc_Product_0001.idc file /data/system/devices/idc/ (following the documentation from android source - IDC
I got the touch device with all requirements for single touch events:
root#android:/ # getevent -il /dev/input/event3
add device 1: /dev/input/event3
bus: 0003
vendor 0dfc
product 0001
version 0202
name: "USB Touchscreen 0dfc:0001"
location: "usb-usb20_host-1.3/input0"
id: ""
version: 1.0.1
events:
KEY (0001): BTN_TOUCH
ABS (0003): ABS_X : value 540, min 0, max 32767, fuzz 0, flat 0, resolution 0
ABS_Y : value 289, min 0, max 32767, fuzz 0, flat 0, resolution 0
input props:
<none>
I also enabled the Pointer Location option from Developer options (Android settings) in order to debug this stage of calibration.
Setup 1
touch.deviceType = touchScreen
With this setup (1) all the gestures on the touchscreen take place at the up-left corner - just a few pixels left/right/up/down no matter the gesture (swipe). All the touchscreen get events. All the gestures are reversed - when swipe left the pointer goes right; when swipe up, the pointer goes down.
Setup 2
touch.deviceType = pointer
touch.gestureMode = pointer
With this setup (2), as expected, it shows a pointer, placed at the position from the last pointer device left (mouse). All the gestures on the touchscreen (no matter the swipe size) keep beaving like setup 1 - move only a few pixels with each swipe event, and with reversed axis.
Setup 3
touch.deviceType = pointer
touch.gestureMode = spots
With this setup (3) the result is the same as setup 2. I just did that to prove that the IDC file is being interpreted correctly.
At this stage, as you can check by now, I have a working IDC file (setup 1) requiring calibration for this touch device.
I tried a lot of combinations from other IDC files (internet samples) and from android source - IDC - ANY OTHER PROPERTY TOOK EFFECT (NOT A SINGLE ONE) - raw.*, output.*, touch.size.*
Does anyone knows how to calibrate properly a touch screen in Android that could guide me in this process?
Same here,
but my calibration app did't do anything.
After a while, reading /system/etc/init.sh i found the following:
mkdir -p /data/misc/tscal
touch /data/misc/tscal/pointercal
chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
chmod 775 /data/misc/tscal
chmod 664 /data/misc/tscal/pointercal
Just run those commands manually, reboot, and start the calibration app

Auto screen orientation changes with respect to time intervals

I wanted to rotate the screen orientations i.e from landscape -> patriot and vice verse for every 500 ms(This is on real device(not on emulator)).
Is there any shell command where we can rotate the current screen orientation? This is not corresponding to any of the app. I just want to rotate the screen in all available directions with irrespective to current activity
I've checked with adb shell to change the screen to landscape:
service call window 18 i32 1
change the screen to portrait:
service call window 18 i32 0
But these are not working on real device.. Can any one please provide a better solution to do this, would really helpful for me.
Atleast share/point me to any available scripts/apks that will do this auto orientations.
Thanks in advance
Well adb shell is still a shell (if a bit cut down)
You can do this:
sw=1;
while true; do
[[ "$sw" = 1 ]] && sw=0 || sw=1;
service call window 18 i32 $sw;
sleep 1
done;
And this is the one line version of it (in case you can not write it in file)
sw=1; while true; do [[ "$sw" = 1 ]] && sw=0 || sw=1; service call window 18 i32 $sw; sleep 1; done;
This will switch orientation every second (I don't think sleep works with less than seconds)
I came across the same problem, and found a solution in here.
briefly, that's what you have to do:
First disable the auto rotation by using the following command:
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
and to rotate:
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:x
for landscape replace x (in the end of the line) with 1 and for portrait with 0, and the code from the previous comment should work just fine :)

How to get the Android device screen size from the adb command line?

I need a way to detect device screen size and density with adb.
If there is no solution, where can I get the complete list of all existing android device with their screen size and density ?
You can also access the WindowManager through ADB:
$ adb shell wm
usage: wm [subcommand] [options]
wm size [reset|WxH]
wm density [reset|DENSITY]
wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]
To get the screen resolution:
$ adb shell wm size
Physical size: 2880x1600
To get the screen the density:
$ adb shell wm density
Physical density: 320
You can also override the density by adding the new density:
$ adb shell wm density 160
LCD density is in the build.prop:
adb shell getprop ro.sf.lcd_density
And the resolution is availble in the dumpsys of the input activity:
# windows
adb shell dumpsys window | find "DisplayWidth"
# linux
adb shell dumpsys window | grep DisplayWidth
It works on all the devices I've tested with (2.2, 2.3.3, 2.3.4, 4.0.3; Acer Liquid E, HTC Wildfire S, HTC Incredible S, Motorola Atrix 4G, Samsung Galaxy Note, Samsung Galaxy Nexus), as well as the emulator, although the emulator's outputs are too clean to serve as a good example for parsing.
Using dumpsys
dumpsys window displays
shows something like this:
Display: mDisplayId=0
init=1080x1920 480dpi cur=1080x1920 app=1080x1920 rng=1080x1005-1920x1845
layoutNeeded=false
another way:
dumpsys display
also shows some interesting stuff like:
mDefaultViewport=DisplayViewport{valid=true, displayId=0, orientation=0, logicalFrame=Rect(0, 0 - 1080, 1920), physicalFrame=Rect(0, 0 - 1080, 1920), deviceWidth=1080, deviceHeight=1920}
and last but not least:
dumpsys power
will display something like
Electron Beam State:
mPrepared=false
mMode=2
mDisplayLayerStack=0
mDisplayWidth=1080
mDisplayHeight=1920
mSurfaceVisible=false
mSurfaceAlpha=0.0
that you could easily use to grep for mDisplayWidth and mDisplayHeight
To get required info from ADB, the following command executed from the command line will return a lot of useful properties about the connected devices
> adb shell getprop
To filter through these properties
on Unix use grep like
> adb shell getprop | grep density
on Windows use find like
> adb shell getprop | findstr "density"
Returned value looks like
[ro.sf.lcd_density]: [240]
for screen size put display instead of density
Work is Good:
dumpsys window | grep Display
return: Display: init=320x480 cur=320x480 app=320x480 rng=320x295-480x455
ANDROID:/ # dumpsys window | grep mGlobalConfiguration
mGlobalConfiguration={1.0 ?mcc?mnc [en_US] ldltr sw720dp w1920dp h532dp 160dpi
So resolution is 1920x720
You can get screen dimensions with this code:
public int getScreenHeight() {
return getDisplay().getHeight();
}
private Display getDisplay() {
return ((WindowManager) getContext().getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay();
}
public int getScreenWidth() {
return getDisplay().getWidth();
}
Once you have the Display in the code above you can use DisplayMetrics to get the density. DisplayMetrics will also give you absolute display with and height.
Look at the output of adb shell dumpsys. The screen size shows up there several times, along with lots of other information.
... although now I'm in the office, while it works on my phone, it's absent from the Galaxy tablet. Darn.
If you need to get the current status of range of Android device available in the market with it Screen Sizes and Densities Click here
This data is based on the number of Android devices that have accessed Android Market within a 7-day period ending on the data collection date

Categories

Resources