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

Commit 743b3632 authored by Mathieu Chartier's avatar Mathieu Chartier
Browse files

Revert "Revert "Add view inflation device config property""

Bug: 111895153
Bug: 123524494
Test: unlock lockscreen
Test: cts-tradefed run cts --enable-parameterized-modules --module-parameter instant_app -m CtsAccelerationTestCases
Test: 6/6 pass as expected (TOT)

This reverts commit 2a3b4394384217ae65b430339270c8914639a9e3.

Change-Id: Ib2267a10ef44b01bc077893172ad39b43ead7841
parent 8c83a07c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -5778,6 +5778,11 @@ package android.provider {
    field public static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
  }
  public static interface DeviceConfig.Runtime {
    field public static final String NAMESPACE = "runtime";
    field public static final String USE_PRECOMPILED_LAYOUT = "view.precompiled_layout_enabled";
  }
  public static interface DeviceConfig.RuntimeNative {
    field public static final String NAMESPACE = "runtime_native";
  }
+15 −0
Original line number Diff line number Diff line
@@ -121,6 +121,21 @@ public final class DeviceConfig {
        String MAX_SUGGESTIONS = "max_suggestions";
    }

    /**
     * Namespace for all runtime related features.
     *
     * @hide
     */
    @SystemApi
    public interface Runtime {
        String NAMESPACE = "runtime";

        /**
         * Whether or not we use the precompiled layout.
         */
        String USE_PRECOMPILED_LAYOUT = "view.precompiled_layout_enabled";
    }

    /**
     * Namespace for all runtime native related features.
     *
+20 −4
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import android.os.Handler;
import android.os.Message;
import android.os.SystemProperties;
import android.os.Trace;
import android.provider.DeviceConfig;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
@@ -80,8 +82,6 @@ public abstract class LayoutInflater {
    private static final String TAG = LayoutInflater.class.getSimpleName();
    private static final boolean DEBUG = false;

    private static final String USE_PRECOMPILED_LAYOUT_SYSTEM_PROPERTY
        = "view.precompiled_layout_enabled";
    private static final String COMPILED_VIEW_DEX_FILE_NAME = "/compiled_view.dex";

    /** Empty stack trace used to avoid log spam in re-throw exceptions. */
@@ -407,8 +407,24 @@ public abstract class LayoutInflater {
    }

    private void initPrecompiledViews() {
        initPrecompiledViews(
                SystemProperties.getBoolean(USE_PRECOMPILED_LAYOUT_SYSTEM_PROPERTY, false));
        // Use the device config if enabled, otherwise default to the system property.
        String usePrecompiledLayout = null;
        try {
            usePrecompiledLayout = DeviceConfig.getProperty(
                    DeviceConfig.Runtime.NAMESPACE,
                    DeviceConfig.Runtime.USE_PRECOMPILED_LAYOUT);
        } catch (Exception e) {
          // May be caused by permission errors reading the property (i.e. instant apps).
        }
        boolean enabled = false;
        if (TextUtils.isEmpty(usePrecompiledLayout)) {
            enabled = SystemProperties.getBoolean(
                    DeviceConfig.Runtime.USE_PRECOMPILED_LAYOUT,
                    false);
        } else {
            enabled = Boolean.parseBoolean(usePrecompiledLayout);
        }
        initPrecompiledViews(enabled);
    }

    private void initPrecompiledViews(boolean enablePrecompiledViews) {