Enabling Mock Locations in Android on Chrome OS

On a Chromebook in Developer Mode, it appears to be possible to successfully enable mock locations for Android via the command prompt. I tested the method in Terminal Emulator (which requires root in Android), but it should also be possible to do in the Chrome OS shell via adb.

In Developer mode, with adb debugging switched on in the Android Developer options, if we connect to Android via adb in the Chrome OS shell
sudo su -
adb connect 100.115.92.2
We can then switch on mock locations via adb
adb shell settings put secure mock_location 1
If a suitable fake location Android app (e.g. https://play.google.com/store/apps/details?id=com.lexa.fakegps) is installed on the device, this can be set as the default mock locations app
adb shell appops set com.lexa.fakegps android:mock_location allow  
To set a different app as the mock locations app, change the package name/App ID (com.lexa.fakegps in the example above) to the appropriate package name (as shown on the app's Play Store URL).

After setting Fake GPS as the mock locations app, I was able to select my mock location in Fake GPS and e.g. Maps in Opera would successfully show the mock location, rather than my current location. I haven't really tested in many other apps at this time. 

I understand that some Android apps may specifically check if mock locations are being used. For those apps, I imagine further steps would probably be required, such as perhaps installing (possibly a different app such as GPS JoyStick) as a system app. This, however, would require remaking the Android rootfs container as a R/W image. If this is required, the rooting script can be run, which, as part of the rooting process, replaces the Android read-only rootfs with a R/W copy.