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

Commit 246f4ac4 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Remove forward-lock install tests

This is a deprecated feature and no longer supported.

Bug: 38197362
Test: bit FrameworksCoreTests:android.content.pm.PackageManagerTests
Change-Id: Ie5c878d36fa42174cebea217a243d04c508d4ca3
parent cda831fc
Loading
Loading
Loading
Loading
+13 −242
Original line number Diff line number Diff line
@@ -467,16 +467,6 @@ public class PackageManagerTests extends AndroidTestCase {

            int rLoc = getInstallLoc(flags, expInstallLocation, pkgLen);
            if (rLoc == INSTALL_LOC_INT) {
                if ((flags & PackageManager.INSTALL_FORWARD_LOCK) != 0) {
                    assertTrue("The application should be installed forward locked",
                            (info.privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0);
                    assertStartsWith("The APK path should point to the ASEC",
                            SECURE_CONTAINERS_PREFIX, srcPath);
                    assertStartsWith("The public APK path should point to the ASEC",
                            SECURE_CONTAINERS_PREFIX, publicSrcPath);
                    assertStartsWith("The native library path should point to the ASEC",
                            SECURE_CONTAINERS_PREFIX, info.nativeLibraryDir);
                } else {
                assertFalse(
                        (info.privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0);
                assertEquals(appInstallPath, srcPath);
@@ -488,7 +478,6 @@ public class PackageManagerTests extends AndroidTestCase {
                        Process.SYSTEM_UID, Process.SYSTEM_UID,
                        S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH,
                        info.nativeLibraryDir);
                }
                assertFalse((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0);

                // Make sure the native library dir is not a symlink
@@ -502,13 +491,8 @@ public class PackageManagerTests extends AndroidTestCase {
                    }
                }
            } else if (rLoc == INSTALL_LOC_SD) {
                if ((flags & PackageManager.INSTALL_FORWARD_LOCK) != 0) {
                    assertTrue("The application should be installed forward locked",
                            (info.privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0);
                } else {
                assertFalse("The application should not be installed forward locked",
                        (info.privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0);
                }
                assertTrue("Application flags (" + info.flags
                        + ") should contain FLAG_EXTERNAL_STORAGE",
                        (info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0);
@@ -798,11 +782,6 @@ public class PackageManagerTests extends AndroidTestCase {
        sampleInstallFromRawResource(0, true);
    }

    @LargeTest
    public void testInstallFwdLockedInternal() throws Exception {
        sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, true);
    }

    @LargeTest
    public void testInstallSdcard() throws Exception {
        // Do not run on devices with emulated external storage.
@@ -906,11 +885,6 @@ public class PackageManagerTests extends AndroidTestCase {
        sampleReplaceFromRawResource(0);
    }

    @LargeTest
    public void testReplaceFailFwdLockedInternal() throws Exception {
        sampleReplaceFromRawResource(PackageManager.INSTALL_FORWARD_LOCK);
    }

    @LargeTest
    public void testReplaceFailSdcard() throws Exception {
        // Do not run on devices with emulated external storage.
@@ -926,12 +900,6 @@ public class PackageManagerTests extends AndroidTestCase {
        sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING);
    }

    @LargeTest
    public void testReplaceFwdLockedInternal() throws Exception {
        sampleReplaceFromRawResource(PackageManager.INSTALL_REPLACE_EXISTING
                | PackageManager.INSTALL_FORWARD_LOCK);
    }

    @LargeTest
    public void testReplaceSdcard() throws Exception {
        // Do not run on devices with emulated external storage.
@@ -1088,11 +1056,6 @@ public class PackageManagerTests extends AndroidTestCase {
        deleteFromRawResource(0, 0);
    }

    @LargeTest
    public void testDeleteFwdLockedInternal() throws Exception {
        deleteFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, 0);
    }

    @LargeTest
    public void testDeleteSdcard() throws Exception {
        // Do not run on devices with emulated external storage.
@@ -1108,11 +1071,6 @@ public class PackageManagerTests extends AndroidTestCase {
        deleteFromRawResource(0, PackageManager.DELETE_KEEP_DATA);
    }

    @LargeTest
    public void testDeleteFwdLockedInternalRetainData() throws Exception {
        deleteFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, PackageManager.DELETE_KEEP_DATA);
    }

    @LargeTest
    public void testDeleteSdcardRetainData() throws Exception {
        // Do not run on devices with emulated external storage.
@@ -1421,31 +1379,6 @@ public class PackageManagerTests extends AndroidTestCase {
                0, true, false, -1, PackageInfo.INSTALL_LOCATION_UNSPECIFIED);
    }

    @LargeTest
    public void testManifestInstallLocationFwdLockedFlagSdcard() throws Exception {
        // Do not run on devices with emulated external storage.
        if (Environment.isExternalStorageEmulated()) {
            return;
        }

        installFromRawResource("install.apk", R.raw.install_loc_unspecified,
                PackageManager.INSTALL_FORWARD_LOCK |
                PackageManager.INSTALL_EXTERNAL, true, false, -1,
                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
    }

    @LargeTest
    public void testManifestInstallLocationFwdLockedSdcard() throws Exception {
        // Do not run on devices with emulated external storage.
        if (Environment.isExternalStorageEmulated()) {
            return;
        }

        installFromRawResource("install.apk", R.raw.install_loc_sdcard,
                PackageManager.INSTALL_FORWARD_LOCK, true, false, -1,
                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
    }

    /*
     * Install a package on internal flash via PackageManager install flag. Replace
     * the package via flag to install on sdcard. Make sure the new flag overrides
@@ -1744,20 +1677,6 @@ public class PackageManagerTests extends AndroidTestCase {
        sampleMoveFromRawResource(installFlags, moveFlags, fail, result);
    }

    @LargeTest
    public void testMoveAppForwardLocked() throws Exception {
        // Do not run on devices with emulated external storage.
        if (Environment.isExternalStorageEmulated()) {
            return;
        }

        int installFlags = PackageManager.INSTALL_FORWARD_LOCK;
        int moveFlags = PackageManager.MOVE_EXTERNAL_MEDIA;
        boolean fail = false;
        int result = PackageManager.MOVE_SUCCEEDED;
        sampleMoveFromRawResource(installFlags, moveFlags, fail, result);
    }

    @LargeTest
    public void testMoveAppFailInternalToExternalDelete() throws Exception {
        // Do not run on devices with emulated external storage.
@@ -1884,63 +1803,6 @@ public class PackageManagerTests extends AndroidTestCase {
        sampleInstallFromRawResource(PackageManager.INSTALL_EXTERNAL, true);
    }

    /*
     * Install an app forward-locked.
     */
    @LargeTest
    public void testFlagF() throws Exception {
        sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK, true);
    }

    /*
     * Install an app with both internal and external flags set. should fail
     */
    @LargeTest
    public void testFlagIE() throws Exception {
        installFromRawResource("install.apk", R.raw.install,
                PackageManager.INSTALL_EXTERNAL | PackageManager.INSTALL_INTERNAL,
                false,
                true, PackageInstaller.STATUS_FAILURE_STORAGE,
                PackageInfo.INSTALL_LOCATION_AUTO);
    }

    /*
     * Install an app with both internal and forward-lock flags set.
     */
    @LargeTest
    public void testFlagIF() throws Exception {
        sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK
                | PackageManager.INSTALL_INTERNAL, true);
    }

    /*
     * Install an app with both external and forward-lock flags set.
     */
    @LargeTest
    public void testFlagEF() throws Exception {
        // Do not run on devices with emulated external storage.
        if (Environment.isExternalStorageEmulated()) {
            return;
        }

        sampleInstallFromRawResource(PackageManager.INSTALL_FORWARD_LOCK
                | PackageManager.INSTALL_EXTERNAL, true);
    }

    /*
     * Install an app with both internal and external flags set with forward
     * lock. Should fail.
     */
    @LargeTest
    public void testFlagIEF() throws Exception {
        installFromRawResource("install.apk", R.raw.install,
                PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_INTERNAL |
                PackageManager.INSTALL_EXTERNAL,
                false,
                true, PackageInstaller.STATUS_FAILURE_STORAGE,
                PackageInfo.INSTALL_LOCATION_AUTO);
    }

    /*
     * Install an app with both internal and manifest option set.
     * should install on internal.
@@ -2031,55 +1893,6 @@ public class PackageManagerTests extends AndroidTestCase {
                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
    }

    /*
     * Install an app with fwd locked flag set and install location set to
     * internal. should install internally.
     */
    @LargeTest
    public void testFlagFManifestI() throws Exception {
        installFromRawResource("install.apk", R.raw.install_loc_internal,
                PackageManager.INSTALL_FORWARD_LOCK,
                true,
                false, -1,
                PackageInfo.INSTALL_LOCATION_INTERNAL_ONLY);
    }

    /*
     * Install an app with fwd locked flag set and install location set to
     * preferExternal. Should install externally.
     */
    @LargeTest
    public void testFlagFManifestE() throws Exception {
        // Do not run on devices with emulated external storage.
        if (Environment.isExternalStorageEmulated()) {
            return;
        }

        installFromRawResource("install.apk", R.raw.install_loc_sdcard,
                PackageManager.INSTALL_FORWARD_LOCK,
                true,
                false, -1,
                PackageInfo.INSTALL_LOCATION_PREFER_EXTERNAL);
    }

    /*
     * Install an app with fwd locked flag set and install location set to auto.
     * should install externally.
     */
    @LargeTest
    public void testFlagFManifestA() throws Exception {
        // Do not run on devices with emulated external storage.
        if (Environment.isExternalStorageEmulated()) {
            return;
        }

        installFromRawResource("install.apk", R.raw.install_loc_auto,
                PackageManager.INSTALL_FORWARD_LOCK,
                true,
                false, -1,
                PackageInfo.INSTALL_LOCATION_AUTO);
    }

    /*
     * The following test functions verify install location for existing apps.
     * ie existing app can be installed internally or externally. If install
@@ -2175,48 +1988,6 @@ public class PackageManagerTests extends AndroidTestCase {
                -1);
    }

    @Suppress
    @LargeTest
    public void testFlagFExistingI() throws Exception {
        int iFlags = PackageManager.INSTALL_INTERNAL;
        int rFlags = PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_REPLACE_EXISTING;
        // First install.
        installFromRawResource("install.apk", R.raw.install,
                iFlags,
                false,
                false, -1,
                -1);
        // Replace now
        installFromRawResource("install.apk", R.raw.install,
                rFlags,
                true,
                false, -1,
                -1);
    }

    @LargeTest
    public void testFlagFExistingE() throws Exception {
        // Do not run on devices with emulated external storage.
        if (Environment.isExternalStorageEmulated()) {
            return;
        }

        int iFlags = PackageManager.INSTALL_EXTERNAL;
        int rFlags = PackageManager.INSTALL_FORWARD_LOCK | PackageManager.INSTALL_REPLACE_EXISTING;
        // First install.
        installFromRawResource("install.apk", R.raw.install,
                iFlags,
                false,
                false, -1,
                -1);
        // Replace now
        installFromRawResource("install.apk", R.raw.install,
                rFlags,
                true,
                false, -1,
                -1);
    }

    /*
     * The following set of tests verify the installation of apps with
     * install location attribute set to internalOnly, preferExternal and auto.