diff --git a/api/system-current.txt b/api/system-current.txt index c1979fd038f1f..12934b9df72ca 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5867,6 +5867,8 @@ package android.provider { field public static final String NAMESPACE_INTELLIGENCE_ATTENTION = "intelligence_attention"; field public static final String NAMESPACE_MEDIA_NATIVE = "media_native"; field public static final String NAMESPACE_NETD_NATIVE = "netd_native"; + field public static final String NAMESPACE_RUNTIME = "runtime"; + field public static final String NAMESPACE_RUNTIME_NATIVE = "runtime_native"; field public static final String NAMESPACE_RUNTIME_NATIVE_BOOT = "runtime_native_boot"; field public static final String NAMESPACE_SYSTEMUI = "systemui"; field public static final String NAMESPACE_TEXTCLASSIFIER = "textclassifier"; @@ -5909,15 +5911,6 @@ package android.provider { field public static final String ROLLBACK_LIFETIME_IN_MILLIS = "rollback_lifetime_in_millis"; } - 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"; - } - public static interface DeviceConfig.Scheduler { field public static final String ENABLE_FAST_METRICS_COLLECTION = "enable_fast_metrics_collection"; field public static final String NAMESPACE = "scheduler"; diff --git a/core/java/android/os/ZygoteProcess.java b/core/java/android/os/ZygoteProcess.java index b6bc95d1cb541..6f0a1f29a3cf0 100644 --- a/core/java/android/os/ZygoteProcess.java +++ b/core/java/android/os/ZygoteProcess.java @@ -21,12 +21,12 @@ import android.annotation.Nullable; import android.content.pm.ApplicationInfo; import android.net.LocalSocket; import android.net.LocalSocketAddress; -import android.provider.DeviceConfig; import android.util.Log; import android.util.Slog; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.Zygote; +import com.android.internal.os.ZygoteConfig; import java.io.BufferedWriter; import java.io.DataInputStream; @@ -659,16 +659,13 @@ public class ZygoteProcess { private boolean fetchUsapPoolEnabledProp() { boolean origVal = mUsapPoolEnabled; - final String propertyString = - Zygote.getConfigurationProperty( - DeviceConfig.RuntimeNative.USAP_POOL_ENABLED, - USAP_POOL_ENABLED_DEFAULT); + final String propertyString = Zygote.getConfigurationProperty( + ZygoteConfig.USAP_POOL_ENABLED, USAP_POOL_ENABLED_DEFAULT); if (!propertyString.isEmpty()) { - mUsapPoolEnabled = - Zygote.getConfigurationPropertyBoolean( - DeviceConfig.RuntimeNative.USAP_POOL_ENABLED, - Boolean.parseBoolean(USAP_POOL_ENABLED_DEFAULT)); + mUsapPoolEnabled = Zygote.getConfigurationPropertyBoolean( + ZygoteConfig.USAP_POOL_ENABLED, + Boolean.parseBoolean(USAP_POOL_ENABLED_DEFAULT)); } if (origVal != mUsapPoolEnabled) { diff --git a/core/java/android/provider/DeviceConfig.java b/core/java/android/provider/DeviceConfig.java index 038d455b510b4..86f9946817ff2 100644 --- a/core/java/android/provider/DeviceConfig.java +++ b/core/java/android/provider/DeviceConfig.java @@ -154,6 +154,22 @@ public final class DeviceConfig { @SystemApi public static final String NAMESPACE_NETD_NATIVE = "netd_native"; + /** + * Namespace for all runtime related features. + * + * @hide + */ + @SystemApi + public static final String NAMESPACE_RUNTIME = "runtime"; + + /** + * Namespace for all runtime native related features. + * + * @hide + */ + @SystemApi + public static final String NAMESPACE_RUNTIME_NATIVE = "runtime_native"; + /** * Namespace for all runtime native boot related features. Boot in this case refers to the * fact that the properties only take affect after rebooting the device. @@ -179,63 +195,6 @@ public final class DeviceConfig { @SystemApi public static final String NAMESPACE_TEXTCLASSIFIER = "textclassifier"; - /** - * 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. - * - * @hide - */ - @SystemApi - public interface RuntimeNative { - String NAMESPACE = "runtime_native"; - - /** - * Zygote flags. See {@link com.internal.os.Zygote}. - */ - - /** - * If {@code true}, enables the unspecialized app process (USAP) pool feature. - * - * @hide for internal use only - */ - String USAP_POOL_ENABLED = "usap_pool_enabled"; - - /** - * The maximum number of processes to keep in the USAP pool. - * - * @hide for internal use only - */ - String USAP_POOL_SIZE_MAX = "usap_pool_size_max"; - - /** - * The minimum number of processes to keep in the USAP pool. - * - * @hide for internal use only - */ - String USAP_POOL_SIZE_MIN = "usap_pool_size_min"; - - /** - * The threshold used to determine if the pool should be refilled. - * - * @hide for internal use only - */ - String USAP_POOL_REFILL_THRESHOLD = "usap_refill_threshold"; - } - /** * Privacy related properties definitions. * diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index 2e27737782fac..35cf129d81b85 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -83,6 +83,10 @@ public abstract class LayoutInflater { private static final boolean DEBUG = false; private static final String COMPILED_VIEW_DEX_FILE_NAME = "/compiled_view.dex"; + /** + * Whether or not we use the precompiled layout. + */ + private static final String USE_PRECOMPILED_LAYOUT = "view.precompiled_layout_enabled"; /** Empty stack trace used to avoid log spam in re-throw exceptions. */ private static final StackTraceElement[] EMPTY_STACK_TRACE = new StackTraceElement[0]; @@ -416,15 +420,15 @@ public abstract class LayoutInflater { String usePrecompiledLayout = null; try { usePrecompiledLayout = DeviceConfig.getProperty( - DeviceConfig.Runtime.NAMESPACE, - DeviceConfig.Runtime.USE_PRECOMPILED_LAYOUT); + DeviceConfig.NAMESPACE_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, + USE_PRECOMPILED_LAYOUT, false); } else { enabled = Boolean.parseBoolean(usePrecompiledLayout); diff --git a/core/java/com/android/internal/os/Zygote.java b/core/java/com/android/internal/os/Zygote.java index 3655748c83e18..992ddd8f1525d 100644 --- a/core/java/com/android/internal/os/Zygote.java +++ b/core/java/com/android/internal/os/Zygote.java @@ -412,7 +412,7 @@ public final class Zygote { return SystemProperties.get( String.join(".", "persist.device_config", - DeviceConfig.RuntimeNative.NAMESPACE, + DeviceConfig.NAMESPACE_RUNTIME_NATIVE, propertyName), defaultValue); } @@ -440,7 +440,7 @@ public final class Zygote { return SystemProperties.getBoolean( String.join(".", "persist.device_config", - DeviceConfig.RuntimeNative.NAMESPACE, + DeviceConfig.NAMESPACE_RUNTIME_NATIVE, propertyName), defaultValue); } diff --git a/core/java/com/android/internal/os/ZygoteConfig.java b/core/java/com/android/internal/os/ZygoteConfig.java new file mode 100644 index 0000000000000..c8ff51e77866a --- /dev/null +++ b/core/java/com/android/internal/os/ZygoteConfig.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.os; + +/** + * Flag names for configuring the zygote. + * + * @hide + */ +public class ZygoteConfig { + + /** If {@code true}, enables the unspecialized app process (USAP) pool feature */ + public static final String USAP_POOL_ENABLED = "blastula_pool_enabled"; + + /** The threshold used to determine if the pool should be refilled */ + public static final String USAP_POOL_REFILL_THRESHOLD = "blastula_refill_threshold"; + + /** The maximum number of processes to keep in the USAP pool */ + public static final String USAP_POOL_SIZE_MAX = "blastula_pool_size_max"; + + /** The minimum number of processes to keep in the USAP pool */ + public static final String USAP_POOL_SIZE_MIN = "blastula_pool_size_min"; +} diff --git a/core/java/com/android/internal/os/ZygoteServer.java b/core/java/com/android/internal/os/ZygoteServer.java index 7abfd85c4f423..3f3aba9b66820 100644 --- a/core/java/com/android/internal/os/ZygoteServer.java +++ b/core/java/com/android/internal/os/ZygoteServer.java @@ -22,7 +22,6 @@ import android.net.LocalServerSocket; import android.net.LocalSocket; import android.os.SystemClock; import android.os.Trace; -import android.provider.DeviceConfig; import android.system.ErrnoException; import android.system.Os; import android.system.StructPollfd; @@ -242,44 +241,33 @@ class ZygoteServer { private void fetchUsapPoolPolicyProps() { if (mUsapPoolSupported) { - final String usapPoolSizeMaxPropString = - Zygote.getConfigurationProperty( - DeviceConfig.RuntimeNative.USAP_POOL_SIZE_MAX, - USAP_POOL_SIZE_MAX_DEFAULT); + final String usapPoolSizeMaxPropString = Zygote.getConfigurationProperty( + ZygoteConfig.USAP_POOL_SIZE_MAX, USAP_POOL_SIZE_MAX_DEFAULT); if (!usapPoolSizeMaxPropString.isEmpty()) { - mUsapPoolSizeMax = - Integer.min( - Integer.parseInt(usapPoolSizeMaxPropString), - USAP_POOL_SIZE_MAX_LIMIT); + mUsapPoolSizeMax = Integer.min(Integer.parseInt( + usapPoolSizeMaxPropString), USAP_POOL_SIZE_MAX_LIMIT); } - final String usapPoolSizeMinPropString = - Zygote.getConfigurationProperty( - DeviceConfig.RuntimeNative.USAP_POOL_SIZE_MIN, - USAP_POOL_SIZE_MIN_DEFAULT); + final String usapPoolSizeMinPropString = Zygote.getConfigurationProperty( + ZygoteConfig.USAP_POOL_SIZE_MIN, USAP_POOL_SIZE_MIN_DEFAULT); if (!usapPoolSizeMinPropString.isEmpty()) { - mUsapPoolSizeMin = - Integer.max( - Integer.parseInt(usapPoolSizeMinPropString), - USAP_POOL_SIZE_MIN_LIMIT); + mUsapPoolSizeMin = Integer.max( + Integer.parseInt(usapPoolSizeMinPropString), USAP_POOL_SIZE_MIN_LIMIT); } - final String usapPoolRefillThresholdPropString = - Zygote.getConfigurationProperty( - DeviceConfig.RuntimeNative.USAP_POOL_REFILL_THRESHOLD, - Integer.toString(mUsapPoolSizeMax / 2)); + final String usapPoolRefillThresholdPropString = Zygote.getConfigurationProperty( + ZygoteConfig.USAP_POOL_REFILL_THRESHOLD, + Integer.toString(mUsapPoolSizeMax / 2)); if (!usapPoolRefillThresholdPropString.isEmpty()) { - mUsapPoolRefillThreshold = - Integer.min( - Integer.parseInt(usapPoolRefillThresholdPropString), - mUsapPoolSizeMax); + mUsapPoolRefillThreshold = Integer.min( + Integer.parseInt(usapPoolRefillThresholdPropString), + mUsapPoolSizeMax); } // Sanity check - if (mUsapPoolSizeMin >= mUsapPoolSizeMax) { Log.w(TAG, "The max size of the USAP pool must be greater than the minimum size." + " Restoring default values."); diff --git a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java index 194549f15ecff..99380c94b869c 100644 --- a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java +++ b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java @@ -83,8 +83,8 @@ public class SettingsToPropertiesMapper { DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT, DeviceConfig.NAMESPACE_MEDIA_NATIVE, DeviceConfig.NAMESPACE_NETD_NATIVE, + DeviceConfig.NAMESPACE_RUNTIME_NATIVE, DeviceConfig.NAMESPACE_RUNTIME_NATIVE_BOOT, - DeviceConfig.RuntimeNative.NAMESPACE, }; private final String[] mGlobalSettings;