Add --custom-package to aapt

This is needed to add library support to the SDK.

The goal is to have libraries and main project use the same
package for the R/Manifest classes to that they can share code
and resources.

BUG 2293994

Change-Id: Ie4cdb5a3bdabe1760a91316fd8969e4f53344bf9
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 1a536d6..0ef5d55 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1151,7 +1151,12 @@
 
     // Write out R.java constants
     if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
-        err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
+        if (bundle->getCustomPackage() == NULL) {
+            err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
+        } else {
+            const String8 customPkg(bundle->getCustomPackage());
+            err = writeResourceSymbols(bundle, assets, customPkg, true);
+        }
         if (err < 0) {
             goto bail;
         }