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

Commit 3474bb8b authored by Pawan Wagh's avatar Pawan Wagh
Browse files

Show compat warnings even with 'pageSizeCompat' set

Run the alignment checks irrespective of the pageSizeCompat attribute.
For 16 KB device - Alignment checks will be run on every app
For 4 KB device - Alignment checks will run on debuggable apps installed
via adb when device in the developer mode.

Bug: 430104514
Test: m FileSystemUtilsTests && atest -c FileSystemUtilsTests
Test: m PageSizeCompatWarningsTest && atest -c PageSizeCompatWarningsTest
Change-Id: I0984f4aca2cb288414ad408db7f8f780e9db48af
parent 2bc1ea1c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -105,14 +105,14 @@ public class AppWarningsHostTest extends BaseHostJUnit4Test {
    @AppModeFull
    public void runAppWith4KbLib_overrideCompatMode()
            throws FileNotFoundException, DeviceNotAvailableException, TargetSetupError {
        runPageSizeWarningsTest(TEST_APP_COMPAT_ENABLED, TEST_NO_WARNINGS);
        runPageSizeWarningsTest(TEST_APP_COMPAT_ENABLED, TEST_WARNINGS);
    }

    @Test
    @AppModeFull
    public void runAppWith4KbLib_disabledCompatMode()
            throws FileNotFoundException, DeviceNotAvailableException, TargetSetupError {
        runPageSizeWarningsTest(TEST_APP_COMPAT_DISABLED, TEST_NO_WARNINGS);
        runPageSizeWarningsTest(TEST_APP_COMPAT_DISABLED, TEST_WARNINGS);
    }

    @Test
+10 −3
Original line number Diff line number Diff line
@@ -78,21 +78,28 @@ public class PageSizeCompatTest {
    @Test
    public void testPageSizeCompat_compatEnabled() throws Exception {
        testPageSizeCompat_appLaunch(true);
        //verify warning dialog
        Assert.assertTrue(findCompatWaring() != null);
    }

    @Test
    public void testPageSizeCompat_compatDisabled() throws Exception {
        testPageSizeCompat_appLaunch(false);
        //verify warning dialog
        Assert.assertTrue(findCompatWaring() != null);
    }

    @Test
    public void testPageSizeCompat_compatByAlignmentChecks() throws Exception {
        testPageSizeCompat_appLaunch(true);

        //verify warning dialog
        Assert.assertTrue(findCompatWaring() != null);
    }

    private UiObject2 findCompatWaring() {
        UiDevice device = UiDevice.getInstance(getInstrumentation());
        device.waitForWindowUpdate(null, TIMEOUT);
        UiObject2 targetObject = device.wait(Until.findObject(By.text(WARNING_TEXT)), TIMEOUT);
        Assert.assertTrue(targetObject != null);
        UiObject2 object = device.wait(Until.findObject(By.text(WARNING_TEXT)), TIMEOUT);
        return object;
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -1892,13 +1892,11 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
     */
    @Override
    public String getPageSizeCompatWarningMessage(Context context) {
        boolean manifestOverrideEnabled =  (mPageSizeAppCompatFlags
                & ApplicationInfo.PAGE_SIZE_APP_COMPAT_FLAG_MANIFEST_OVERRIDE_ENABLED) != 0;
        boolean settingsOverrideEnabled =  (mPageSizeAppCompatFlags
                & ApplicationInfo.PAGE_SIZE_APP_COMPAT_FLAG_SETTINGS_OVERRIDE_ENABLED) != 0;
        boolean settingsOverrideDisabled =  (mPageSizeAppCompatFlags
                & ApplicationInfo.PAGE_SIZE_APP_COMPAT_FLAG_SETTINGS_OVERRIDE_DISABLED) != 0;
        if (manifestOverrideEnabled || settingsOverrideEnabled || settingsOverrideDisabled) {
        if (settingsOverrideEnabled || settingsOverrideDisabled) {
            return null;
        }

+21 −21
Original line number Diff line number Diff line
@@ -437,7 +437,8 @@ final class ScanPackageUtils {
            if (parsedPackage.getPageSizeAppCompatFlags()
                    > ApplicationInfo.PAGE_SIZE_APP_COMPAT_FLAG_UNDEFINED) {
                pkgSetting.setPageSizeAppCompatFlags(parsedPackage.getPageSizeAppCompatFlags());
            } else {
            }

            // 16 KB is only support for 64 bit ABIs and for apps which are being installed
            // Check alignment. System, Apex and Platform packages should be page-agnostic now
            if ((Build.SUPPORTED_64_BIT_ABIS.length > 0)
@@ -460,7 +461,6 @@ final class ScanPackageUtils {
                }
            }
        }
        }

        parsedPackage.setFactoryTest(isUnderFactoryTest && parsedPackage.getRequestedPermissions()
                .contains(android.Manifest.permission.FACTORY_TEST));