Filter products during compile phase

Unfortunately there is no good way to deal with products in the link phase.
Products are like preprocessor defines in that they are processed early
and change the composition of the compiled unit.

Change-Id: I6d5e15ef60d29df8e83e059ba857c09333993779
diff --git a/tools/aapt2/link/Link.cpp b/tools/aapt2/link/Link.cpp
index 2b4c4d2..fa321a0 100644
--- a/tools/aapt2/link/Link.cpp
+++ b/tools/aapt2/link/Link.cpp
@@ -52,6 +52,7 @@
     bool staticLib = false;
     bool verbose = false;
     bool outputToDirectory = false;
+    Maybe<std::string> privateSymbols;
 };
 
 struct LinkContext : public IAaptContext {
@@ -400,7 +401,13 @@
 
         mContext.mNameMangler = util::make_unique<NameMangler>(
                 NameManglerPolicy{ mContext.mCompilationPackage });
-        mContext.mPackageId = 0x7f;
+
+        if (mContext.mCompilationPackage == u"android") {
+            mContext.mPackageId = 0x01;
+        } else {
+            mContext.mPackageId = 0x7f;
+        }
+
         mContext.mSymbols = createSymbolTableFromIncludePaths();
         if (!mContext.mSymbols) {
             return 1;
@@ -689,6 +696,9 @@
                             "by -o",
                             &options.outputToDirectory)
             .optionalSwitch("--static-lib", "Generate a static Android library", &options.staticLib)
+            .optionalFlag("--private-symbols", "Package name to use when generating R.java for "
+                          "private symbols. If not specified, public and private symbols will "
+                          "use the application's package name", &options.privateSymbols)
             .optionalSwitch("-v", "Enables verbose logging", &options.verbose);
 
     if (!flags.parse("aapt2 link", args, &std::cerr)) {