Below we can see how ASM's socket_connect hook behaves.
Every LSM hook implemented in ASM (e.g., socket_connect, kill_background_processes) follows the same logic seen in this image. The dashed boxes represent the modules that differ between hooks, i.e., for the kill_background_processes hook we would have asm_kill_background_processes(…) instead of asm_socket_create(…) in the asm_lsm.c file, and kill_background_processes(…) instead of socket_create(…) in the ASMService class.
asm-lsm.c - /kernel/goldfish/security/asmlsm/asm_lsm.c
asm-iface.c - /kernel/goldfish/security/asmlsm/asm_iface.c
ASMService - /frameworks/base/services/java/com/android/server/ASMService.java
ASMDomainSocketInterface - /frameworks/base/services/java/asm/ASMDomainSocketInterface.java
ASMAsyncQueryTask - /frameworks/base/services/java/asm/ASMDomainSocketInterface.java