AAPT2: Change how we generate Java classes

Previously we would be writing out the Manifest.java file as we
processed the AndroidManifest.xml. This would lead to empty
Manifest classes if there were no permissions or permission groups
defined in the AndroidManifest.xml.

This would pose problems for processes that checked for public classes
and considered them part of the API (support lib).

Now we collect the structure of the Java class in memory before deciding
if a file should be created.

Change-Id: I6b909f28d74356414c6ef5ad005180d6ea5e44ca
This commit is contained in:
Adam Lesinski
2016-03-31 13:33:02 -07:00
parent becc30196d
commit 6cbfb1de49
12 changed files with 459 additions and 303 deletions

View File

@@ -28,7 +28,7 @@
namespace aapt {
class AnnotationProcessor;
class ClassDefinitionWriter;
class ClassDefinition;
struct JavaClassGeneratorOptions {
/*
@@ -70,16 +70,15 @@ public:
const std::string& getError() const;
private:
bool writeEntriesForClass(ClassDefinitionWriter* outClassDef,
const StringPiece16& packageNameToGenerate,
const ResourceTablePackage* package,
const ResourceTableType* type);
bool addMembersToTypeClass(const StringPiece16& packageNameToGenerate,
const ResourceTablePackage* package,
const ResourceTableType* type,
ClassDefinition* outTypeClassDef);
void writeStyleableEntryForClass(ClassDefinitionWriter* outClassDef,
AnnotationProcessor* processor,
const StringPiece16& packageNameToGenerate,
const std::u16string& entryName,
const Styleable* styleable);
void addMembersToStyleableClass(const StringPiece16& packageNameToGenerate,
const std::u16string& entryName,
const Styleable* styleable,
ClassDefinition* outStyleableClassDef);
bool skipSymbol(SymbolState state);