Testing Your Android Apps for Chromebooks - When You Don't Have One

While I don't have a Chromebook, I recently bought a Samsung Dex, which for those of you who aren't aware of what that is, it basically allows you to take your Samsung phone, dock it, connect a mouse, keyboard, and external monitor, and use the phone as if it were a desktop computer. Seeing as I still actively develop and use Simple Markdown, I wanted to take a look at how I could make it compatible with Dex so that I could give it a go. Much to my surprise, Android emulators have the multi-window functionality built-in. Samsung has provided us with a neat little guide to take a standard emulator and convert it for desktop use, but I'll give you the quick points below.

Create an emulator based on the Nexus 6P running Android Nougat. Ensure that you have adb on your PATH, and open up the terminal. Run the following:

adb shell

This will drop you into the terminal session for your emulator, where you'll run the following commands:

su
setenforce 0
settings put global enable_freeform_support 1
cd /data/local/tmp
mkdir permissions && cd permissions
cp -a /system/etc/permissions/* ./
sed -e "s/live_wallpaper/freeform_window_management/" android.software.live_wallpaper.xml > freeform.xml
mount --bind . /system/etc/permissions
stop
start
reboot

Once the emulator reboots, run your app. Tap the Recent Apps button and you should notice a new icon next to the close button.

Tap that, and your app should launch in freeform mode. Last but not least, you'll need to adjust the view density to get the resolution closer to that of a Chromebook (or Dex). Rotate the emulator into landscape mode and run adb shell to get into the device's terminal again. From there, run the following:

wm density 160
wm size 1080x1920

Now, you should be looking at your app as if it were running on a Chromebook! Interestingly enough, I was able to replicate a bug that was plaguing some of my Chromebook users that occurred by resizing the window. Here's a screenshot of Simple Markdown in action: