Loading tools/aapt2/LoadedApk.cpp +37 −37 Original line number Diff line number Diff line Loading @@ -35,6 +35,43 @@ using ::std::unique_ptr; namespace aapt { static ApkFormat DetermineApkFormat(io::IFileCollection* apk) { if (apk->FindFile(kApkResourceTablePath) != nullptr) { return ApkFormat::kBinary; } else if (apk->FindFile(kProtoResourceTablePath) != nullptr) { return ApkFormat::kProto; } else { // If the resource table is not present, attempt to read the manifest. io::IFile* manifest_file = apk->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { return ApkFormat::kUnknown; } // First try in proto format. std::unique_ptr<io::InputStream> manifest_in = manifest_file->OpenInputStream(); if (manifest_in != nullptr) { pb::XmlNode pb_node; io::ProtoInputStreamReader proto_reader(manifest_in.get()); if (proto_reader.ReadMessage(&pb_node)) { return ApkFormat::kProto; } } // If it didn't work, try in binary format. std::unique_ptr<io::IData> manifest_data = manifest_file->OpenAsData(); if (manifest_data != nullptr) { std::string error; std::unique_ptr<xml::XmlResource> manifest = xml::Inflate(manifest_data->data(), manifest_data->size(), &error); if (manifest != nullptr) { return ApkFormat::kBinary; } } return ApkFormat::kUnknown; } } std::unique_ptr<LoadedApk> LoadedApk::LoadApkFromPath(const StringPiece& path, IDiagnostics* diag) { Source source(path); std::string error; Loading Loading @@ -301,41 +338,4 @@ std::unique_ptr<xml::XmlResource> LoadedApk::LoadXml(const std::string& file_pat return doc; } ApkFormat LoadedApk::DetermineApkFormat(io::IFileCollection* apk) { if (apk->FindFile(kApkResourceTablePath) != nullptr) { return ApkFormat::kBinary; } else if (apk->FindFile(kProtoResourceTablePath) != nullptr) { return ApkFormat::kProto; } else { // If the resource table is not present, attempt to read the manifest. io::IFile* manifest_file = apk->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { return ApkFormat::kUnknown; } // First try in proto format. std::unique_ptr<io::InputStream> manifest_in = manifest_file->OpenInputStream(); if (manifest_in != nullptr) { pb::XmlNode pb_node; io::ProtoInputStreamReader proto_reader(manifest_in.get()); if (!proto_reader.ReadMessage(&pb_node)) { return ApkFormat::kProto; } } // If it didn't work, try in binary format. std::unique_ptr<io::IData> manifest_data = manifest_file->OpenAsData(); if (manifest_data != nullptr) { std::string error; std::unique_ptr<xml::XmlResource> manifest = xml::Inflate(manifest_data->data(), manifest_data->size(), &error); if (manifest != nullptr) { return ApkFormat::kBinary; } } return ApkFormat::kUnknown; } } } // namespace aapt tools/aapt2/LoadedApk.h +0 −2 Original line number Diff line number Diff line Loading @@ -121,8 +121,6 @@ class LoadedApk { std::unique_ptr<ResourceTable> table_; std::unique_ptr<xml::XmlResource> manifest_; ApkFormat format_; static ApkFormat DetermineApkFormat(io::IFileCollection* apk); }; } // namespace aapt Loading Loading
tools/aapt2/LoadedApk.cpp +37 −37 Original line number Diff line number Diff line Loading @@ -35,6 +35,43 @@ using ::std::unique_ptr; namespace aapt { static ApkFormat DetermineApkFormat(io::IFileCollection* apk) { if (apk->FindFile(kApkResourceTablePath) != nullptr) { return ApkFormat::kBinary; } else if (apk->FindFile(kProtoResourceTablePath) != nullptr) { return ApkFormat::kProto; } else { // If the resource table is not present, attempt to read the manifest. io::IFile* manifest_file = apk->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { return ApkFormat::kUnknown; } // First try in proto format. std::unique_ptr<io::InputStream> manifest_in = manifest_file->OpenInputStream(); if (manifest_in != nullptr) { pb::XmlNode pb_node; io::ProtoInputStreamReader proto_reader(manifest_in.get()); if (proto_reader.ReadMessage(&pb_node)) { return ApkFormat::kProto; } } // If it didn't work, try in binary format. std::unique_ptr<io::IData> manifest_data = manifest_file->OpenAsData(); if (manifest_data != nullptr) { std::string error; std::unique_ptr<xml::XmlResource> manifest = xml::Inflate(manifest_data->data(), manifest_data->size(), &error); if (manifest != nullptr) { return ApkFormat::kBinary; } } return ApkFormat::kUnknown; } } std::unique_ptr<LoadedApk> LoadedApk::LoadApkFromPath(const StringPiece& path, IDiagnostics* diag) { Source source(path); std::string error; Loading Loading @@ -301,41 +338,4 @@ std::unique_ptr<xml::XmlResource> LoadedApk::LoadXml(const std::string& file_pat return doc; } ApkFormat LoadedApk::DetermineApkFormat(io::IFileCollection* apk) { if (apk->FindFile(kApkResourceTablePath) != nullptr) { return ApkFormat::kBinary; } else if (apk->FindFile(kProtoResourceTablePath) != nullptr) { return ApkFormat::kProto; } else { // If the resource table is not present, attempt to read the manifest. io::IFile* manifest_file = apk->FindFile(kAndroidManifestPath); if (manifest_file == nullptr) { return ApkFormat::kUnknown; } // First try in proto format. std::unique_ptr<io::InputStream> manifest_in = manifest_file->OpenInputStream(); if (manifest_in != nullptr) { pb::XmlNode pb_node; io::ProtoInputStreamReader proto_reader(manifest_in.get()); if (!proto_reader.ReadMessage(&pb_node)) { return ApkFormat::kProto; } } // If it didn't work, try in binary format. std::unique_ptr<io::IData> manifest_data = manifest_file->OpenAsData(); if (manifest_data != nullptr) { std::string error; std::unique_ptr<xml::XmlResource> manifest = xml::Inflate(manifest_data->data(), manifest_data->size(), &error); if (manifest != nullptr) { return ApkFormat::kBinary; } } return ApkFormat::kUnknown; } } } // namespace aapt
tools/aapt2/LoadedApk.h +0 −2 Original line number Diff line number Diff line Loading @@ -121,8 +121,6 @@ class LoadedApk { std::unique_ptr<ResourceTable> table_; std::unique_ptr<xml::XmlResource> manifest_; ApkFormat format_; static ApkFormat DetermineApkFormat(io::IFileCollection* apk); }; } // namespace aapt Loading