Merge "gs-common/esim: include sysprop setupwizard.feature.provisioning_profile_mode" into main
diff --git a/camera/lyric.mk b/camera/lyric.mk
index c886138..0ec1d6d 100644
--- a/camera/lyric.mk
+++ b/camera/lyric.mk
@@ -20,8 +20,20 @@
 # All shipping releases will switch to prebuilts (trunk+)
 # if this condition is not true, then build from source.
 
-ifneq ($(RELEASE_PIXEL_CAMERA_ENABLE_PREBUILT),true)
+# Fallback if the prebuilts directory does not exist, then we must
+# build from source no matter what, so we log a warning
+ifeq ($(RELEASE_PIXEL_CAMERA_ENABLE_PREBUILT),true)
+  ifeq ($(wildcard vendor/google/services/LyricCameraHAL/prebuilt),)
+    $(warning Lyric prebuilt directory is missing, it will be built from source)
+    BUILD_LYRIC_FROM_SOURCE := true
+  else
+    BUILD_LYRIC_FROM_SOURCE := false
+  endif
+else
+  BUILD_LYRIC_FROM_SOURCE := true
+endif  # RELEASE_PIXEL_CAMERA_ENABLE_PREBUILT
 
+ifeq ($(BUILD_LYRIC_FROM_SOURCE),true)
 PRODUCT_SOONG_NAMESPACES += \
     vendor/google/camera \
     vendor/google/camera/google_3a/libs_v4 \
@@ -41,7 +53,7 @@
 # Calibration tool for debug builds
 PRODUCT_PACKAGES_DEBUG += tarasque_test
 PRODUCT_PACKAGES_DEBUG += ProtoCalibGenerator
-endif  # RELEASE_PIXEL_CAMERA_ENABLE_PREBUILT check
+endif  # BUILD_LYRIC_FROM_SOURCE
 
 # Init-time log settings for Google 3A
 PRODUCT_PACKAGES += libg3a_standalone_gabc_rc
