19

I've got adb access to my android phone.

So I know that I can override screen density and screen resolution with the am command provided with Android. That's great and dandy, I guess. But is there a way to grab those two numbers from the command line? I know the pm utility can do some information gathering, most notably pm list features to see if the Android device has wireless, bluetooth, gps, etc. pm doesn't seem to do much more information reporting than this, though.

It would be helpful to know what versions of Android that the command is supported for. Ideally I would like something that works on Android 2.2+ (Froyo), but taking something that only works from 4.0.3+ (Ice Cream Sandwich) is fine too. I would also like it if there was a way to figure this out without root access.

I know that it's possible to get the screen resolution and density programmatically, as described in this question.

3 Answers 3

17

the result and precise format of the dumpsys command depends on the hardware vendor (of graphics chipset/driver and handset itself) but you should be able to find that info in the adb shell dumpsys display output

3
  • 6
    So I could call adb shell dumpsys display | grep mBaseDisplayInfo to get the appropriate information? It seems to match up, on my nexus 7 dumpsys reports the density to be 213 and the resolution to be 800x1280. It also reports information on rotation and such, neat. I didn't know dumpsys existed, but it seems to report on a lot of useful information as noted here: stackoverflow.com/questions/11201659/… Apr 26, 2013 at 20:14
  • yes. the problem is that different phones could have a different format of this line
    – user23414
    Apr 26, 2013 at 20:16
  • adb shell dumpsys display | grep mRequestedMode Then adb shell dumpsys display | grep mMode={id= to get the modeinfo Jun 20, 2018 at 22:04
13

In Android versions equipped with wm tool, you can use the commands:

adb shell wm size      # shows the real size and current size
adb shell wm density   # shows the real density and current density

(Click image to enlarge)

IMG:

I've tested successfully on stock Android 5.x and 6.x. Since wm tool comes with Android 4.3.x and 4.4.x as well, the solution may work on them as well.

10
  • Note: yes, the question restricts to now archaic Android version but the problem seems relevant for just any Android version. I decided to bring information not covered in accepted answer.
    – Firelord
    May 13, 2016 at 6:20
  • Is this measurement in pixels? Apr 8, 2019 at 14:28
  • @IgorGanapolsky that I do not know.
    – Firelord
    Apr 8, 2019 at 15:38
  • 1
    @Tri Material Terminal Emulator. Link: play.google.com/store/apps/…
    – Firelord
    Mar 11, 2022 at 15:27
  • 1
    @james28909 I think you should ask this as a separate question. dumpsys in my device does not report density higher than what wm command does. // No problem. No need to call me Sir. :)
    – Firelord
    Aug 5, 2023 at 13:28
6

If display service isn't available in dumpsys, you may look for line ro.sf.lcd_density= into /system/build.prop. To get it from phone:

adb pull /system/build.prop
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .