Merge change 8528 into donut
* changes:
Allow override of default symbol location for native heap library resolution
diff --git a/tools/findunused/findunusedtranslations b/tools/findunused/findunusedtranslations
new file mode 100755
index 0000000..878681e
--- /dev/null
+++ b/tools/findunused/findunusedtranslations
@@ -0,0 +1,103 @@
+#!/usr/bin/perl
+
+sub usage {
+ print STDERR "Usage: findunusedtranslations values/strings.xml\n";
+ print STDERR "\n";
+ print STDERR "Will read values/strings.xml and rewrite\n";
+ print STDERR "values-xx/strings.xml and values-xx-rYY/strings.xml\n";
+ print STDERR "files to remove strings that no longer appear in the\n";
+ print STDERR "base strings file.\n";
+
+ exit 1;
+}
+
+if ($#ARGV != 0) {
+ usage();
+}
+
+unless ($ARGV[0] =~ /^(.*)\/values([^\/]*)\/(.*\.xml)/) {
+ print STDERR "Bad format for $ARGV[0]\n";
+ usage();
+}
+
+unless (-f $ARGV[0]) {
+ print STDERR "$0: $ARGV[0]: No such file\n";
+}
+
+$prefix = $1;
+$values = $2;
+$suffix = $3;
+
+if ($values =~ /^(-mcc[^-]*)*(-mnc[^-]*)*(.*)$/) {
+ $pattern1 = "$prefix/values$1$2-??$3/$suffix";
+ $pattern2 = "$prefix/values$1$2-??-r??$3/$suffix";
+} else {
+ $pattern1 = "$prefix/values-??$values/$suffix";
+ $pattern2 = "$prefix/values-??-r??$values/$suffix";
+}
+
+@matches = (glob($pattern1), glob($pattern2));
+
+open(IN, "<$ARGV[0]");
+while (<IN>) {
+ if (/<string [^>]*name="([^"]*)"/) {
+ $string{$1} = 1;
+ }
+ if (/<string-array [^>]*name="([^"]*)"/) {
+ $stringarray{$1} = 1;
+ }
+ if (/<plurals [^>]*name="([^"]*)"/) {
+ $plurals{$1} = 1;
+ }
+}
+close(IN);
+
+for $match (@matches) {
+ print "Rewriting $match\n";
+ $suppress = 0;
+ $text = "";
+ $changes = 0;
+
+ open(IN, "<$match");
+ while (<IN>) {
+ if (/<string [^>]*name="([^"]*)"/) {
+ if ($string{$1} == 0) {
+ $suppress = 1;
+ $changes = 1;
+ }
+ }
+ if (/<string-array [^>]*name="([^"]*)"/) {
+ if ($stringarray{$1} == 0) {
+ $suppress = 1;
+ $changes = 1;
+ }
+ }
+ if (/<plurals [^>]*name="([^"]*)"/) {
+ if ($plurals{$1} == 0) {
+ $suppress = 1;
+ $changes = 1;
+ }
+ }
+
+ $text .= $_ unless ($suppress);
+
+ if (/<\/string/) {
+ $suppress = 0;
+ }
+ if (/<\/string-array/) {
+ $suppress = 0;
+ }
+ if (/<\/plurals/) {
+ $suppress = 0;
+ }
+ }
+ close(IN);
+
+ if ($changes) {
+ open(OUT, ">$match");
+ print OUT $text;
+ close(OUT);
+ } else {
+ print "(no changes)\n";
+ }
+}
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
index d146842..abd42fb 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
@@ -140,4 +140,51 @@
// only one doc package so any doc package is the same item.
return pkg instanceof DocPackage;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * The comparison between doc packages is a bit more complex so we override the default
+ * implementation.
+ * <p/>
+ * Docs are upgrade if they have a higher api, or a similar api but a higher revision.
+ * <p/>
+ * What makes this more complex is handling codename.
+ */
+ @Override
+ public UpdateInfo canBeUpdatedBy(Package replacementPackage) {
+ if (replacementPackage == null) {
+ return UpdateInfo.INCOMPATIBLE;
+ }
+
+ // check they are the same item.
+ if (sameItemAs(replacementPackage) == false) {
+ return UpdateInfo.INCOMPATIBLE;
+ }
+
+ DocPackage replacementDoc = (DocPackage)replacementPackage;
+
+ AndroidVersion replacementVersion = replacementDoc.getVersion();
+
+ // the new doc is an update if the api level is higher
+ if (replacementVersion.getApiLevel() > mVersion.getApiLevel()) {
+ return UpdateInfo.UPDATE;
+ }
+
+ // if it's the exactly same (including codename), we check the revision
+ if (replacementVersion.equals(mVersion) &&
+ replacementPackage.getRevision() > this.getRevision()) {
+ return UpdateInfo.UPDATE;
+ }
+
+ // else we check if they have the same api level and the new one is a preview, in which
+ // case it's also an update (since preview have the api level of the _previous_ version.
+ if (replacementVersion.getApiLevel() == mVersion.getApiLevel() &&
+ replacementVersion.isPreview()) {
+ return UpdateInfo.UPDATE;
+ }
+
+ // not an upgrade but not incompatible either.
+ return UpdateInfo.NOT_UPDATE;
+ }
}
diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
index 369305a..1fcd6b1 100755
--- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
+++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
@@ -330,7 +330,7 @@
*
* @see #sameItemAs(Package)
*/
- public final UpdateInfo canBeUpdatedBy(Package replacementPackage) {
+ public UpdateInfo canBeUpdatedBy(Package replacementPackage) {
if (replacementPackage == null) {
return UpdateInfo.INCOMPATIBLE;
}