Merge "Remove system-ext from test." into main
diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk
index 75e9f77..cb5575b 100644
--- a/core/android_soong_config_vars.mk
+++ b/core/android_soong_config_vars.mk
@@ -187,3 +187,8 @@
# Add use_camera_v4l2_hal flag for hardware/libhardware/modules/camera/3_4:camera.v4l2
$(call soong_config_set_bool,camera,use_camera_v4l2_hal,$(if $(filter true,$(USE_CAMERA_V4L2_HAL)),true,false))
+
+# Add audioserver_multilib flag for hardware/interfaces/soundtrigger/2.0/default:android.hardware.soundtrigger@2.0-impl
+ifneq ($(strip $(AUDIOSERVER_MULTILIB)),)
+ $(call soong_config_set,soundtrigger,audioserver_multilib,$(AUDIOSERVER_MULTILIB))
+endif
diff --git a/core/binary.mk b/core/binary.mk
index 1e98bc0..3481144 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -330,18 +330,20 @@
ifneq ($(LOCAL_IN_VENDOR),)
# Vendor modules have LOCAL_IN_VENDOR
my_cflags += -D__ANDROID_VENDOR__
-
- ifeq ($(BOARD_API_LEVEL),)
- # TODO(b/314036847): This is a fallback for UDC targets.
- # This must be a build failure when UDC is no longer built from this source tree.
- my_cflags += -D__ANDROID_VENDOR_API__=$(PLATFORM_SDK_VERSION)
- else
- my_cflags += -D__ANDROID_VENDOR_API__=$(BOARD_API_LEVEL)
- endif
else ifneq ($(LOCAL_IN_PRODUCT),)
# Product modules have LOCAL_IN_PRODUCT
my_cflags += -D__ANDROID_PRODUCT__
endif
+
+ # Define __ANDROID_VENDOR_API__ for both product and vendor variants because
+ # they both use the same LLNDK libraries.
+ ifeq ($(BOARD_API_LEVEL),)
+ # TODO(b/314036847): This is a fallback for UDC targets.
+ # This must be a build failure when UDC is no longer built from this source tree.
+ my_cflags += -D__ANDROID_VENDOR_API__=$(PLATFORM_SDK_VERSION)
+ else
+ my_cflags += -D__ANDROID_VENDOR_API__=$(BOARD_API_LEVEL)
+ endif
endif
ifndef LOCAL_IS_HOST_MODULE
diff --git a/target/product/go_defaults_common.mk b/target/product/go_defaults_common.mk
index fd4047a..0fcf16b 100644
--- a/target/product/go_defaults_common.mk
+++ b/target/product/go_defaults_common.mk
@@ -24,11 +24,6 @@
# Speed profile services and wifi-service to reduce RAM and storage.
PRODUCT_SYSTEM_SERVER_COMPILER_FILTER := speed-profile
-# Use a profile based boot image for this device. Note that this is currently a
-# generic profile and not Android Go optimized.
-PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE := true
-PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION := frameworks/base/config/boot-image-profile.txt
-
# Do not generate libartd.
PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD := false
diff --git a/tools/aconfig/aconfig_device_paths/src/HostDeviceProtosTemplate.java b/tools/aconfig/aconfig_device_paths/src/HostDeviceProtosTemplate.java
index 844232b..e2ad40a 100644
--- a/tools/aconfig/aconfig_device_paths/src/HostDeviceProtosTemplate.java
+++ b/tools/aconfig/aconfig_device_paths/src/HostDeviceProtosTemplate.java
@@ -25,6 +25,7 @@
/**
* A host lib that can read all aconfig proto file paths on a given device.
+ * This lib is only available on device with root access (userdebug/eng).
*/
public class HostDeviceProtos {
/**
@@ -40,7 +41,8 @@
};
private static final String APEX_DIR = "/apex";
- private static final String RECURSIVELY_LIST_APEX_DIR_COMMAND = "shell find /apex | grep aconfig_flags";
+ private static final String RECURSIVELY_LIST_APEX_DIR_COMMAND =
+ "shell su 0 find /apex | grep aconfig_flags";
private static final String APEX_ACONFIG_PATH_SUFFIX = "/etc/aconfig_flags.pb";
diff --git a/tools/edit_monitor/daemon_manager.py b/tools/edit_monitor/daemon_manager.py
index 79831a7..1876451 100644
--- a/tools/edit_monitor/daemon_manager.py
+++ b/tools/edit_monitor/daemon_manager.py
@@ -20,6 +20,7 @@
import pathlib
import signal
import subprocess
+import sys
import tempfile
import time
@@ -27,7 +28,8 @@
DEFAULT_PROCESS_TERMINATION_TIMEOUT_SECONDS = 1
DEFAULT_MONITOR_INTERVAL_SECONDS = 5
DEFAULT_MEMORY_USAGE_THRESHOLD = 2000
-DEFAULT_CPU_USAGE_THRESHOLD = 10
+DEFAULT_CPU_USAGE_THRESHOLD = 200
+DEFAULT_REBOOT_TIMEOUT_SECONDS = 60 * 60 * 24
def default_daemon_target():
@@ -72,6 +74,7 @@
interval: int = DEFAULT_MONITOR_INTERVAL_SECONDS,
memory_threshold: float = DEFAULT_MEMORY_USAGE_THRESHOLD,
cpu_threshold: float = DEFAULT_CPU_USAGE_THRESHOLD,
+ reboot_timeout: int = DEFAULT_REBOOT_TIMEOUT_SECONDS,
):
"""Monits the daemon process status.
@@ -80,8 +83,10 @@
given thresholds.
"""
logging.info("start monitoring daemon process %d.", self.daemon_process.pid)
-
+ reboot_time = time.time() + reboot_timeout
while self.daemon_process.is_alive():
+ if time.time() > reboot_time:
+ self.reboot()
try:
memory_usage = self._get_process_memory_percent(self.daemon_process.pid)
self.max_memory_usage = max(self.max_memory_usage, memory_usage)
@@ -119,9 +124,32 @@
if self.daemon_process and self.daemon_process.is_alive():
self._terminate_process(self.daemon_process.pid)
self._remove_pidfile()
+ logging.debug("Successfully stopped daemon manager.")
except Exception as e:
logging.exception("Failed to stop daemon manager with error %s", e)
+ def reboot(self):
+ """Reboots the current process.
+
+ Stops the current daemon manager and reboots the entire process based on
+ the binary file. Exits directly If the binary file no longer exists.
+ """
+ logging.debug("Rebooting process based on binary %s.", self.binary_path)
+
+ # Stop the current daemon manager first.
+ self.stop()
+
+ # If the binary no longer exists, exit directly.
+ if not os.path.exists(self.binary_path):
+ logging.info("binary %s no longer exists, exiting.", self.binary_path)
+ sys.exit(0)
+
+ try:
+ os.execv(self.binary_path, sys.argv)
+ except OSError as e:
+ logging.exception("Failed to reboot process with error: %s.", e)
+ sys.exit(1) # Indicate an error occurred
+
def _stop_any_existing_instance(self):
if not self.pid_file_path.exists():
logging.debug("No existing instances.")
diff --git a/tools/edit_monitor/daemon_manager_test.py b/tools/edit_monitor/daemon_manager_test.py
index 0c9e04b..bcfa850 100644
--- a/tools/edit_monitor/daemon_manager_test.py
+++ b/tools/edit_monitor/daemon_manager_test.py
@@ -197,6 +197,19 @@
mock_output.side_effect = OSError('Unknown OSError')
self.assert_run_simple_daemon_success()
+ @mock.patch('os.execv')
+ def test_monitor_daemon_reboot_triggered(self, mock_execv):
+ binary_file = tempfile.NamedTemporaryFile(
+ dir=self.working_dir.name, delete=False
+ )
+
+ dm = daemon_manager.DaemonManager(
+ binary_file.name, daemon_target=long_running_daemon
+ )
+ dm.start()
+ dm.monitor_daemon(reboot_timeout=0.5)
+ mock_execv.assert_called_once()
+
def test_stop_success(self):
dm = daemon_manager.DaemonManager(
TEST_BINARY_FILE, daemon_target=long_running_daemon
@@ -232,6 +245,52 @@
self.assert_no_subprocess_running()
self.assertTrue(dm.pid_file_path.exists())
+ @mock.patch('os.execv')
+ def test_reboot_success(self, mock_execv):
+ binary_file = tempfile.NamedTemporaryFile(
+ dir=self.working_dir.name, delete=False
+ )
+
+ dm = daemon_manager.DaemonManager(
+ binary_file.name, daemon_target=long_running_daemon
+ )
+ dm.start()
+ dm.reboot()
+
+ # Verifies the old process is stopped
+ self.assert_no_subprocess_running()
+ self.assertFalse(dm.pid_file_path.exists())
+
+ mock_execv.assert_called_once()
+
+ @mock.patch('os.execv')
+ def test_reboot_binary_no_longer_exists(self, mock_execv):
+ dm = daemon_manager.DaemonManager(
+ TEST_BINARY_FILE, daemon_target=long_running_daemon
+ )
+ dm.start()
+
+ with self.assertRaises(SystemExit) as cm:
+ dm.reboot()
+ mock_execv.assert_not_called()
+ self.assertEqual(cm.exception.code, 0)
+
+ @mock.patch('os.execv')
+ def test_reboot_failed(self, mock_execv):
+ mock_execv.side_effect = OSError('Unknown OSError')
+ binary_file = tempfile.NamedTemporaryFile(
+ dir=self.working_dir.name, delete=False
+ )
+
+ dm = daemon_manager.DaemonManager(
+ binary_file.name, daemon_target=long_running_daemon
+ )
+ dm.start()
+
+ with self.assertRaises(SystemExit) as cm:
+ dm.reboot()
+ self.assertEqual(cm.exception.code, 1)
+
def assert_run_simple_daemon_success(self):
damone_output_file = tempfile.NamedTemporaryFile(
dir=self.working_dir.name, delete=False