Merge "aoc: add permissions for new sysfs node" into main
diff --git a/battery_mitigation/battery_mitigation.cpp b/battery_mitigation/battery_mitigation.cpp
index 101be13..cb33205 100644
--- a/battery_mitigation/battery_mitigation.cpp
+++ b/battery_mitigation/battery_mitigation.cpp
@@ -83,10 +83,17 @@
         {"voltage_now", "/sys/class/power_supply/battery/voltage_now"},
         {"current_now", "/sys/class/power_supply/battery/current_now"},
     },
-    .NumericSysfsStatDirs = {
-        {"last_triggered_mode", "/sys/devices/virtual/pmic/mitigation/last_triggered_mode/"},
-    },
     .TriggeredIdxPath = "/sys/devices/virtual/pmic/mitigation/br_stats/triggered_idx",
+    .triggeredStatePath[android::hardware::google::pixel::UVLO1] =
+        "/sys/devices/virtual/pmic/mitigation/triggered_state/uvlo1_triggered",
+    .triggeredStatePath[android::hardware::google::pixel::UVLO2] =
+        "/sys/devices/virtual/pmic/mitigation/triggered_state/uvlo2_triggered",
+    .triggeredStatePath[android::hardware::google::pixel::OILO1] =
+        "/sys/devices/virtual/pmic/mitigation/triggered_state/oilo1_triggered",
+    .triggeredStatePath[android::hardware::google::pixel::OILO2] =
+        "/sys/devices/virtual/pmic/mitigation/triggered_state/oilo2_triggered",
+    .triggeredStatePath[android::hardware::google::pixel::SMPL] =
+        "/sys/devices/virtual/pmic/mitigation/triggered_state/smpl_triggered",
     .BrownoutStatsPath = "/sys/devices/virtual/pmic/mitigation/br_stats/stats",
     .StoringPath = "/data/vendor/mitigation/thismeal.bin",
     .ParsedThismealPath = "/data/vendor/mitigation/thismeal.txt",
@@ -112,27 +119,19 @@
                 {
                     .MainPmicName = "s2mpg10-odpm\n",
                     .SubPmicName = "s2mpg11-odpm\n",
-                    .PcieModemPath = "/sys/devices/platform/11920000.pcie/power_stats",
-                    .PcieWifiPath = "/sys/devices/platform/14520000.pcie/power_stats",
                 },
                 {
                     .MainPmicName = "s2mpg12-odpm\n",
                     .SubPmicName = "s2mpg13-odpm\n",
-                    .PcieModemPath = "/sys/devices/platform/11920000.pcie/power_stats",
-                    .PcieWifiPath = "/sys/devices/platform/14520000.pcie/power_stats",
                 },
                 {
                     .MainPmicName = "s2mpg14-odpm\n",
                     .SubPmicName = "s2mpg15-odpm\n",
-                    .PcieModemPath = "/sys/devices/platform/12100000.pcie/power_stats",
-                    .PcieWifiPath = "/sys/devices/platform/13120000.pcie/power_stats",
                 },
                 /* MAX_SUPPORTED_PLATFORM */
                 {
                     .MainPmicName = "s2mpg14-odpm\n",
                     .SubPmicName = "s2mpg15-odpm\n",
-                    .PcieModemPath = "/sys/devices/platform/12100000.pcie/power_stats",
-                    .PcieWifiPath = "/sys/devices/platform/13120000.pcie/power_stats",
                 },
 
     },
@@ -188,8 +187,6 @@
             batteryMitigationService->genLastmealCSV(eventThreadCfg.ParsedLastmealCSVPath)) {
             android::base::SetProperty(kLastMealProperty, "1");
         }
