[aapt2] Add --non-updatable-system flag
This adds `updatableSystem="false"` to the root <manifest> tag if no
versionCode is specified (either explicitly or through --version-code).
This attribute makes the APK not updatable (see b/266131956).
Bug: 328302305
Test: atest aapt2_tests
Test: Manually ran `aapt2 link --non-updatable-system` and verified the
resulting APK.
Change-Id: I51cdbcdac7c03de10aac9bc22f5081e12fa142ab
diff --git a/tools/aapt2/cmd/Link.h b/tools/aapt2/cmd/Link.h
index dc18b1c..8fe414f 100644
--- a/tools/aapt2/cmd/Link.h
+++ b/tools/aapt2/cmd/Link.h
@@ -335,6 +335,11 @@
"are separated by ',' and the name is separated from the value by '='.\n"
"Example: \"flag1=true,flag2=false,flag3=\" (flag3 has no given value).",
&feature_flags_args_);
+ AddOptionalSwitch("--non-updatable-system",
+ "Mark the app as a non-updatable system app. This inserts\n"
+ "updatableSystem=\"false\" to the root manifest node, overwriting any\n"
+ "existing attribute. This is ignored if the manifest has a versionCode.",
+ &options_.manifest_fixer_options.non_updatable_system);
}
int Action(const std::vector<std::string>& args) override;