Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71a24be9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix APCT tests"

parents bbb00da5 d5aaa448
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.content.pm;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.annotations.VisibleForTesting;

import java.io.UnsupportedEncodingException;
import java.security.SecureRandom;
import java.util.Random;
@@ -86,6 +88,7 @@ public class VerifierDeviceIdentity implements Parcelable {
     * @return verifier device identity based on the input from the provided
     *         random number generator
     */
    @VisibleForTesting
    static VerifierDeviceIdentity generate(Random rng) {
        long identity = rng.nextLong();
        return new VerifierDeviceIdentity(identity);
+2 −30
Original line number Diff line number Diff line
@@ -294,7 +294,7 @@ public class PackageManagerSettingsTests {
                null /*disabledPkg*/,
                null /*sharedUser*/,
                UPDATED_CODE_PATH /*codePath*/,
                null /*resourcePath*/,
                UPDATED_CODE_PATH /*resourcePath*/,
                null /*legacyNativeLibraryPath*/,
                "arm64-v8a" /*primaryCpuAbi*/,
                "armeabi" /*secondaryCpuAbi*/,
@@ -328,7 +328,7 @@ public class PackageManagerSettingsTests {
                null /*disabledPkg*/,
                null /*sharedUser*/,
                UPDATED_CODE_PATH /*codePath*/,
                null /*resourcePath*/,
                UPDATED_CODE_PATH /*resourcePath*/,
                null /*legacyNativeLibraryPath*/,
                "arm64-v8a" /*primaryCpuAbi*/,
                "armeabi" /*secondaryCpuAbi*/,
@@ -561,34 +561,6 @@ public class PackageManagerSettingsTests {
                false /*notLaunched*/, false /*stopped*/, true /*installed*/);
    }

    @Test
    public void testInsertPackageSetting() {
        final PackageSetting ps = createPackageSetting(0 /*sharedUserId*/, 0 /*pkgFlags*/);
        final PackageParser.Package pkg = new PackageParser.Package(PACKAGE_NAME);
        pkg.applicationInfo.setCodePath(ps.codePathString);
        pkg.applicationInfo.setResourcePath(ps.resourcePathString);
        final Context context = InstrumentationRegistry.getContext();
        final Object lock = new Object();
        PermissionManagerInternal pmInt = PermissionManagerService.create(context, null, lock);
        final Settings settings =
                new Settings(context.getFilesDir(), pmInt.getPermissionSettings(), lock);
        pkg.usesStaticLibraries = new ArrayList<>(
                Arrays.asList("foo.bar1", "foo.bar2", "foo.bar3"));
        pkg.usesStaticLibrariesVersions = new long[] {2, 4, 6};
        settings.insertPackageSettingLPw(ps, pkg);
        assertEquals(pkg, ps.pkg);
        assertArrayEquals(pkg.usesStaticLibraries.toArray(new String[0]), ps.usesStaticLibraries);
        assertArrayEquals(pkg.usesStaticLibrariesVersions, ps.usesStaticLibrariesVersions);

        pkg.usesStaticLibraries = null;
        pkg.usesStaticLibrariesVersions = null;
        settings.insertPackageSettingLPw(ps, pkg);
        assertEquals(pkg, ps.pkg);
        assertNull("Actual: " + Arrays.toString(ps.usesStaticLibraries), ps.usesStaticLibraries);
        assertNull("Actual: " + Arrays.toString(ps.usesStaticLibrariesVersions),
                ps.usesStaticLibrariesVersions);
    }

    private <T> void assertArrayEquals(T[] a, T[] b) {
        assertTrue("Expected: " + Arrays.toString(a) + ", actual: " + Arrays.toString(b),
                Arrays.equals(a, b));