-        /* Start BrownoutEventThread to poll brownout event from kernel */
-        batteryMitigationService->startBrownoutEventThread();
     } else{
         bmSp = new BatteryMitigation(cfg);
         if (!bmSp) {
@@ -226,6 +223,10 @@
     if (isBatteryMitigationReady) {
         android::base::SetProperty(kReadyProperty, "1");
     }
+    if (isBatteryMitigationReady && brownoutStatsBinarySupported) {
+        /* Start BrownoutEventThread to poll brownout event from kernel */
+        batteryMitigationService->startBrownoutEventThread();
+    }
     while (true) {
         pause();
     }
diff --git a/camera/sepolicy/product/private/service_contexts b/camera/sepolicy/product/private/service_contexts
new file mode 100644
index 0000000..fed03af
--- /dev/null
+++ b/camera/sepolicy/product/private/service_contexts
@@ -0,0 +1 @@
+com.google.pixel.camera.services.binder.IServiceBinder/default u:object_r:camera_binder_service:s0
\ No newline at end of file
diff --git a/camera/sepolicy/product/private/vendor_pbcs_app.te b/camera/sepolicy/product/private/vendor_pbcs_app.te
index d77162e..54bc0c0 100644
--- a/camera/sepolicy/product/private/vendor_pbcs_app.te
+++ b/camera/sepolicy/product/private/vendor_pbcs_app.te
@@ -7,3 +7,6 @@
 allow vendor_pbcs_app app_api_service:service_manager find;
 # Allow PBCS to find Camera Service.
 allow vendor_pbcs_app cameraserver_service:service_manager find;
+
+# Allow PBCS to add the ServiceBinder service to ServiceManager.
+add_service(vendor_pbcs_app, camera_binder_service);
\ No newline at end of file
diff --git a/camera/sepolicy/product/public/service.te b/camera/sepolicy/product/public/service.te
new file mode 100644
index 0000000..f94fd9f
--- /dev/null
+++ b/camera/sepolicy/product/public/service.te
@@ -0,0 +1 @@
+type camera_binder_service, hal_service_type, protected_service, service_manager_type;
\ No newline at end of file
diff --git a/camera/sepolicy/vendor/hal_camera_default.te b/camera/sepolicy/vendor/hal_camera_default.te
index dd00cc3..4c9aa05 100644
--- a/camera/sepolicy/vendor/hal_camera_default.te
+++ b/camera/sepolicy/vendor/hal_camera_default.te
@@ -1,4 +1,4 @@
-allow hal_camera_default vendor_camera_binder_service:service_manager find;
+allow hal_camera_default camera_binder_service:service_manager find;
 # Allow Lyric Hal to find the LyricConfigProvider service through ServiceManager.
 allow hal_camera_default vendor_camera_lyricconfigprovider_service:service_manager find;
 
diff --git a/camera/sepolicy/vendor/service.te b/camera/sepolicy/vendor/service.te
index 877dbc1..87a1d93 100644
--- a/camera/sepolicy/vendor/service.te
+++ b/camera/sepolicy/vendor/service.te
@@ -1,5 +1,3 @@
-type vendor_camera_binder_service, hal_service_type, protected_service, service_manager_type;
-
 type hal_pixel_remote_camera_service, hal_service_type, protected_service, service_manager_type;
 
 type vendor_camera_lyricconfigprovider_service, hal_service_type, protected_service, service_manager_type;
diff --git a/camera/sepolicy/vendor/service_contexts b/camera/sepolicy/vendor/service_contexts
index e6eaa64..1bcaab8 100644
--- a/camera/sepolicy/vendor/service_contexts
+++ b/camera/sepolicy/vendor/service_contexts
@@ -1,5 +1,3 @@
-com.google.pixel.camera.services.binder.IServiceBinder/default u:object_r:vendor_camera_binder_service:s0
-
 com.google.pixel.camera.connectivity.hal.provider.ICameraProvider/default u:object_r:hal_pixel_remote_camera_service:s0
 
 com.google.pixel.camera.services.lyricconfigprovider.ILyricConfigProvider/default u:object_r:vendor_camera_lyricconfigprovider_service:s0
diff --git a/camera/sepolicy/vendor/vendor_pbcs_app.te b/camera/sepolicy/vendor/vendor_pbcs_app.te
index 7b9c5e2..b25c9a2 100644
--- a/camera/sepolicy/vendor/vendor_pbcs_app.te
+++ b/camera/sepolicy/vendor/vendor_pbcs_app.te
@@ -1,5 +1,5 @@
 # Allow PBCS to add the ServiceBinder service to ServiceManager.
-add_service(vendor_pbcs_app, vendor_camera_binder_service);
+add_service(vendor_pbcs_app, camera_binder_service);
 # Allow PBCS to add the LyricConfigProvider service to ServiceManager.
 add_service(vendor_pbcs_app, vendor_camera_lyricconfigprovider_service);
 # Allow PBCS to add the CameraIdRemapper service to ServiceManager.
diff --git a/gyotaku_app/sepolicy/gyotaku_app.te b/gyotaku_app/sepolicy/gyotaku_app.te
index 80123cf..867ec4c 100644
--- a/gyotaku_app/sepolicy/gyotaku_app.te
+++ b/gyotaku_app/sepolicy/gyotaku_app.te
@@ -22,4 +22,7 @@
 
   # For persistent property use
   get_prop(gyotaku_app, logpersistd_logging_prop);
+
+  # For access hal_power_stats
+  hal_client_domain(gyotaku_app, hal_power_stats);
 ')
diff --git a/pixel_metrics/dump_pixel_metrics.cpp b/pixel_metrics/dump_pixel_metrics.cpp
index 2dd5553..597d765 100644
--- a/pixel_metrics/dump_pixel_metrics.cpp
+++ b/pixel_metrics/dump_pixel_metrics.cpp
@@ -21,6 +21,7 @@
     setbuf(stdout, NULL);
     dumpFileContent("Long running IRQ metrics", "/sys/kernel/metrics/irq/long_irq_metrics");
     dumpFileContent("Storm IRQ metrics", "/sys/kernel/metrics/irq/storm_irq_metrics");
+    dumpFileContent("Long RT Runnable metrics", "/sys/kernel/metrics/runnable/stats");
     dumpFileContent("Resume latency metrics", "/sys/kernel/metrics/resume_latency/resume_latency_metrics");
     return 0;
 }
diff --git a/pixel_metrics/sepolicy/genfs_contexts b/pixel_metrics/sepolicy/genfs_contexts
index 45ba566..c58fbe7 100644
--- a/pixel_metrics/sepolicy/genfs_contexts
+++ b/pixel_metrics/sepolicy/genfs_contexts
@@ -3,5 +3,7 @@
 genfscon sysfs /kernel/metrics/irq/long_irq_metrics                       u:object_r:sysfs_vendor_metrics:s0
 genfscon sysfs /kernel/metrics/irq/stats_reset                            u:object_r:sysfs_vendor_metrics:s0
 genfscon sysfs /kernel/metrics/irq/storm_irq_metrics                      u:object_r:sysfs_vendor_metrics:s0
+genfscon sysfs /kernel/metrics/runnable/stats_reset                       u:object_r:sysfs_vendor_metrics:s0
+genfscon sysfs /kernel/metrics/runnable/stats                             u:object_r:sysfs_vendor_metrics:s0
 genfscon sysfs /kernel/metrics/thermal/tr_by_group/tmu/stats              u:object_r:sysfs_vendor_metrics:s0
 genfscon sysfs /kernel/metrics/thermal/tr_by_group/spmic/stats            u:object_r:sysfs_vendor_metrics:s0
diff --git a/thermal/thermal_hal/thermal_config_schemas/Android.bp b/thermal/thermal_hal/thermal_config_schemas/Android.bp
new file mode 100644
index 0000000..ed66305
--- /dev/null
+++ b/thermal/thermal_hal/thermal_config_schemas/Android.bp
@@ -0,0 +1,17 @@
+cc_library_static {
+    name: "thermal_HAL_info_config_proto",
+    host_supported: true,
+    srcs: [
+        "thermal_info_config.proto",
+    ],
+    proto: {
+        type: "full",
+        export_proto_headers: true,
+        include_dirs: ["external/protobuf/src"],
+    },
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-Wno-unused-parameter",
+    ],
+}
\ No newline at end of file
diff --git a/thermal/thermal_hal/thermal_config_schemas/thermal_info_config.proto b/thermal/thermal_hal/thermal_config_schemas/thermal_info_config.proto
new file mode 100644
index 0000000..c97fa7f
--- /dev/null
+++ b/thermal/thermal_hal/thermal_config_schemas/thermal_info_config.proto
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+syntax = "proto3";
+
+package devices.shusky;
+
+message ThermalConfig {
+  repeated Sensor sensors = 1 [ json_name = "Sensors" ];
+  repeated CoolingDevice coolingdevices = 2 [ json_name = "CoolingDevices" ];
+  repeated PowerRails powerrails = 3 [ json_name = "PowerRails" ];
+  Stats stats = 4 [ json_name = "Stats" ];
+}
+
+message Sensor {
+  string name = 1 [ json_name = "Name" ];
+  string type = 2 [ json_name = "Type" ];
+  repeated float hotthreshold = 3 [ json_name = "HotThreshold" ];
+  repeated float hothysteresis = 4 [ json_name = "HotHysteresis" ];
+  string temppath = 5 [ json_name = "TempPath" ];
+  float multiplier = 6 [ json_name = "Multiplier" ];
+  int32 pollingdelay = 7 [ json_name = "PollingDelay" ];
+  int32 passivedelay = 8 [ json_name = "PassiveDelay" ];
+  bool hidden = 9 [ json_name = "Hidden" ];
+  bool virtualsensor = 10 [ json_name = "VirtualSensor" ];
+  repeated string triggersensor = 11 [ json_name = "TriggerSensor" ];
+  string formula = 12 [ json_name = "Formula" ];
+  repeated string combination = 13 [ json_name = "Combination" ];
+  repeated float Coefficient = 14 [ json_name = "Coefficient" ];
+  bool sendpowerhint = 15 [ json_name = "SendPowerHint" ];
+  bool sendcallback = 16 [ json_name = "SendCallback" ];
+  PIDInfo pidinfo = 17 [ json_name = "PIDInfo" ];
+  repeated ExcludedPowerInfo excludedpowerinfo = 18
+      [ json_name = "ExcludedPowerInfo" ];
+  repeated BindedCdevInfo bindedcdevinfos = 19 [ json_name = "BindedCdevInfo" ];
+  repeated string combinationtype = 20 [ json_name = "CombinationType" ];
+  string version = 21 [ json_name = "Version" ];
+  int32 offset = 22 [ json_name = "Offset" ];
+  repeated Profile profile = 23 [ json_name = "Profile" ];
+  float vrthreshold = 24 [ json_name = "VrThreshold" ];
+  bool monitor = 25 [ json_name = "Monitor" ];
+}
+
+message Profile {
+  string mode = 1 [ json_name = "Mode" ];
+  repeated BindedCdevInfo bindedcdevinfo = 2 [ json_name = "BindedCdevInfo" ];
+}
+
+message ExcludedPowerInfo {
+  string powerrail = 1 [ json_name = "PowerRail" ];
+  repeated float powerweight = 2 [ json_name = "PowerWeight" ];
+}
+
+message BindedCdevInfo {
+  string cdevrequest = 1 [ json_name = "CdevRequest" ];
+  repeated float cdevweightforpid = 2 [ json_name = "CdevWeightForPID" ];
+  int32 maxreleasestep = 3 [ json_name = "MaxReleaseStep" ];
+  int32 maxthrottlestep = 4 [ json_name = "MaxThrottleStep" ];
+  repeated int32 cdevceiling = 5 [ json_name = "CdevCeiling" ];
+  repeated int32 limitinfo = 6 [ json_name = "LimitInfo" ];
+  string bindedpowerrail = 7 [ json_name = "BindedPowerRail" ];
+  bool disabled = 8 [ json_name = "Disabled" ];
+}
+
+message PIDInfo {
+  repeated float k_po = 1 [ json_name = "K_Po" ];
+  repeated float k_pu = 2 [ json_name = "K_Pu" ];
+  repeated float k_i = 3 [ json_name = "K_I" ];
+  repeated float k_d = 4 [ json_name = "K_D" ];
+  repeated float i_max = 5 [ json_name = "I_Max" ];
+  repeated float s_power = 6 [ json_name = "S_Power" ];
+  repeated float minallocpower = 7 [ json_name = "MinAllocPower" ];
+  repeated float maxallocpower = 8 [ json_name = "MaxAllocPower" ];
+  repeated float i_cutoff = 9 [ json_name = "I_Cutoff" ];
+  int32 i_default = 10 [ json_name = "I_Default" ];
+}
+
+message CoolingDevice {
+  string name = 1 [ json_name = "Name" ];
+  string type = 2 [ json_name = "Type" ];
+  string writepath = 3 [ json_name = "WritePath" ];
+  repeated int32 state2power = 4 [ json_name = "State2Power" ];
+}
+
+message PowerRails {
+  string name = 1 [ json_name = "Name" ];
+  int32 powersampledelay = 2 [ json_name = "PowerSampleDelay" ];
+  int32 powersamplecount = 3 [ json_name = "PowerSampleCount" ];
+  bool virtualrails = 4 [ json_name = "VirtualRails" ];
+  string formula = 5 [ json_name = "Formula" ];
+  repeated string combination = 6 [ json_name = "Combination" ];
+  repeated float coefficient = 7 [ json_name = "Coefficient" ];
+}
+
+message Stats {
+  SensorStats sensorstats = 1 [ json_name = "Sensors" ];
+  CoolingDeviceStats coolingdevicestats = 2 [ json_name = "CoolingDevices" ];
+}
+
+message SensorStats {
+  repeated string recordwithdefaultthreshold = 1
+      [ json_name = "RecordWithDefaultThreshold" ];
+  repeated SensorStat recordwiththreshold = 2
+      [ json_name = "RecordWithThreshold" ];
+  Abnormality abnormality = 3 [ json_name = "Abnormality" ];
+}
+
+message CoolingDeviceStats {
+  RecordVotePerSensor recordvotepersensor = 1
+      [ json_name = "RecordVotePerSensor" ];
+}
+
+message RecordVotePerSensor {
+  bool defaultthresholdenableall = 1
+      [ json_name = "DefaultThresholdEnableAll" ];
+}
+
+message SensorStat {
+  string name = 1 [ json_name = "Name" ];
+  repeated int32 thresholds = 2 [ json_name = "Thresholds" ];
+}
+
+message Abnormality {
+  Outlier outlier = 1 [ json_name = "Outlier" ];
+  Stuck stuck = 2 [ json_name = "Stuck" ];
+}
+
+message Outlier { repeated Config configs = 1 [ json_name = "Configs" ]; }
+
+message Stuck { repeated Config configs = 1 [ json_name = "Configs" ]; }
+
+message Config {
+  repeated string monitor = 1 [ json_name = "Monitor" ];
+  TempStuck tempstuck = 2 [ json_name = "TempStuck" ];
+  repeated float temprange = 3 [ json_name = "TempRange" ];
+}
+
+message TempStuck {
+  int32 minpollingcount = 1 [ json_name = "MinPollingCount" ];
+  int32 minstuckduration = 2 [ json_name = "MinStuckDuration" ];
+}
diff --git a/widevine/widevine.mk b/widevine/widevine.mk
index a8ffcc5..420806e 100644
--- a/widevine/widevine.mk
+++ b/widevine/widevine.mk
@@ -3,6 +3,9 @@
 
 ifdef RELEASE_PACKAGE_WIDEVINE
   PRODUCT_PACKAGES += $(RELEASE_PACKAGE_WIDEVINE)
+  ifneq ($(wildcard vendor/google/dev-keystore),)
+    $(call soong_config_set,widevine,use_devkey,true)
+  endif
   PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS += \
 	vendor/widevine/libwvdrmengine/apex/device/linker.config.json
 else
diff --git a/wireless_charger/compatibility_matrix.xml b/wireless_charger/compatibility_matrix.xml
index 85ee65a..7d18cd9 100644
--- a/wireless_charger/compatibility_matrix.xml
+++ b/wireless_charger/compatibility_matrix.xml
@@ -1,7 +1,7 @@
 <compatibility-matrix version="1.0" type="framework">
     <hal format="aidl" optional="true">
         <name>vendor.google.wireless_charger</name>
-        <version>1</version>
+        <version>1-2</version>
         <interface>
             <name>IWirelessCharger</name>
             <instance>default</instance>