[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/link/ManifestFixer.cpp b/tools/aapt2/link/ManifestFixer.cpp
index 0b16e2c..b56b4c4 100644
--- a/tools/aapt2/link/ManifestFixer.cpp
+++ b/tools/aapt2/link/ManifestFixer.cpp
@@ -487,6 +487,16 @@
       }
     }
 
+    if (options_.non_updatable_system) {
+      if (el->FindAttribute(xml::kSchemaAndroid, "versionCode") == nullptr) {
+        el->RemoveAttribute("", "updatableSystem");
+        el->attributes.push_back(xml::Attribute{"", "updatableSystem", "false"});
+      } else {
+        diag->Note(android::DiagMessage(el->line_number)
+                   << "Ignoring --non-updatable-system because the manifest has a versionCode");
+      }
+    }
+
     return true;
   });