Fix app cache dir guessing.

A change to BaseDexClassLoader changed the format of
its toString output which we rely upon (yuck) to figure
out what the cache dir should be.

Change-Id: I0f28e3eff9eba70a1f5e6c538aa8da32c264515b
diff --git a/README b/README
index 6ca0de4..86b8be6 100644
--- a/README
+++ b/README
@@ -12,5 +12,6 @@
 Can mock concrete classes, requires dexmaker.jar on classpath.
 
 Local Modifications:
-No modifications.
+- Change to AppDataDirGuesser to handle the new class loader toString
+  format introduced in JB.
 
diff --git a/src/com/google/testing/littlemock/AppDataDirGuesser.java b/src/com/google/testing/littlemock/AppDataDirGuesser.java
index e661ed6..254ed7e 100644
--- a/src/com/google/testing/littlemock/AppDataDirGuesser.java
+++ b/src/com/google/testing/littlemock/AppDataDirGuesser.java
@@ -75,7 +75,7 @@
     }
 
     // Parsing toString() method: yuck.  But no other way to get the path.
-    // Strip out the bit between angle brackets, that's our path.
+    // Strip out the bit between square brackets, that's our path.
     String result = classLoader.toString();
     int index = result.lastIndexOf('[');
     result = (index == -1) ? result : result.substring(index + 1);
@@ -86,7 +86,7 @@
   // @VisibleForTesting
   File[] guessPath(String input) {
     List<File> results = new ArrayList<File>();
-    for (String potential : input.split(":")) {
+    for (String potential : splitPathList(input)) {
       if (!potential.startsWith("/data/app/")) {
         continue;
       }
@@ -110,10 +110,25 @@
         }
       }
     }
+
     return results.toArray(new File[results.size()]);
   }
 
   // @VisibleForTesting
+  static String[] splitPathList(String input) {
+    String trimmed = input;
+    if (input.startsWith("dexPath=")) {
+      int start = "dexPath=".length();
+      int end = input.indexOf(',');
+
+      trimmed = (end == -1) ? input.substring(start) :
+          input.substring(start, end);
+    }
+
+    return trimmed.split(":");
+  }
+
+  // @VisibleForTesting
   boolean fileOrDirExists(File file) {
       return file.exists();
   }
diff --git a/tests/com/google/testing/littlemock/AppDataDirGuesserTest.java b/tests/com/google/testing/littlemock/AppDataDirGuesserTest.java
index 3ab38b2..191a608 100644
--- a/tests/com/google/testing/littlemock/AppDataDirGuesserTest.java
+++ b/tests/com/google/testing/littlemock/AppDataDirGuesserTest.java
@@ -67,6 +67,15 @@
         .shouldGive("/data/data/com.google.android.voicesearch/cache");
   }
 
+  public void testSplitPathList() {
+    final String[] expected = { "foo", "bar" };
+    assertTrue(Arrays.equals(expected, AppDataDirGuesser.splitPathList("foo:bar")));
+    assertTrue(Arrays.equals(expected,
+              AppDataDirGuesser.splitPathList("dexPath=foo:bar")));
+    assertTrue(Arrays.equals(expected,
+              AppDataDirGuesser.splitPathList("dexPath=foo:bar,bazPath=bar:bar2")));
+  }
+
   private interface TestCondition {
     TestCondition withNonWriteable(String... files);
     void shouldGive(String... files);