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

Commit 29050056 authored by Pawan Wagh's avatar Pawan Wagh Committed by Android (Google) Code Review
Browse files

Merge changes I7c5f6734,I5b9450dd into main

* changes:
  Show page size compat warnings on 4 KB device
  Run page size alignment checks on 4 KB device
parents 2a6ed32d 5c6072c9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -270,6 +270,14 @@ flag {
    is_fixed_read_only: true
}

flag {
    name: "app_compat_warnings_16kb"
    namespace: "devoptions_settings"
    description: "Feature flag to enable page size app compat warnings based on the alignment checks."
    bug: "418267369"
    is_fixed_read_only: true
}

flag {
    name: "remove_hidden_module_usage"
    namespace: "modularization"
+3 −3
Original line number Diff line number Diff line
@@ -706,7 +706,7 @@ static jint checkAlignment(JNIEnv* env, jstring javaNativeLibPath, jboolean extr
                           ZipFileRO* zipFile, ZipEntryRO zipEntry, const char* fileName) {
    int mode = PAGE_SIZE_APP_COMPAT_FLAG_UNDEFINED;
    // Need two separate install status for APK and ELF alignment
    static const size_t kPageSize = getpagesize();
    static const size_t kPageSize16Kb = 16384;
    jint ret = INSTALL_SUCCEEDED;

    ScopedUtfChars nativeLibPath(env, javaNativeLibPath);
@@ -730,10 +730,10 @@ static jint checkAlignment(JNIEnv* env, jstring javaNativeLibPath, jboolean extr
        return PAGE_SIZE_APP_COMPAT_FLAG_ERROR;
    }

    if (offset % kPageSize != 0) {
    if (offset % kPageSize16Kb != 0) {
        ALOGW("Library '%s' is not PAGE(%zu)-aligned - will not be able to open it directly "
              "from apk.\n",
              fileName, kPageSize);
              fileName, kPageSize16Kb);
        mode |= PAGE_SIZE_APP_COMPAT_FLAG_UNCOMPRESSED_LIBS_NOT_ALIGNED;
        ALOGI("Setting page size compat mode "
              "PAGE_SIZE_APP_COMPAT_FLAG_UNCOMPRESSED_LIBS_NOT_ALIGNED for %s",
+24 −3
Original line number Diff line number Diff line
@@ -199,22 +199,43 @@
    <!-- Displayed to confirm to the user that caller ID will not be restricted on the next call or in general. -->
    <string name="CLIRDefaultOffNextCallOff">Caller ID defaults to not restricted. Next call: Not restricted</string>
    <!-- Message displayed in dialog when APK is not 16 KB aligned. [CHAR LIMIT=NONE] -->
    <!-- Message displayed in dialog when APK is not 16 KB aligned on 16 KB device. [CHAR LIMIT=NONE] -->
    <string name="page_size_compat_apk_warning">This app isn’t 16 KB compatible. APK alignment check failed.
        This app will be run using page size compatible mode. For best compatibility, please recompile the application with 16 KB support.
        For more information, see &lt;a href=\"https://developer.android.com/16kb-page-size\"&gt;https://developer.android.com/16kb-page-size&lt;/a&gt; </string>
    <!-- Message displayed in dialog when ELF is not 16 KB aligned. [CHAR LIMIT=NONE] -->
    <!-- Message displayed in dialog when ELF is not 16 KB aligned on 16 KB device . [CHAR LIMIT=NONE] -->
    <string name="page_size_compat_elf_warning">This app isn’t 16 KB compatible. ELF alignment check failed.
        This app will be run using page size compatible mode. For best compatibility, please recompile the application with 16 KB support.
        For more information, see &lt;a href=\"https://developer.android.com/16kb-page-size\"&gt;https://developer.android.com/16kb-page-size&lt;/a&gt;</string>
    <!-- Message displayed in dialog when APK and ELF are not 16 KB aligned. [CHAR LIMIT=NONE] -->
    <!-- Message displayed in dialog when APK and ELF are not 16 KB aligned on 16 KB device. [CHAR LIMIT=NONE] -->
    <string name="page_size_compat_apk_and_elf_warning">This app isn’t 16 KB compatible. APK and ELF alignment checks failed.
        This app will be run using page size compatible mode. For best compatibility, please recompile the application with 16 KB support.
        For more information, see &lt;a href=\"https://developer.android.com/16kb-page-size\"&gt;https://developer.android.com/16kb-page-size&lt;/a&gt;</string>
    <!-- Message displayed in dialog when APK is not 16 KB aligned on 4 KB device. [CHAR LIMIT=NONE] -->
    <string name="page_size_compat_apk_warning_4kb">This warning is showing because this is a debuggable app which is currently being tested.
        If you are not the developer, please report this to the developer and ask for a non-debuggable app.
        This app isn\’t 16 KB compatible. APK alignment check failed.
        Please follow the steps on &lt;a href=\"https://developer.android.com/16kb-page-size\"&gt;https://developer.android.com/16kb-page-size&lt;/a&gt; </string>
    <!-- Message displayed in dialog when ELF is not 16 KB aligned on 4 KB device. [CHAR LIMIT=NONE] -->
    <string name="page_size_compat_elf_warning_4kb">This warning is showing because this is a debuggable app which is currently being tested.
        If you are not the developer, please report this to the developer and ask for a non-debuggable app.
        This app isn\’t 16 KB compatible. ELF alignment check failed.
        Please follow the steps on &lt;a href=\"https://developer.android.com/16kb-page-size\"&gt;https://developer.android.com/16kb-page-size&lt;/a&gt;</string>
    <!-- Message displayed in dialog when APK and ELF are not 16 KB aligned on 4 KB device. [CHAR LIMIT=NONE] -->
    <string name="page_size_compat_apk_and_elf_warning_4kb">This warning is showing because this is a debuggable app which is currently being tested.
        If you are not the developer, please report this to the developer and ask for a non-debuggable app.
        This app isn\’t 16 KB compatible. APK and ELF alignment checks failed.
        Please follow the steps on &lt;a href=\"https://developer.android.com/16kb-page-size\"&gt;https://developer.android.com/16kb-page-size&lt;/a&gt;</string>
    <!--Confirmation text for page size mismatch dialog to never show-->
    <string name="page_size_compat_never_show"> Don\'t Show Again</string>
    <!-- Displayed to tell the user that caller ID is not provisioned for their SIM. -->
    <string name="serviceNotProvisioned">Service not provisioned.</string>
    <!-- Displayed to tell the user that they cannot change the caller ID setting. -->
+4 −0
Original line number Diff line number Diff line
@@ -3396,6 +3396,10 @@
  <java-symbol type="string" name="page_size_compat_apk_warning" />
  <java-symbol type="string" name="page_size_compat_elf_warning" />
  <java-symbol type="string" name="page_size_compat_apk_and_elf_warning" />
  <java-symbol type="string" name="page_size_compat_apk_warning_4kb" />
  <java-symbol type="string" name="page_size_compat_elf_warning_4kb" />
  <java-symbol type="string" name="page_size_compat_apk_and_elf_warning_4kb" />
  <java-symbol type="string" name="page_size_compat_never_show" />

  <!--  Work profile unlaunchable app alert dialog-->
  <java-symbol type="style" name="AlertDialogWithEmergencyButton"/>
+13 −4
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ import android.os.UserHandle;
import android.os.incremental.IncrementalManager;
import android.service.pm.PackageProto;
import android.service.pm.PackageProto.UserInfoProto.ArchiveState.ArchiveActivityInfo;
import android.system.Os;
import android.system.OsConstants;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -1860,19 +1862,26 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
        boolean elfNotAligned = (mPageSizeAppCompatFlags
                & ApplicationInfo.PAGE_SIZE_APP_COMPAT_FLAG_ELF_NOT_ALIGNED) != 0;

        // On 4 KB device, show a warning to fix compatibility.
        boolean is4kbDevice = Os.sysconf(OsConstants._SC_PAGESIZE) == 4096;
        if (uncompressedLibsNotAligned && elfNotAligned) {
            return context.getText(
                            com.android.internal.R.string.page_size_compat_apk_and_elf_warning)
            return context.getText(is4kbDevice
                            ? com.android.internal.R.string.page_size_compat_apk_and_elf_warning_4kb
                     : com.android.internal.R.string.page_size_compat_apk_and_elf_warning)
                    .toString();
        }

        if (uncompressedLibsNotAligned) {
            return context.getText(com.android.internal.R.string.page_size_compat_apk_warning)
            return context.getText(is4kbDevice
                            ? com.android.internal.R.string.page_size_compat_apk_warning_4kb
                            : com.android.internal.R.string.page_size_compat_apk_warning)
                    .toString();
        }

        if (elfNotAligned) {
            return context.getText(com.android.internal.R.string.page_size_compat_elf_warning)
            return context.getText(is4kbDevice
                            ? com.android.internal.R.string.page_size_compat_elf_warning_4kb
                            : com.android.internal.R.string.page_size_compat_elf_warning)
                    .toString();
        }

Loading