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

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

Merge "[layout compilation] Disable precompiled layouts when preferCodeIntegrity is set"

parents 87e66f17 987c7a95
Loading
Loading
Loading
Loading
+25 −12
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
import android.annotation.SystemService;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
@@ -398,10 +399,23 @@ public abstract class LayoutInflater {
    }

    private void initPrecompiledViews() {
        try {
        // Check if precompiled layouts are enabled by a system property.
        mUseCompiledView =
            SystemProperties.getBoolean(USE_PRECOMPILED_LAYOUT_SYSTEM_PROPERTY, false);
            if (mUseCompiledView) {
        if (!mUseCompiledView) {
            return;
        }

        // Make sure the application allows code generation
        ApplicationInfo appInfo = mContext.getApplicationInfo();
        if ((appInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PREFER_CODE_INTEGRITY) != 0
            || appInfo.isPrivilegedApp()) {
            mUseCompiledView = false;
            return;
        }

        // Try to load the precompiled layout file.
        try {
            mPrecompiledClassLoader = mContext.getClassLoader();
            String dexFile = mContext.getCodeCacheDir() + COMPILED_VIEW_DEX_FILE_NAME;
            if (new File(dexFile).exists()) {
@@ -411,7 +425,6 @@ public abstract class LayoutInflater {
                // layouts.
                mUseCompiledView = false;
            }
            }
        } catch (Throwable e) {
            if (DEBUG) {
                Log.e(TAG, "Failed to initialized precompiled views layouts", e);