When you modified implementation (not interface!) of a Java function in "frameworks" directory, all .apks (e.g., Email.apk) were rebuilt.
I introduced .KATI_RESTAT pseudo-target to kati and Android.mk so they use ninja's "restat" feature, which was designed to solve this issue (probably for .so files in Chromium).
$ m && touch \ frameworks/base/core/java/com/google/android/util/Procedure.java \ && time m Before: 3m48s After: 1m46s $ m && touch bionic/libc/stdio/stdio.c && time m Before: 1m03s (2563 targets) After: 21s (90 targets)