I have doubts that a third-party Android app can act in a supervisory mode since Android is running as a guest container/VM in ChromeOS.
From: https://chromium.googlesource.com/chromiumos/docs/+/HEAD/containers_and_vms.md#Don_t-Android-apps-ARC_run-in-a-container-and-not-a-VM
Glossary
- ARC (App Runtime for Chrome): The old/deprecated method of running Android apps in a Chrome NaCl (Native Client) sandbox. Had random compatibility issues.
- ARC++ (Android Runtime for Chrome [plus plus]): The current method for booting Android in a container under Chrome OS.
- ARCVM (Android Runtime for Chrome in a VM): The latest method for booting Android under Chrome OS. Unlike ARC++, ARCVM runs Android inside crosvm.
Don't Android apps (ARC++) run in a container and not a VM?
While Android apps currently run in a container, eligible devices are migrating to running inside a VM.
For ARC++ container, we try to isolate them quite a bit (using namespaces, seccomp, alt syscall, SELinux, etc...), but at the end of the day, they have direct access to many syscalls and kernel interfaces, so a bug in there is reachable via code compiled with Android's NDK.
If Android apps are in a container, why can't users run code too?
We don't usually accept a low security bar in one place as a valid reason to lower the security bar everywhere. Instead, we want to constantly raise the security bar for all code.
For example, devices that support Android 11+ are being migrated from ARC++ in a container to ARCVM.
Are Android apps (ARC++) going away?
There are no plans to merge the two projects. We share/re-use a lot of the Chrome bridge code though, so it‘s not like we’re doing everything from scratch.
Don't VMs slow everything down?
It is certainly true that VMs add overhead when compared to running in only a container or directly in the system. However, in our tests, the overhead is negligble to the user experience, and well worth the strong gains in system security.
For more details, see the Security section in this doc.
As you can see, Android apps are isolated from ChromeOS, so any action like screen lock would have to be managed via existing ChromeOS APIs like Enterprise Management on Chrome OS or Google's Family Link
But what about a script that locks the screen inside of crosh?
I'm not sure if the script is running in ChromeOS developer mode or just running the default crosh environment to work. Either way the user is being explicit about such actions. To my knowledge Android has no explicit external facing APIs since it is within a container/VM.
Couldn't I write something using Android NDK to access the kernel to achieve my objective?
Possibly, provided you pass through all of the security layers as ARC++ is based on container technology, however as mentioned above, future versions will be within a VM.