Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1553c82e authored by Joe Onorato's avatar Joe Onorato
Browse files

Add a flag (-G) to aapt to have it output the classes that shouldn't be obfuscated by ProGuard.

parent b0a05404
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1819,6 +1819,19 @@ void AaptAssets::print() const
    AaptDir::print();
}

sp<AaptDir> AaptAssets::resDir(const String8& name)
{
    const Vector<sp<AaptDir> >& dirs = mDirs;
    const size_t N = dirs.size();
    for (size_t i=0; i<N; i++) {
        const sp<AaptDir>& d = dirs.itemAt(i);
        if (d->getLeaf() == name) {
            return d;
        }
    }
    return NULL;
}

bool
valid_symbol_name(const String8& symbol)
{
+1 −0
Original line number Diff line number Diff line
@@ -508,6 +508,7 @@ public:
    void print() const;

    inline const Vector<sp<AaptDir> >& resDirs() { return mDirs; }
    sp<AaptDir> resDir(const String8& name);

    inline sp<AaptAssets> getOverlay() { return mOverlay; }
    inline void setOverlay(sp<AaptAssets>& overlay) { mOverlay = overlay; }
+4 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public:
          mRequireLocalization(false), mPseudolocalize(false),
          mValues(false),
          mCompressionMethod(0), mOutputAPKFile(NULL),
          mAssetSourceDir(NULL),
          mAssetSourceDir(NULL), mProguardFile(NULL),
          mAndroidManifestFile(NULL), mPublicOutputFile(NULL),
          mRClassDir(NULL), mResourceIntermediatesDir(NULL),
          mMinSdkVersion(NULL), mTargetSdkVersion(NULL), mMaxSdkVersion(NULL),
@@ -88,6 +88,8 @@ public:
     */
    const char* getAssetSourceDir() const { return mAssetSourceDir; }
    void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; }
    const char* getProguardFile() const { return mProguardFile; }
    void setProguardFile(const char* file) { mProguardFile = file; }
    const android::Vector<const char*>& getResourceSourceDirs() const { return mResourceSourceDirs; }
    void addResourceSourceDir(const char* dir) { mResourceSourceDirs.insertAt(dir,0); }
    const char* getAndroidManifestFile() const { return mAndroidManifestFile; }
@@ -161,6 +163,7 @@ private:
    int         mCompressionMethod;
    const char* mOutputAPKFile;
    const char* mAssetSourceDir;
    const char* mProguardFile;
    const char* mAndroidManifestFile;
    const char* mPublicOutputFile;
    const char* mRClassDir;
+7 −1
Original line number Diff line number Diff line
@@ -233,7 +233,7 @@ static ssize_t indexOfAttribute(const ResXMLTree& tree, uint32_t attrRes)
    return -1;
}

static String8 getAttribute(const ResXMLTree& tree, const char* ns,
String8 getAttribute(const ResXMLTree& tree, const char* ns,
                            const char* attr, String8* outError)
{
    ssize_t idx = tree.indexOfAttribute(ns, attr);
@@ -1158,6 +1158,12 @@ int doPackage(Bundle* bundle)
        }
    }

    // Write out the ProGuard file
    err = writeProguardFile(bundle, assets);
    if (err < 0) {
        goto bail;
    }

    // Write the apk
    if (outputAPKFile) {
        err = writeAPK(bundle, assets, String8(outputAPKFile));
+14 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ void usage(void)
        "        [--max-sdk-version VAL] [--app-version VAL] \\\n"
        "        [--app-version-name TEXT]\\\n"
        "        [-I base-package [-I base-package ...]] \\\n"
        "        [-A asset-source-dir] [-P public-definitions-file] \\\n"
        "        [-A asset-source-dir]  [-G class-list-file] [-P public-definitions-file] \\\n"
        "        [-S resource-sources [-S resource-sources ...]] "
        "        [-F apk-file] [-J R-file-dir] \\\n"
        "        [raw-files-dir [raw-files-dir] ...]\n"
@@ -109,6 +109,7 @@ void usage(void)
        "   -z  require localization of resource attributes marked with\n"
        "       localization=\"suggested\"\n"
        "   -A  additional directory in which to find raw asset files\n"
        "   -G  A file to output proguard options into.\n"
        "   -F  specify the apk file to output\n"
        "   -I  add an existing package to base include set\n"
        "   -J  specify where to output R.java resource constant definitions\n"
@@ -274,6 +275,17 @@ int main(int argc, char* const argv[])
                convertPath(argv[0]);
                bundle.setAssetSourceDir(argv[0]);
                break;
            case 'G':
                argc--;
                argv++;
                if (!argc) {
                    fprintf(stderr, "ERROR: No argument supplied for '-G' option\n");
                    wantUsage = true;
                    goto bail;
                }
                convertPath(argv[0]);
                bundle.setProguardFile(argv[0]);
                break;
            case 'I':
                argc--;
                argv++;
Loading