diff --git a/camera/lyric_soong_variables.md b/camera/lyric_soong_variables.md
index b442943..4289109 100644
--- a/camera/lyric_soong_variables.md
+++ b/camera/lyric_soong_variables.md
@@ -44,3 +44,13 @@
 $(call soong_config_set,google3a_config,target_device,oriole)
 ```
 A mixture of `camera_hardware` and `tuning_product` used by 3A.
+
+## `radioext_interface_type`
+
+Example:
+```
+$(call soong_config_set,lyric,radioext_interface_type,aidl)
+```
+Specifies which interface type to use in the RadioExt client when communicating
+with the RadioExt service. The possible values are "hidl" and "aidl".
+Devices launching with Android 15 no longer support HIDL.
diff --git a/gps/dump/dump_gps.cpp b/gps/dump/dump_gps.cpp
index e073732..7906a1f 100644
--- a/gps/dump/dump_gps.cpp
+++ b/gps/dump/dump_gps.cpp
@@ -17,6 +17,7 @@
 #include <android-base/properties.h>
 #include <dirent.h>
 #include <dump/pixel_dump.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
@@ -66,6 +67,58 @@
   return;
 }
 
+int compareFileExtensions(const struct dirent **a, const struct dirent **b) {
+    int num_a, num_b;
+    sscanf((*a)->d_name, "rawbinlog.out.%d", &num_a);
+    sscanf((*b)->d_name, "rawbinlog.out.%d", &num_b);
+
+    return num_a - num_b;
+}
+
+void dumpLogsAscending(const char* SrcDir, const char* DestDir, int limit, const char* prefix) {
+
+    struct dirent **dirent_list = NULL;
+    int num_entries = scandir(SrcDir, &dirent_list, 0, (int (*)(const struct dirent **, const struct dirent **)) alphasort);
+    if (!dirent_list) {
+        printf("Unable to scan dir: %s.\n", SrcDir);
+        return;
+    } else if (num_entries <= 0) {
+        printf("No file is found.\n");
+        return;
+    }
+
+    if (access(DestDir, R_OK)) {
+        printf("Unable to find folder: %s\n", DestDir);
+        return;
+    }
+
+    qsort(dirent_list, num_entries, sizeof(struct dirent *), (int (*)(const void *, const void *)) compareFileExtensions);
+
+    int copiedFiles = 0;
+
+    for (int i = 0 ; i < num_entries; i++) {
+
+        if (0 != strncmp(dirent_list[i]->d_name, prefix, strlen(prefix))) {
+            continue;
+        }
+
+        if ((copiedFiles >= limit) && (limit != -1)) {
+            printf("Skipped %s\n", dirent_list[i]->d_name);
+            continue;
+        }
+
+        copiedFiles++;
+        copyFile(concatenatePath(SrcDir, dirent_list[i]->d_name).c_str(), concatenatePath(DestDir, dirent_list[i]->d_name).c_str());
+    }
+
+    while (num_entries--) {
+        free(dirent_list[num_entries]);
+    }
+
+    free(dirent_list);
+    return;
+}
+
 int main() {
     if(!::android::base::GetBoolProperty("vendor.gps.aol.enabled", false)) {
         printf("vendor.gps.aol.enabled is false. gps logging is not running.\n");
@@ -85,9 +138,8 @@
     if (access(GPS_VENDOR_CHIP_INFO, F_OK) == 0) {
         copyFile(GPS_VENDOR_CHIP_INFO, concatenatePath(outputDir.c_str(), "chip.info").c_str());
     }
-    dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), maxFileNum, GPS_RAWLOG_PREFIX);
+    dumpLogsAscending(GPS_LOG_DIRECTORY, outputDir.c_str(), 5, GPS_RAWLOG_PREFIX);
     dumpLogs(GPS_LOG_DIRECTORY, outputDir.c_str(), 18, GPS_MEMDUMP_LOG_PREFIX);
     copyDirectory(GPS_RESOURCE_DIRECTORY, concatenatePath(outputDir.c_str(), "resource"));
     return 0;
 }
-
diff --git a/interrupts/Android.bp b/interrupts/Android.bp
new file mode 100644
index 0000000..a4f62bc
--- /dev/null
+++ b/interrupts/Android.bp
@@ -0,0 +1,21 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+    name: "dump_interrupts_traces",
+    srcs: ["traces/dump_interrupts_traces.cpp"],
+    init_rc: ["init.interrupts.rc"],
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    shared_libs: [
+        "libbase",
+        "libdump",
+        "liblog",
+    ],
+    vendor: true,
+    relative_install_path: "dump",
+}
diff --git a/interrupts/init.interrupts.rc b/interrupts/init.interrupts.rc
new file mode 100644
index 0000000..9492fdc
--- /dev/null
+++ b/interrupts/init.interrupts.rc
@@ -0,0 +1,23 @@
+on init
+    # Create the directory for the trace instance during early init
+    mkdir /sys/kernel/tracing/instances/irq_gia_google 0755 root root
+    chown system system /sys/kernel/tracing/instances/irq_gia_google
+    chown system system /sys/kernel/tracing/instances/irq_gia_google/trace
+
+    # Enable gia events
+    write /sys/kernel/tracing/instances/irq_gia_google/events/irq_gia/enable 1
+
+    # There are some very high frequency IRQ events happening all the time. Tracing
+    # them is not absolute necessity, but a flood of them is noise for more interesting
+    # events that we want to capture. All these high frequency IRQs have virq < 11.
+    write /sys/kernel/tracing/instances/irq_gia_google/events/irq/filter "irq > 11"
+    write /sys/kernel/tracing/instances/irq_gia_google/events/irq/irq_handler_entry/enable 1
+    write /sys/kernel/tracing/instances/irq_gia_google/events/irq/irq_handler_exit/enable 1
+
+    # Keep the buffer size small. This size is practically enough for debug purpose.
+    # Having low size helps because this entire buffer gets dumped in bugreport.
+    # Having a large size can impact bugreport size and time it takes to pack/unpack.
+    write /sys/kernel/tracing/instances/irq_gia_google/buffer_size_kb 512
+
+    # Go!
+    write /sys/kernel/tracing/instances/irq_gia_google/tracing_on 1
diff --git a/interrupts/interrupts.mk b/interrupts/interrupts.mk
new file mode 100644
index 0000000..bf14f97
--- /dev/null
+++ b/interrupts/interrupts.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/interrupts/traces/sepolicy
+
+PRODUCT_PACKAGES += dump_interrupts_traces
diff --git a/interrupts/traces/dump_interrupts_traces.cpp b/interrupts/traces/dump_interrupts_traces.cpp
new file mode 100644
index 0000000..da747a3
--- /dev/null
+++ b/interrupts/traces/dump_interrupts_traces.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2024 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.
+ */
+#include <dump/pixel_dump.h>
+#include <android-base/file.h>
+
+int main() {
+    std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "interrupts");
+    if (mkdir(outputDir.c_str(), 0777) == -1) {
+        printf("Unable to create folder: %s\n", outputDir.c_str());
+        return 0;
+    }
+
+    copyFile("/sys/kernel/tracing/instances/irq_gia_google/trace",
+             concatenatePath(outputDir.c_str(), "interrupts_trace").c_str());
+
+    return 0;
+}
diff --git a/interrupts/traces/sepolicy/dump_interrupts_traces.te b/interrupts/traces/sepolicy/dump_interrupts_traces.te
new file mode 100644
index 0000000..bc3952a
--- /dev/null
+++ b/interrupts/traces/sepolicy/dump_interrupts_traces.te
@@ -0,0 +1,7 @@
+#
+pixel_bugreport(dump_interrupts_traces)
+
+allow dump_interrupts_traces radio_vendor_data_file:dir { search add_name create write };
+allow dump_interrupts_traces radio_vendor_data_file:file { getattr create write open };
+allow dump_interrupts_traces debugfs_tracing_instances:dir search;
+allow dump_interrupts_traces tracefs_instances_interrupts:file { getattr read open };
diff --git a/interrupts/traces/sepolicy/file.te b/interrupts/traces/sepolicy/file.te
new file mode 100644
index 0000000..4decea9
--- /dev/null
+++ b/interrupts/traces/sepolicy/file.te
@@ -0,0 +1,2 @@
+#
+type tracefs_instances_interrupts, sysfs_type, fs_type;
diff --git a/interrupts/traces/sepolicy/file_contexts b/interrupts/traces/sepolicy/file_contexts
new file mode 100644
index 0000000..5a010e9
--- /dev/null
+++ b/interrupts/traces/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/dump/dump_interrupts_traces          u:object_r:dump_interrupts_traces_exec:s0
diff --git a/interrupts/traces/sepolicy/genfs_contexts b/interrupts/traces/sepolicy/genfs_contexts
new file mode 100644
index 0000000..70223b7
--- /dev/null
+++ b/interrupts/traces/sepolicy/genfs_contexts
@@ -0,0 +1 @@
+genfscon tracefs /instances/irq_gia_google/trace u:object_r:tracefs_instances_interrupts:s0
diff --git a/modem/shared_modem_platform/sepolicy/file_contexts b/modem/shared_modem_platform/sepolicy/file_contexts
deleted file mode 100644
index 2598585..0000000
--- a/modem/shared_modem_platform/sepolicy/file_contexts
+++ /dev/null
@@ -1,2 +0,0 @@
-# modem_svc_sit
-/vendor/bin/shared_modem_platform   u:object_r:modem_svc_sit_exec:s0
diff --git a/modem/shared_modem_platform/sepolicy/modem_svc_sit.te b/modem/shared_modem_platform/sepolicy/modem_svc_sit.te
deleted file mode 100644
index b1ed074..0000000
--- a/modem/shared_modem_platform/sepolicy/modem_svc_sit.te
+++ /dev/null
@@ -1,2 +0,0 @@
-# Modem SVC will register the default instance of the AIDL ISharedModemPlatform hal.
-hal_server_domain(modem_svc_sit, hal_shared_modem_platform)
diff --git a/modem/shared_modem_platform/shared_modem_platform.mk b/modem/shared_modem_platform/shared_modem_platform.mk
index 0a3be6d..3f50c37 100644
--- a/modem/shared_modem_platform/shared_modem_platform.mk
+++ b/modem/shared_modem_platform/shared_modem_platform.mk
@@ -8,4 +8,4 @@
 
 PRODUCT_PACKAGES += shared_modem_platform
 DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE += device/google/gs-common/modem/shared_modem_platform/compatibility_matrix.xml
-BOARD_SEPOLICY_DIRS += device/google/gs-common/modem/shared_modem_platform/sepolicy
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/modem/shared_modem_platform/sepolicy
diff --git a/performance/Android.bp b/performance/Android.bp
index 5c0e0b2..6dae537 100644
--- a/performance/Android.bp
+++ b/performance/Android.bp
@@ -5,7 +5,10 @@
 cc_binary {
     name: "dump_perf",
     srcs: ["dump_perf.cpp"],
-    init_rc: ["init.pixel-mm-gs.rc"],
+    init_rc: [
+        "init.pixel-mm-gs.rc",
+        "init.pixel-perf.rc",
+    ],
     cflags: [
         "-Wall",
         "-Wextra",
diff --git a/performance/init.pixel-perf.rc b/performance/init.pixel-perf.rc
new file mode 100644
index 0000000..36c487f
--- /dev/null
+++ b/performance/init.pixel-perf.rc
@@ -0,0 +1,45 @@
+# Copyright (C) 2024 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.
+
+on init
+    # cpufreq governor setting
+    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor sched_pixel
+    write /sys/devices/system/cpu/cpu8/cpufreq/scaling_governor sched_pixel
+
+    write /sys/devices/system/cpu/cpu0/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu1/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu2/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu3/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu4/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu5/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu6/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu7/cpufreq/sched_pixel/up_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu8/cpufreq/sched_pixel/up_rate_limit_us 500
+
+    write /sys/devices/system/cpu/cpu0/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu1/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu2/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu3/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu4/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu5/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu6/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu7/cpufreq/sched_pixel/down_rate_limit_us 500
+    write /sys/devices/system/cpu/cpu8/cpufreq/sched_pixel/down_rate_limit_us 500