Search in sources :

Example 6 with PackageUseInfo

use of com.android.server.pm.dex.PackageDexUsage.PackageUseInfo in project platform_frameworks_base by android.

the class DexManagerTests method testNotifySecondaryForeign.

@Test
public void testNotifySecondaryForeign() {
    // Foo loads bar secondary files.
    List<String> barSecondaries = mBarUser0.getSecondaryDexPaths();
    notifyDexLoad(mFooUser0, barSecondaries, mUser0);
    PackageUseInfo pui = getPackageUseInfo(mBarUser0);
    assertNotNull(pui);
    assertFalse(pui.isUsedByOtherApps());
    assertEquals(barSecondaries.size(), pui.getDexUseInfoMap().size());
    assertSecondaryUse(mFooUser0, pui, barSecondaries, /*isUsedByOtherApps*/
    true, mUser0);
}
Also used : PackageUseInfo(com.android.server.pm.dex.PackageDexUsage.PackageUseInfo) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 7 with PackageUseInfo

use of com.android.server.pm.dex.PackageDexUsage.PackageUseInfo in project platform_frameworks_base by android.

the class DexManagerTests method testNotifyPackageInstallUsedByOther.

@Test
public void testNotifyPackageInstallUsedByOther() {
    TestData newPackage = new TestData("newPackage", VMRuntime.getInstructionSet(Build.SUPPORTED_ABIS[0]), mUser0);
    List<String> newSecondaries = newPackage.getSecondaryDexPaths();
    // Before we notify about the installation of the newPackage if mFoo
    // is trying to load something from it we should not find it.
    notifyDexLoad(mFooUser0, newSecondaries, mUser0);
    assertNull(getPackageUseInfo(newPackage));
    // Notify about newPackage install and let mFoo load its dexes.
    mDexManager.notifyPackageInstalled(newPackage.mPackageInfo, mUser0);
    notifyDexLoad(mFooUser0, newSecondaries, mUser0);
    // We should get back the right info.
    PackageUseInfo pui = getPackageUseInfo(newPackage);
    assertNotNull(pui);
    assertFalse(pui.isUsedByOtherApps());
    assertEquals(newSecondaries.size(), pui.getDexUseInfoMap().size());
    assertSecondaryUse(newPackage, pui, newSecondaries, /*isUsedByOtherApps*/
    true, mUser0);
}
Also used : PackageUseInfo(com.android.server.pm.dex.PackageDexUsage.PackageUseInfo) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 8 with PackageUseInfo

use of com.android.server.pm.dex.PackageDexUsage.PackageUseInfo in project platform_frameworks_base by android.

the class DexManagerTests method testNotifySequence.

@Test
public void testNotifySequence() {
    // Foo loads its own secondary files.
    List<String> fooSecondaries = mFooUser0.getSecondaryDexPaths();
    notifyDexLoad(mFooUser0, fooSecondaries, mUser0);
    // Foo loads Bar own secondary files.
    List<String> barSecondaries = mBarUser0.getSecondaryDexPaths();
    notifyDexLoad(mFooUser0, barSecondaries, mUser0);
    // Foo loads Bar primary files.
    notifyDexLoad(mFooUser0, mBarUser0.getBaseAndSplitDexPaths(), mUser0);
    // Bar loads its own secondary files.
    notifyDexLoad(mBarUser0, barSecondaries, mUser0);
    // Bar loads some own secondary files which foo didn't load.
    List<String> barSecondariesForOwnUse = mBarUser0.getSecondaryDexPathsForOwnUse();
    notifyDexLoad(mBarUser0, barSecondariesForOwnUse, mUser0);
    // Check bar usage. Should be used by other app (for primary and barSecondaries).
    PackageUseInfo pui = getPackageUseInfo(mBarUser0);
    assertNotNull(pui);
    assertTrue(pui.isUsedByOtherApps());
    assertEquals(barSecondaries.size() + barSecondariesForOwnUse.size(), pui.getDexUseInfoMap().size());
    assertSecondaryUse(mFooUser0, pui, barSecondaries, /*isUsedByOtherApps*/
    true, mUser0);
    assertSecondaryUse(mFooUser0, pui, barSecondariesForOwnUse, /*isUsedByOtherApps*/
    false, mUser0);
    // Check foo usage. Should not be used by other app.
    pui = getPackageUseInfo(mFooUser0);
    assertNotNull(pui);
    assertFalse(pui.isUsedByOtherApps());
    assertEquals(fooSecondaries.size(), pui.getDexUseInfoMap().size());
    assertSecondaryUse(mFooUser0, pui, fooSecondaries, /*isUsedByOtherApps*/
    false, mUser0);
}
Also used : PackageUseInfo(com.android.server.pm.dex.PackageDexUsage.PackageUseInfo) Test(org.junit.Test) SmallTest(android.support.test.filters.SmallTest)

Example 9 with PackageUseInfo

use of com.android.server.pm.dex.PackageDexUsage.PackageUseInfo in project platform_frameworks_base by android.

the class PackageDexUsageTests method assertPackageDexUsage.

private void assertPackageDexUsage(TestData primary, TestData... secondaries) {
    String packageName = primary == null ? secondaries[0].mPackageName : primary.mPackageName;
    boolean primaryUsedByOtherApps = primary == null ? false : primary.mUsedByOtherApps;
    PackageUseInfo pInfo = mPackageDexUsage.getPackageUseInfo(packageName);
    // Check package use info
    assertNotNull(pInfo);
    assertEquals(primaryUsedByOtherApps, pInfo.isUsedByOtherApps());
    Map<String, DexUseInfo> dexUseInfoMap = pInfo.getDexUseInfoMap();
    assertEquals(secondaries.length, dexUseInfoMap.size());
    // Check dex use info
    for (TestData testData : secondaries) {
        DexUseInfo dInfo = dexUseInfoMap.get(testData.mDexFile);
        assertNotNull(dInfo);
        assertEquals(testData.mUsedByOtherApps, dInfo.isUsedByOtherApps());
        assertEquals(testData.mOwnerUserId, dInfo.getOwnerUserId());
        assertEquals(1, dInfo.getLoaderIsas().size());
        assertTrue(dInfo.getLoaderIsas().contains(testData.mLoaderIsa));
    }
}
Also used : DexUseInfo(com.android.server.pm.dex.PackageDexUsage.DexUseInfo) PackageUseInfo(com.android.server.pm.dex.PackageDexUsage.PackageUseInfo)

Aggregations

PackageUseInfo (com.android.server.pm.dex.PackageDexUsage.PackageUseInfo)9 SmallTest (android.support.test.filters.SmallTest)6 Test (org.junit.Test)6 DexUseInfo (com.android.server.pm.dex.PackageDexUsage.DexUseInfo)3 PackageInfo (android.content.pm.PackageInfo)2 RemoteException (android.os.RemoteException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ApplicationInfo (android.content.pm.ApplicationInfo)1 InstallerException (com.android.server.pm.Installer.InstallerException)1 PackageDexOptimizer (com.android.server.pm.PackageDexOptimizer)1 HashSet (java.util.HashSet)1