OSDN Git Service

Add missing return in DexManager
authorCalin Juravle <calin@google.com>
Sat, 11 Mar 2017 02:24:33 +0000 (18:24 -0800)
committerCalin Juravle <calin@google.com>
Tue, 28 Mar 2017 20:37:15 +0000 (13:37 -0700)
Harmless issue but which can spam the logs.

Test: mostly manual since the check is buried deep inside and cannot be
verified accurately. I added another test to DexManager to stress that
code path and then checked the logs.

Bug: 36117123

(cherry picked from commit 2dfc1b3e125860221bc67835c2d5c99198a12f8a)

Merged-In: I1a878a200f3f726dfaa85f1bed1398acc8dce979
Change-Id: Ib2c034add2e8229b90eb4aaa0067d42d26798670

services/core/java/com/android/server/pm/dex/DexManager.java
services/tests/servicestests/src/com/android/server/pm/dex/DexManagerTests.java

index 755c486..83dd392 100644 (file)
@@ -432,7 +432,7 @@ public class DexManager {
         // Ignore framework code.
         // TODO(calin): is there a better way to detect it?
         if (dexPath.startsWith("/system/framework/")) {
-            new DexSearchResult("framework", DEX_SEARCH_NOT_FOUND);
+            return new DexSearchResult("framework", DEX_SEARCH_NOT_FOUND);
         }
 
         // First, check if the package which loads the dex file actually owns it.
index fa0bd39..72fb78e 100644 (file)
@@ -61,7 +61,6 @@ public class DexManagerTests {
 
     @Before
     public void setup() {
-
         mUser0 = 0;
         mUser1 = 1;
 
@@ -352,6 +351,15 @@ public class DexManagerTests {
         assertNull(pui);
     }
 
+    @Test
+    public void testNotifyFrameworkLoad() {
+        String frameworkDex = "/system/framework/com.android.location.provider.jar";
+        // Load a dex file from framework.
+        notifyDexLoad(mFooUser0, Arrays.asList(frameworkDex), mUser0);
+        // The dex file should not be recognized as a package.
+        assertNull(mDexManager.getPackageUseInfo(frameworkDex));
+    }
+
     private void assertSecondaryUse(TestData testData, PackageUseInfo pui,
             List<String> secondaries, boolean isUsedByOtherApps, int ownerUserId) {
         for (String dex : secondaries) {