OSDN Git Service

Fix 2 filtering problems in multi dex + main list.
authorYohann Roussel <yroussel@google.com>
Wed, 21 Aug 2013 19:17:24 +0000 (21:17 +0200)
committerBrian Carlstrom <bdc@google.com>
Wed, 28 Aug 2013 23:38:19 +0000 (16:38 -0700)
- Classes in archives were added in all dexes.
- Adding resources could be done twice in non "strictNameCheck" mode
(when using BestEffortMainDexListFilter) if there was 2 secondary
dex.

(cherry picked from commit ad27e19691c6723a801b127f8802f5cdf4f44359)

Change-Id: I5cbc1b273518e868fdd3d642d50488ddcbec2af6

dx/src/com/android/dx/cf/direct/ClassPathOpener.java
dx/src/com/android/dx/command/dexer/Main.java

index 6d33733..c9fe275 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.dx.cf.direct;
 
 import com.android.dex.util.FileUtils;
+
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
@@ -264,22 +265,24 @@ public class ClassPathOpener {
             }
 
             String path = one.getName();
-            InputStream in = zip.getInputStream(one);
+            if (filter.accept(path)) {
+                InputStream in = zip.getInputStream(one);
 
-            baos.reset();
-            for (;;) {
-                int amt = in.read(buf);
-                if (amt < 0) {
-                    break;
-                }
+                baos.reset();
+                for (;;) {
+                    int amt = in.read(buf);
+                    if (amt < 0) {
+                        break;
+                    }
 
-                baos.write(buf, 0, amt);
-            }
+                    baos.write(buf, 0, amt);
+                }
 
-            in.close();
+                in.close();
 
-            byte[] bytes = baos.toByteArray();
-            any |= consumer.processFileBytes(path, one.getTime(), bytes);
+                byte[] bytes = baos.toByteArray();
+                any |= consumer.processFileBytes(path, one.getTime(), bytes);
+            }
         }
 
         zip.close();
index d9f6ab0..042a086 100644 (file)
@@ -1103,8 +1103,10 @@ public class Main {
                         }
                     }
                 }
+                return false;
+            } else {
+                return true;
             }
-            return false;
         }
 
         private static String getSimpleName(String path) {