| 2584 | } |
| 2585 | |
| 2586 | status_t |
| 2587 | writeProguardFile(Bundle* bundle, const sp<AaptAssets>& assets) |
| 2588 | { |
| 2589 | status_t err = -1; |
| 2590 | |
| 2591 | if (!bundle->getProguardFile()) { |
| 2592 | return NO_ERROR; |
| 2593 | } |
| 2594 | |
| 2595 | ProguardKeepSet keep; |
| 2596 | |
| 2597 | err = writeProguardForAndroidManifest(&keep, assets); |
| 2598 | if (err < 0) { |
| 2599 | return err; |
| 2600 | } |
| 2601 | |
| 2602 | err = writeProguardForLayouts(&keep, assets); |
| 2603 | if (err < 0) { |
| 2604 | return err; |
| 2605 | } |
| 2606 | |
| 2607 | FILE* fp = fopen(bundle->getProguardFile(), "w+"); |
| 2608 | if (fp == NULL) { |
| 2609 | fprintf(stderr, "ERROR: Unable to open class file %s: %s\n", |
| 2610 | bundle->getProguardFile(), strerror(errno)); |
| 2611 | return UNKNOWN_ERROR; |
| 2612 | } |
| 2613 | |
| 2614 | const KeyedVector<String8, SortedVector<String8> >& rules = keep.rules; |
| 2615 | const size_t N = rules.size(); |
| 2616 | for (size_t i=0; i<N; i++) { |
| 2617 | const SortedVector<String8>& locations = rules.valueAt(i); |
| 2618 | const size_t M = locations.size(); |
| 2619 | for (size_t j=0; j<M; j++) { |
| 2620 | fprintf(fp, "# %s\n", locations.itemAt(j).string()); |
| 2621 | } |
| 2622 | fprintf(fp, "%s\n\n", rules.keyAt(i).string()); |
| 2623 | } |
| 2624 | fclose(fp); |
| 2625 | |
| 2626 | return err; |
| 2627 | } |
| 2628 | |
| 2629 | // Loops through the string paths and writes them to the file pointer |
| 2630 | // Each file path is written on its own line with a terminating backslash. |
no test coverage detected