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.

Ehtesh Choudhury
  • 347
  • 1
  • 2
  • 10

3 Answers3

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

  • 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: http://stackoverflow.com/questions/11201659/android-adb-shell-dumpsys-tool – Ehtesh Choudhury Apr 26 '13 at 20:14
  • yes. the problem is that different phones could have a different format of this line –  Apr 26 '13 at 20:16
  • adb shell dumpsys display | grep mRequestedMode Then adb shell dumpsys display | grep mMode={id= to get the modeinfo – Lava Sangeetham Jun 20 '18 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.

Firelord
  • 25,084
  • 20
  • 124
  • 286
  • 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 '16 at 06:20
  • Is this measurement in pixels? – IgorGanapolsky Apr 08 '19 at 14:28
  • @IgorGanapolsky that I do not know. – Firelord Apr 08 '19 at 15:38
  • I know this is unrelated, but what terminal emulator are you using? – Tri Mar 11 '22 at 12:53
  • 1
    @Tri Material Terminal Emulator. Link: https://play.google.com/store/apps/details?id=yarolegovich.materialterminal&hl=en_US&gl=US – Firelord Mar 11 '22 at 15:27
  • @Firelord when using wm density, my phone reports the supported dpi is 420, but when using dumpsys display | grep dpi, it reports that the display dpi supported is 560. So i am confused on which is the correct reading or if wm density isn't actually dpi? So you know what's going on here? – james28909 Aug 03 '23 at 17:33
  • I am not to sure about these entries from getprop: ~ $ getprop | grep ro.sf [ro.sf.init.lcd_density]: [560] [ro.sf.lcd_density]: [420] guess i will Google it – james28909 Aug 03 '23 at 17:37
  • @james28909 In my OnePlus 6 (Android 11), wm density reports Physical density and Override density. Override density is what I (the user) has manually configured. Physical density is that the device came with. dumpsys display reports the same info as BaseDisplayInfo and OverrideDisplayInfo. I don't know about [ro.sf.init.lcd_density]. – Firelord Aug 05 '23 at 06:35
  • @Firelord yes sir, i understand what you mean. I were just wondering why dumpsys display | grep dpi reports a higher dpi than wm density. If you use termux or a terminal emulator, try that dumpster command and you will see what i mean. I also wonder what the property [ro.sf.init.lcd_density]: is, or what it controls. My Googlefu could not find anything informative about this property. Also, thanks for responding :) – james28909 Aug 05 '23 at 11:04
  • 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 05 '23 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
janot
  • 555
  • 3
  • 9
  • 25