summaryrefslogtreecommitdiff
path: root/startop/view_compiler/apk_layout_compiler.cc
diff options
context:
space:
mode:
authorEric Holk <eholk@google.com>2019-01-15 10:03:46 -0800
committerEric Holk <eholk@google.com>2019-01-15 10:03:46 -0800
commit0e0e7dde92e2ca9cba3e119111563c4f4f20ccfc (patch)
tree7f995cfe8abc37afe5c0713cf57f14d0a24edc64 /startop/view_compiler/apk_layout_compiler.cc
parent6f37294f4caf3af7fc88f4bd70bf90e52bc27214 (diff)
[viewcompiler] Enable input from file descriptor
This is needed to be able to launch the viewcompiler from installd. We only support FD-input mode when reading from APKs. For output to an FD, we rely on stdout redirection. Bug: 111895153 Change-Id: I3025d83c60494485bada5f2f4cd67e25354d1d53
Diffstat (limited to 'startop/view_compiler/apk_layout_compiler.cc')
-rw-r--r--startop/view_compiler/apk_layout_compiler.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/startop/view_compiler/apk_layout_compiler.cc b/startop/view_compiler/apk_layout_compiler.cc
index e95041ba34a4..09cdbd5fee58 100644
--- a/startop/view_compiler/apk_layout_compiler.cc
+++ b/startop/view_compiler/apk_layout_compiler.cc
@@ -79,9 +79,9 @@ bool CanCompileLayout(ResXMLParser* parser) {
return visitor.can_compile();
}
-void CompileApkLayouts(const std::string& filename, CompilationTarget target,
- std::ostream& target_out) {
- auto assets = android::ApkAssets::Load(filename);
+namespace {
+void CompileApkAssetsLayouts(const std::unique_ptr<const android::ApkAssets>& assets,
+ CompilationTarget target, std::ostream& target_out) {
android::AssetManager2 resources;
resources.SetApkAssets({assets.get()});
@@ -155,5 +155,20 @@ void CompileApkLayouts(const std::string& filename, CompilationTarget target,
target_out.write(image.ptr<const char>(), image.size());
}
}
+} // namespace
+
+void CompileApkLayouts(const std::string& filename, CompilationTarget target,
+ std::ostream& target_out) {
+ auto assets = android::ApkAssets::Load(filename);
+ CompileApkAssetsLayouts(assets, target, target_out);
+}
+
+void CompileApkLayoutsFd(android::base::unique_fd fd, CompilationTarget target,
+ std::ostream& target_out) {
+ constexpr const char* friendly_name{"viewcompiler assets"};
+ auto assets = android::ApkAssets::LoadFromFd(
+ std::move(fd), friendly_name, /*system=*/false, /*force_shared_lib=*/false);
+ CompileApkAssetsLayouts(assets, target, target_out);
+}
} // namespace startop