Loading tools/aapt2/LoadedApk.cpp +36 −39 Original line number Diff line number Diff line Loading @@ -57,19 +57,17 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadApkFromPath(const StringPiece& path, I std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( const Source& source, unique_ptr<io::IFileCollection> collection, IDiagnostics* diag) { io::IFile* table_file = collection->FindFile(kProtoResourceTablePath); if (table_file == nullptr) { diag->Error(DiagMessage(source) << "failed to find " << kProtoResourceTablePath); return {}; } std::unique_ptr<ResourceTable> table; io::IFile* table_file = collection->FindFile(kProtoResourceTablePath); if (table_file != nullptr) { pb::ResourceTable pb_table; std::unique_ptr<io::InputStream> in = table_file->OpenInputStream(); if (in == nullptr) { diag->Error(DiagMessage(source) << "failed to open " << kProtoResourceTablePath); return {}; } pb::ResourceTable pb_table; io::ZeroCopyInputAdaptor adaptor(in.get()); if (!pb_table.ParseFromZeroCopyStream(&adaptor)) { diag->Error(DiagMessage(source) << "failed to read " << kProtoResourceTablePath); Loading @@ -77,12 +75,13 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( } std::string error; std::unique_ptr<ResourceTable> table = util::make_unique<ResourceTable>(); table = util::make_unique<ResourceTable>(); if (!DeserializeTableFromPb(pb_table, collection.get(), table.get(), &error)) { diag->Error(DiagMessage(source) << "failed to deserialize " << kProtoResourceTablePath << ": " << error); return {}; } } io::IFile* manifest_file = collection->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { Loading @@ -103,6 +102,7 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( return {}; } std::string error; std::unique_ptr<xml::XmlResource> manifest = DeserializeXmlResourceFromPb(pb_node, &error); if (manifest == nullptr) { diag->Error(DiagMessage(source) Loading @@ -115,25 +115,22 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( std::unique_ptr<LoadedApk> LoadedApk::LoadBinaryApkFromFileCollection( const Source& source, unique_ptr<io::IFileCollection> collection, IDiagnostics* diag) { io::IFile* table_file = collection->FindFile(kApkResourceTablePath); if (table_file == nullptr) { diag->Error(DiagMessage(source) << "failed to find " << kApkResourceTablePath); return {}; } std::unique_ptr<ResourceTable> table; io::IFile* table_file = collection->FindFile(kApkResourceTablePath); if (table_file != nullptr) { table = util::make_unique<ResourceTable>(); std::unique_ptr<io::IData> data = table_file->OpenAsData(); if (data == nullptr) { diag->Error(DiagMessage(source) << "failed to open " << kApkResourceTablePath); return {}; } std::unique_ptr<ResourceTable> table = util::make_unique<ResourceTable>(); BinaryResourceParser parser(diag, table.get(), source, data->data(), data->size(), collection.get()); if (!parser.Parse()) { return {}; } } io::IFile* manifest_file = collection->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { Loading tools/aapt2/cmd/Convert.cpp +31 −29 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ bool ConvertApk(IAaptContext* context, unique_ptr<LoadedApk> apk, IApkSerializer return false; } if (apk->GetResourceTable() != nullptr) { // Resource table if (!serializer->SerializeTable(apk->GetResourceTable(), writer)) { context->GetDiagnostics()->Error(DiagMessage(apk->GetSource()) Loading Loading @@ -94,6 +95,7 @@ bool ConvertApk(IAaptContext* context, unique_ptr<LoadedApk> apk, IApkSerializer } // entry } // type } // package } // Other files std::unique_ptr<io::IFileCollectionIterator> iterator = apk->GetFileCollection()->Iterator(); Loading Loading
tools/aapt2/LoadedApk.cpp +36 −39 Original line number Diff line number Diff line Loading @@ -57,19 +57,17 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadApkFromPath(const StringPiece& path, I std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( const Source& source, unique_ptr<io::IFileCollection> collection, IDiagnostics* diag) { io::IFile* table_file = collection->FindFile(kProtoResourceTablePath); if (table_file == nullptr) { diag->Error(DiagMessage(source) << "failed to find " << kProtoResourceTablePath); return {}; } std::unique_ptr<ResourceTable> table; io::IFile* table_file = collection->FindFile(kProtoResourceTablePath); if (table_file != nullptr) { pb::ResourceTable pb_table; std::unique_ptr<io::InputStream> in = table_file->OpenInputStream(); if (in == nullptr) { diag->Error(DiagMessage(source) << "failed to open " << kProtoResourceTablePath); return {}; } pb::ResourceTable pb_table; io::ZeroCopyInputAdaptor adaptor(in.get()); if (!pb_table.ParseFromZeroCopyStream(&adaptor)) { diag->Error(DiagMessage(source) << "failed to read " << kProtoResourceTablePath); Loading @@ -77,12 +75,13 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( } std::string error; std::unique_ptr<ResourceTable> table = util::make_unique<ResourceTable>(); table = util::make_unique<ResourceTable>(); if (!DeserializeTableFromPb(pb_table, collection.get(), table.get(), &error)) { diag->Error(DiagMessage(source) << "failed to deserialize " << kProtoResourceTablePath << ": " << error); return {}; } } io::IFile* manifest_file = collection->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { Loading @@ -103,6 +102,7 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( return {}; } std::string error; std::unique_ptr<xml::XmlResource> manifest = DeserializeXmlResourceFromPb(pb_node, &error); if (manifest == nullptr) { diag->Error(DiagMessage(source) Loading @@ -115,25 +115,22 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadProtoApkFromFileCollection( std::unique_ptr<LoadedApk> LoadedApk::LoadBinaryApkFromFileCollection( const Source& source, unique_ptr<io::IFileCollection> collection, IDiagnostics* diag) { io::IFile* table_file = collection->FindFile(kApkResourceTablePath); if (table_file == nullptr) { diag->Error(DiagMessage(source) << "failed to find " << kApkResourceTablePath); return {}; } std::unique_ptr<ResourceTable> table; io::IFile* table_file = collection->FindFile(kApkResourceTablePath); if (table_file != nullptr) { table = util::make_unique<ResourceTable>(); std::unique_ptr<io::IData> data = table_file->OpenAsData(); if (data == nullptr) { diag->Error(DiagMessage(source) << "failed to open " << kApkResourceTablePath); return {}; } std::unique_ptr<ResourceTable> table = util::make_unique<ResourceTable>(); BinaryResourceParser parser(diag, table.get(), source, data->data(), data->size(), collection.get()); if (!parser.Parse()) { return {}; } } io::IFile* manifest_file = collection->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { Loading
tools/aapt2/cmd/Convert.cpp +31 −29 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ bool ConvertApk(IAaptContext* context, unique_ptr<LoadedApk> apk, IApkSerializer return false; } if (apk->GetResourceTable() != nullptr) { // Resource table if (!serializer->SerializeTable(apk->GetResourceTable(), writer)) { context->GetDiagnostics()->Error(DiagMessage(apk->GetSource()) Loading Loading @@ -94,6 +95,7 @@ bool ConvertApk(IAaptContext* context, unique_ptr<LoadedApk> apk, IApkSerializer } // entry } // type } // package } // Other files std::unique_ptr<io::IFileCollectionIterator> iterator = apk->GetFileCollection()->Iterator(); Loading