External Portrait Android Modification

I wanted to get a device to display digital sheet music and started looking online to see what options were available. It seems most people choose to use a tablet for this purpose, but ones large enough for sheet music are rather expensive and (in my personal experience) tablets age poorly. A portable monitor seemed like it might be a better alternative since I already had a Raspberry Pi, Steam Deck, and a few other devices that could be used with it. So I spent a little over $100 for a 15 inch monitor with touch capability.

I decided to use my previous Android phone in an effort to reduce waste. The screen was cracked from being bent halfway but the phone itself still functions well and has the benefit of supporting HDMI-out. Once I connected the two everything worked as I had hoped... in landscape mode. For some reason swapping to portrait would only show the phone's portrait display in the monitor's landscape orientation:

Image of monitor displaying the homescreen in the wrong orientaion, letterboxed

No combination of settings on the phone or display could solve this issue. Looking online I found that I'm not the only one that has encountered this problem and there were many answers stating that the solution is to set persist.demo.hdmirotation to portrait!

Unfortunately it turns out that property no longer exists on versions after Android 10. After searching through the code I found ro.surface_flinger.primary_display_orientation, which ended up not helping either. Since I had already been making my own builds of LineageOS for that phone as well as my current one, I decided to go a bit further and make a simple change to a hardcoded value:

--- a/frameworks/base/services/core/java/com/android/server/display/LogicalDisplay.java
+++ b/frameworks/base/services/core/java/com/android/server/display/LogicalDisplay.java
@@ -402,7 +402,7 @@
         // Set the orientation.
         // The orientation specifies how the physical coordinate system of the display
         // is rotated when the contents of the logical display are rendered.
-        int orientation = Surface.ROTATION_0;
+        int orientation = Surface.ROTATION_270;
         if ((displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0) {
             orientation = displayInfo.rotation;
         }

Which finally solved the issue:

Image of monitor displaying the homescreen with the correct orientaion

I designed and 3d-printed a stand to mount the monitor to my ES100. It works well enough but could use a third leg for better stability. The openscad file is available here if you happen to find that useful!

Image of monitor mounted to piano

I created a shortcut to a termux script that sets a higher density and disables the display & touch input on the phone itself:

#!/bin/sh

su -c 'wm density 200'
su -c 'echo 0 > /sys/class/leds/lcd-backlight/brightness'
su -c 'echo 0 > /sys/class/leds/lcd-backlight-ex/brightness'
su -c 'rm -rf /dev/input/event1'
Image of mounted monitor displaying sheet music


RSS feed