Merge "Avoid compacting when app has foreground activities" into tm-dev