Weather that permission denying actually blocks accelerometer access to the app or simply stops it being associated with your profile is beyond me.
At least on Pixel I cannot deny 'Google Play Services' from access Physical Activity so it seems like a feel good permission and they still grab whatever data they want.
Perhaps someone working in Maps can answer that?
The microcontroller OS code lives here: https://android.googlesource.com/device/google/contexthub/+/... It supports loading binary "micro-apps" (with optional encryption and/or signing) and provides them an API to use to gain sensor data access. Sensor drivers are also loaded as micro-apps. As is the "communicate with the main android CPU" code. It is also a micro-app. The OS itself is little more than an event loop, some power management, timer provider, and the loader of micro-apps in a particular format.
Activity detection is one of such micro-apps and is, as far as I know, not itself open source.
Source: I was the TL for this project back in the day