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

Commit 9719b517 authored by Pawan Wagh's avatar Pawan Wagh
Browse files

Show appwarnings only if developer mode is on

- Adding check to show appwarnings when developer mode is on
- Adding check to run alignment scan only if new package is being
  scanned

Test: m PageSizeCompatWarningsTest && atest -c PageSizeCompatWarningsTest
Bug: 416538966
Flag: android.content.pm.app_compat_warnings_16kb
Change-Id: I5c209711cb9e6249329a834caf3eb452a33e4216
parent d2d7f63b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
        <option name="force-skip-system-props" value="true" />
        <option name="set-global-setting" key="verifier_engprod" value="1" />
        <option name="set-global-setting" key="verifier_verify_adb_installs" value="0" />
        <option name="set-global-setting" key="development_settings_enabled" value="1" />
        <option name="restore-settings" value="true" />
    </target_preparer>

+15 −3
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import static com.android.server.pm.PackageManagerServiceUtils.getLastModifiedTi

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.Flags;
@@ -425,12 +426,14 @@ final class ScanPackageUtils {

        boolean is16KbDevice = Os.sysconf(OsConstants._SC_PAGESIZE) == PAGE_SIZE_16KB;

        // Run 16 KB alignment checks on 4 KB device if evaluated as true.
        // Run 16 KB alignment checks on 4 KB device if evaluated as true for new installations.
        boolean enable4kbChecks =  false;
        if ((Build.SUPPORTED_64_BIT_ABIS.length > 0)
                && !isSystemApp
                && !isApex
                && !isPlatformPackage) {
                && !isPlatformPackage
                && (scanFlags & SCAN_NEW_INSTALL) != 0
        ) {
            enable4kbChecks = enableAlignmentChecks(parsedPackage, injector.getContext(),
                pkgSetting.getInstallSource().mInitiatingPackageName);
        }
@@ -1116,9 +1119,18 @@ final class ScanPackageUtils {
            return false;
        }

        final ContentResolver resolver = context.getContentResolver();
        if (resolver == null) {
            Slog.w(TAG, "Content resolver not available!");
            return false;
        }

        boolean isDebuggable = parsedPackage.isDebuggable();
        boolean isDeveloperMode = android.provider.Settings.Global.getInt(resolver,
                android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
        boolean isInstalledByAdb = PackageManagerServiceUtils.isInstalledByAdb(initiatingPackage);
        return isDebuggable && isInstalledByAdb;

        return isDebuggable && isDeveloperMode && isInstalledByAdb;
    }

    /** Directory where installed application's 32-bit native libraries are copied. */