Optimize checkDuplicatedVersions

Previously, the checkDuplicatedVersions mutator visited a node multiple
times. When the mutator is running for a module, the mutator visited all
of the transitive depmendencies of the module. As a result, modules that
are at the bottom of the dependency tree were visited a lot of times.

This change optimizes the behavior; now, each module visited only once.
When the mutator is running for a module, it gathers AIDL interface
modules that the module directly depends on. If there is any, the info
is recorded and is used in the later runs of the mutator.

Bug: 160855603
Test: measure the time spent for running the mutator by inserting some
time check routines around the runMutator function in blueprint.
1680ms -> 330ms in AOSP/aosp_arm64 target
Change-Id: Ib9b583a0ce01cd858652d0de650ca76c18c5b9cf
2 files changed