Imported type is preferred to preprocessed type

This change fixes a corner case bug that an imported type isn't
preferred to the preprocessed type when the type is already defined in
the preprocessed file. Consider following example:

android.aidl:
parcelable aaa.bbb.Data;
parcelable xxx.yyy.Data;

include/xxx/yyy/Data.aidl:
package xxx.yyy;
parcelable Data;

src/my/IFoo.aidl:
package my;
import xxx.yyy.Data;
interface IFoo { void foo(in Data d); }

When the aidl compiler invoked with the following arguments

aidl -p android.aidl -I include -o out src/my/IFoo.aidl

the type reference `Data` for the `foo` method was incorrectly resolved
to aaa.bbb.Data even when xxx.yyy.Data was explicitly imported. This was
happening because we didn't import a file when the type was found in the
preprocessed file. Then later we queried the unresolved reference `Data'
to the preprocessed file, we get aaa.bbb.Data because it is
alphabetically before xxx.yyy.Data.

Fixing this bug by not ignoring the import for if the type is just from
the preprocessed file (i.e. do ignoring the import only when the type
was already imported explicitly).

This change also fixes a bug that unresolved types can be imported prior
to the fully qualified imports. It could happen because they were all
put together in a set. Now they are stored in a vector.

Bug: 147918827
Test: aidl_unittests. a new unittest was added and it fails when run
without the change.

Change-Id: I10260e92f50f5f7b64da99284c25b13459e063ad
6 files changed