Merge "audio: add soong config for ims media to read" into main
diff --git a/aoc/sepolicy/aocd.te b/aoc/sepolicy/aocd.te
index b2bfd13..464e46b 100644
--- a/aoc/sepolicy/aocd.te
+++ b/aoc/sepolicy/aocd.te
@@ -20,4 +20,5 @@
# set properties
set_prop(aocd, vendor_aoc_prop)
-set_prop(aocd, vendor_timeout_aoc_prop)
\ No newline at end of file
+set_prop(aocd, vendor_timeout_aoc_prop)
+get_prop(aocd, vendor_volte_mif_off)
\ No newline at end of file
diff --git a/aoc/sepolicy/property.te b/aoc/sepolicy/property.te
index c2f5695..e6d715b 100644
--- a/aoc/sepolicy/property.te
+++ b/aoc/sepolicy/property.te
@@ -1,3 +1,4 @@
# AoC
vendor_internal_prop(vendor_aoc_prop)
-vendor_internal_prop(vendor_timeout_aoc_prop)
\ No newline at end of file
+vendor_internal_prop(vendor_timeout_aoc_prop)
+vendor_internal_prop(vendor_volte_mif_off)
diff --git a/aoc/sepolicy/property_contexts b/aoc/sepolicy/property_contexts
index 3c2acb6..475272a 100644
--- a/aoc/sepolicy/property_contexts
+++ b/aoc/sepolicy/property_contexts
@@ -1,3 +1,4 @@
# AoC
vendor.aoc.firmware.version u:object_r:vendor_aoc_prop:s0
-persist.vendor.aoc.status_request_timed_out u:object_r:vendor_timeout_aoc_prop:s0
\ No newline at end of file
+persist.vendor.aoc.status_request_timed_out u:object_r:vendor_timeout_aoc_prop:s0
+persist.vendor.radio.volte_mif_off u:object_r:vendor_volte_mif_off:s0
\ No newline at end of file
diff --git a/battery_mitigation/battery_mitigation.cpp b/battery_mitigation/battery_mitigation.cpp
index fb81b20..a4e28b9 100644
--- a/battery_mitigation/battery_mitigation.cpp
+++ b/battery_mitigation/battery_mitigation.cpp
@@ -73,6 +73,7 @@
};
const struct MitigationConfig::EventThreadConfig eventThreadCfg = {
+ .BrownoutStatsEnablePath = "/sys/devices/virtual/pmic/mitigation/br_stats/enable_br_stats",
.NumericSysfsStatPaths = {
{"cpu0_freq", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"},
{"cpu1_freq", "/sys/devices/system/cpu/cpu1/cpufreq/scaling_cur_freq"},
diff --git a/battery_mitigation/battery_mitigation.rc b/battery_mitigation/battery_mitigation.rc
index 6c8f5cc..bc95fd3 100644
--- a/battery_mitigation/battery_mitigation.rc
+++ b/battery_mitigation/battery_mitigation.rc
@@ -1,6 +1,7 @@
on property:vendor.thermal.link_ready=1
mkdir /data/vendor/mitigation 0755 system system
chown system system /data/vendor/mitigation
+ chown system system /sys/devices/virtual/pmic/mitigation/br_stats/enable_br_stats
start vendor.battery_mitigation
on property:vendor.thermal.link_ready=1 && property:ro.boot.bootreason=reboot,uvlo,pmic,if && property:sys.boot.reason=reboot,uvlo,pmic,if
diff --git a/battery_mitigation/sepolicy/vendor/battery_mitigation.te b/battery_mitigation/sepolicy/vendor/battery_mitigation.te
index 4b5bc48..ee0780a 100644
--- a/battery_mitigation/sepolicy/vendor/battery_mitigation.te
+++ b/battery_mitigation/sepolicy/vendor/battery_mitigation.te
@@ -19,7 +19,7 @@
r_dir_file(battery_mitigation, sysfs_odpm)
r_dir_file(battery_mitigation, sysfs_power_stats)
allow battery_mitigation sysfs_bcl:dir r_dir_perms;
-allow battery_mitigation sysfs_bcl:file r_file_perms;
+allow battery_mitigation sysfs_bcl:file rw_file_perms;
allow battery_mitigation sysfs_bcl:lnk_file r_file_perms;
allow battery_mitigation sysfs_thermal:lnk_file r_file_perms;
allow battery_mitigation mitigation_vendor_data_file:dir rw_dir_perms;
diff --git a/chre/README.txt b/chre/README.txt
new file mode 100644
index 0000000..3bdea2b
--- /dev/null
+++ b/chre/README.txt
@@ -0,0 +1,5 @@
+This folder contains the common settings for CHRE shared by various platforms.
+
+Dependencies among types can happen. For example, hal_contexthub_default
+depends on sysfs_aoc at the moment. When setting up a device with CHRE
+we should make sure rules of dependent types are included too.
diff --git a/chre/hal.mk b/chre/hal.mk
new file mode 100644
index 0000000..13ebb7f
--- /dev/null
+++ b/chre/hal.mk
@@ -0,0 +1,2 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/chre/sepolicy/
+PRODUCT_PACKAGES += android.hardware.contexthub-service.generic
\ No newline at end of file
diff --git a/chre/sepolicy/file_contexts b/chre/sepolicy/file_contexts
new file mode 100644
index 0000000..0659579
--- /dev/null
+++ b/chre/sepolicy/file_contexts
@@ -0,0 +1 @@
+/vendor/bin/hw/android\.hardware\.contexthub-service\.generic u:object_r:hal_contexthub_default_exec:s0
diff --git a/chre/sepolicy/hal_contexthub_default.te b/chre/sepolicy/hal_contexthub_default.te
new file mode 100644
index 0000000..3d67bd3
--- /dev/null
+++ b/chre/sepolicy/hal_contexthub_default.te
@@ -0,0 +1,33 @@
+# Allow context hub HAL to communicate with daemon via socket
+unix_socket_connect(hal_contexthub_default, chre, chre)
+
+# Permit communication with AoC
+allow hal_contexthub_default aoc_device:chr_file rw_file_perms;
+
+# Allow context hub HAL to determine AoC's current clock
+allow hal_contexthub_default sysfs_aoc:dir search;
+allow hal_contexthub_default sysfs_aoc_boottime:file r_file_perms;
+
+# Allow context hub HAL to create thread to watch AOC's device
+allow hal_contexthub_default device:dir r_dir_perms;
+
+# Allow context hub HAL to use the USF low latency transport
+usf_low_latency_transport(hal_contexthub_default)
+
+# Allow context hub HAL to talk to the WiFi HAL
+binder_call(hal_contexthub_default, hal_wifi_ext)
+allow hal_contexthub_default hal_wifi_ext_service:service_manager find;
+
+# Allow context hub HAL to talk to stats service
+binder_call(hal_contexthub_default, stats_service_server)
+allow hal_contexthub_default fwk_stats_service:service_manager find;
+
+# Allow context hub HAL to write data to /data/vendor/chre/ directory
+allow hal_contexthub_default chre_data_file:dir create_dir_perms;
+allow hal_contexthub_default chre_data_file:file create_file_perms;
+
+# Allow context hub HAL to use WakeLock
+wakelock_use(hal_contexthub_default)
+
+# Allow context hub HAL to block suspend, which is required to use EPOLLWAKEUP
+allow hal_contexthub_default self:global_capability2_class_set block_suspend;
diff --git a/display_logbuffer/Android.bp b/display_logbuffer/Android.bp
new file mode 100644
index 0000000..e2859d9
--- /dev/null
+++ b/display_logbuffer/Android.bp
@@ -0,0 +1,19 @@
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+ name: "dump_display_logbuffer",
+ srcs: ["dump_display_logbuffer.cpp"],
+ init_rc: ["init.display_logbuffer.rc"],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libdump",
+ ],
+ vendor: true,
+ relative_install_path: "dump",
+}
diff --git a/display_logbuffer/dump.mk b/display_logbuffer/dump.mk
new file mode 100644
index 0000000..9808c1d
--- /dev/null
+++ b/display_logbuffer/dump.mk
@@ -0,0 +1,3 @@
+BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/display_logbuffer/sepolicy
+
+PRODUCT_PACKAGES += dump_display_logbuffer
diff --git a/display_logbuffer/dump_display_logbuffer.cpp b/display_logbuffer/dump_display_logbuffer.cpp
new file mode 100644
index 0000000..7477c8c
--- /dev/null
+++ b/display_logbuffer/dump_display_logbuffer.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2022 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 <unistd.h>
+
+const char* logbuffer_paths[][2] = {
+ {"DSIM0", "/dev/logbuffer_dsim0"},
+ {"DSIM1", "/dev/logbuffer_dsim1"},
+};
+
+int main() {
+ for (auto &logbuffer_path : logbuffer_paths) {
+ if(!access(logbuffer_path[1], R_OK)) {
+ dumpFileContent(logbuffer_path[0], logbuffer_path[1]);
+ }
+ }
+
+ return 0;
+}
\ No newline at end of file
diff --git a/display_logbuffer/init.display_logbuffer.rc b/display_logbuffer/init.display_logbuffer.rc
new file mode 100644
index 0000000..2a39ce3
--- /dev/null
+++ b/display_logbuffer/init.display_logbuffer.rc
@@ -0,0 +1,3 @@
+on property:ro.build.type=userdebug
+ chown system system /dev/logbuffer_dsim0
+ chown system system /dev/logbuffer_dsim1
diff --git a/display_logbuffer/sepolicy/device.te b/display_logbuffer/sepolicy/device.te
new file mode 100644
index 0000000..94432f4
--- /dev/null
+++ b/display_logbuffer/sepolicy/device.te
@@ -0,0 +1 @@
+type display_log_device, dev_type;
\ No newline at end of file
diff --git a/display_logbuffer/sepolicy/dump_display_logbuffer.te b/display_logbuffer/sepolicy/dump_display_logbuffer.te
new file mode 100644
index 0000000..34da48c
--- /dev/null
+++ b/display_logbuffer/sepolicy/dump_display_logbuffer.te
@@ -0,0 +1,3 @@
+pixel_bugreport(dump_display_logbuffer)
+
+allow dump_display_logbuffer display_log_device:chr_file r_file_perms;
\ No newline at end of file
diff --git a/display_logbuffer/sepolicy/file_contexts b/display_logbuffer/sepolicy/file_contexts
new file mode 100644
index 0000000..7425214
--- /dev/null
+++ b/display_logbuffer/sepolicy/file_contexts
@@ -0,0 +1,4 @@
+/vendor/bin/dump/dump_display_logbuffer u:object_r:dump_display_logbuffer_exec:s0
+
+/dev/logbuffer_dsim0 u:object_r:display_log_device:s0
+/dev/logbuffer_dsim1 u:object_r:display_log_device:s0
diff --git a/edgetpu/sepolicy/hal_audio_default.te b/edgetpu/sepolicy/hal_audio_default.te
index 2646fcc..523770c 100644
--- a/edgetpu/sepolicy/hal_audio_default.te
+++ b/edgetpu/sepolicy/hal_audio_default.te
@@ -12,3 +12,7 @@
# Allow audio HAL to read tflite Darwinn delegate properties
get_prop(hal_audio_default, vendor_tflite_delegate_prop)
+get_prop(hal_audio_default, vendor_edgetpu_runtime_prop)
+
+# Allow DMA Buf access.
+allow hal_audio_default dmabuf_system_heap_device:chr_file r_file_perms;
diff --git a/powerstats/AdaptiveDvfsStateResidencyDataProvider.cpp b/powerstats/AdaptiveDvfsStateResidencyDataProvider.cpp
index 6e377aa..c842d3e 100644
--- a/powerstats/AdaptiveDvfsStateResidencyDataProvider.cpp
+++ b/powerstats/AdaptiveDvfsStateResidencyDataProvider.cpp
@@ -62,6 +62,14 @@
}
}
+ // Cpufreq data is sorted in ascending order, but power stats are sorted
+ // in descending order. Reverse sorting to maintain consistency with
+ // other power stats.
+ if (states.size() > 1 &&
+ std::atoll(states[0].second.c_str()) < std::atoll(states[1].second.c_str())) {
+ std::reverse(states.begin(), states.end());
+ }
+
mPowerEntities.push_back({powerEntities[i].first, std::move(states)});
}
diff --git a/powerstats/DisplayMrrStateResidencyDataProvider.cpp b/powerstats/DisplayMrrStateResidencyDataProvider.cpp
new file mode 100644
index 0000000..8ab9af4
--- /dev/null
+++ b/powerstats/DisplayMrrStateResidencyDataProvider.cpp
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+#include "DisplayMrrStateResidencyDataProvider.h"
+
+#include <android-base/logging.h>
+#include <android-base/parseint.h>
+#include <android-base/strings.h>
+
+using android::base::ParseInt;
+using android::base::ParseUint;
+using android::base::Split;
+using android::base::Trim;
+
+static const std::string TIME_IN_STATE = "time_in_state";
+static const std::string AVAILABLE_STATE = "available_disp_stats";
+static const std::vector<std::string> DISP_STATE = { "On", "HBM", "LP", "Off" };
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+
+DisplayMrrStateResidencyDataProvider::DisplayMrrStateResidencyDataProvider(
+ const std::string& name, const std::string& path) : mName(name), mPath(path) {
+ mConfigs = std::vector<Config>();
+ std::string statePath = mPath + AVAILABLE_STATE;
+ std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(statePath.c_str(), "r"), fclose);
+ if (fp) {
+ char *line = nullptr;
+ size_t len = 0;
+ Config config = { .state = 0, .resX = 0, .resY = 0, .rr = 0 };
+ while (getline(&line, &len, fp.get()) != -1) {
+ if (parseAvailableState(line, &config)) {
+ mConfigs.push_back(config);
+ } else {
+ PLOG(ERROR) << "Failed to parse display config for [" << std::string(line)
+ << "] from " << statePath;
+ mConfigs.clear();
+ break;
+ }
+ }
+ free(line);
+ } else {
+ PLOG(ERROR) << "Failed to open file " << statePath;
+ }
+}
+
+bool DisplayMrrStateResidencyDataProvider::parseConfig(
+ char const *line, Config *config, uint64_t *duration) {
+ std::vector<std::string> parts = Split(line, " ");
+
+ if (duration == nullptr) {
+ if (parts.size() != 4) return false;
+ } else {
+ if (parts.size() != 5) return false;
+
+ if (!ParseUint(Trim(parts[4]), duration)) return false;
+ }
+
+ if (!ParseInt(Trim(parts[0]), &config->state)) return false;
+ if (!ParseInt(Trim(parts[1]), &config->resX)) return false;
+ if (!ParseInt(Trim(parts[2]), &config->resY)) return false;
+ if (!ParseInt(Trim(parts[3]), &config->rr)) return false;
+
+ return true;
+}
+
+bool DisplayMrrStateResidencyDataProvider::parseAvailableState(
+ char const *line, Config *config) {
+ return parseConfig(line, config, nullptr);
+}
+
+bool DisplayMrrStateResidencyDataProvider::parseTimeInState(
+ char const *line, Config *config, uint64_t *duration) {
+ return parseConfig(line, config, duration);
+}
+
+bool DisplayMrrStateResidencyDataProvider::getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
+ if (mConfigs.empty()) {
+ LOG(ERROR) << "Display MRR state list is empty!";
+ return false;
+ }
+
+ std::string path = mPath + TIME_IN_STATE;
+ std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(path.c_str(), "r"), fclose);
+ if (!fp) {
+ PLOG(ERROR) << "Failed to open file " << path;
+ return false;
+ }
+
+ std::vector<StateResidency> stateResidencies;
+ for (int i = 0; i < mConfigs.size(); i++) {
+ StateResidency s = {.id = i, .totalTimeInStateMs = 0};
+ stateResidencies.push_back(s);
+ }
+
+ char *line = nullptr;
+ size_t len = 0;
+ Config config = { .state = 0, .resX = 0, .resY = 0, .rr = 0 };
+ uint64_t duration;
+ std::vector<Config>::const_iterator found;
+ while (getline(&line, &len, fp.get()) != -1) {
+ if (parseTimeInState(line, &config, &duration)) {
+ found = std::find(mConfigs.begin(), mConfigs.end(), config);
+ if (found != mConfigs.end()) {
+ stateResidencies[found - mConfigs.begin()].totalTimeInStateMs = duration;
+ } else {
+ LOG(ERROR) << "Failed to find config for [" << std::string(line)
+ << "] in display MRR state list";
+ }
+ } else {
+ LOG(ERROR) << "Failed to parse state and duration from [" << std::string(line) << "]";
+ free(line);
+ return false;
+ }
+ }
+
+ residencies->emplace(mName, stateResidencies);
+
+ free(line);
+
+ return true;
+}
+
+std::unordered_map<std::string, std::vector<State>> DisplayMrrStateResidencyDataProvider::getInfo()
+{
+ int32_t dispId;
+ std::string name;
+ std::vector<State> states;
+ for (int32_t id = 0; id < mConfigs.size(); id++) {
+ dispId = mConfigs[id].state;
+ if (dispId >= DISP_STATE.size()) {
+ LOG(ERROR) << "Display state id " << dispId << " is out of bound";
+ return {};
+ }
+
+ name = DISP_STATE[dispId];
+ if (dispId != DISP_STATE.size() - 1) {
+ name += ": " + std::to_string(mConfigs[id].resX) +
+ "x" + std::to_string(mConfigs[id].resY) +
+ "@" + std::to_string(mConfigs[id].rr);
+ }
+ State s = { .id = id, .name = name };
+ states.push_back(s);
+ }
+
+ return {{ mName, states }};
+}
+
+} // namespace stats
+} // namespace power
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/powerstats/TpuDvfsStateResidencyDataProvider.cpp b/powerstats/TpuDvfsStateResidencyDataProvider.cpp
new file mode 100644
index 0000000..e1ce56c
--- /dev/null
+++ b/powerstats/TpuDvfsStateResidencyDataProvider.cpp
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+#include "TpuDvfsStateResidencyDataProvider.h"
+
+#include <android-base/logging.h>
+
+static const std::string ENTITY_NAME = "TPU-DVFS";
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+
+TpuDvfsStateResidencyDataProvider::TpuDvfsStateResidencyDataProvider(
+ const std::string& path,
+ std::vector<std::string> frequencies,
+ uint64_t clockRate)
+ : mPath(path), mFrequencies(std::move(frequencies)), mClockRate(clockRate) {}
+
+bool TpuDvfsStateResidencyDataProvider::getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
+ // Using FILE* instead of std::ifstream for performance reasons
+ std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(mPath.c_str(), "r"), fclose);
+ if (!fp) {
+ PLOG(ERROR) << "Failed to open file " << mPath;
+ return false;
+ }
+
+ std::vector<StateResidency> stateResidencies;
+ for (int i = 0; i < mFrequencies.size(); i++) {
+ StateResidency s = {.id = i, .totalTimeInStateMs = 0};
+ stateResidencies.push_back(s);
+ }
+
+ char *line = nullptr;
+ size_t len = 0;
+ std::istringstream ssLine;
+ std::string split;
+ int32_t lineIdx = 0;
+ std::vector<int32_t> stateIdxMap;
+ int32_t colIdx;
+ std::vector<std::string>::const_iterator found;
+ while (getline(&line, &len, fp.get()) != -1) {
+ ssLine.clear();
+ ssLine.str(line);
+ colIdx = 0;
+ for (std::string split; std::getline(ssLine, split, ' ');) {
+ // Skip first column
+ if (split.find(':') != std::string::npos)
+ continue;
+
+ if (lineIdx == 0) {
+ // Build the state index map by first row
+ split.erase(split.find_last_not_of(" \n\r\t") + 1);
+ found = std::find(mFrequencies.begin(), mFrequencies.end(), split);
+ if (found != mFrequencies.end()) {
+ stateIdxMap.push_back(found - mFrequencies.begin());
+ } else {
+ PLOG(ERROR) << "TPU frequency " << split << " is not found in " << mPath;
+ stateIdxMap.push_back(0);
+ }
+ } else {
+ // Add up time in frequency per uid
+ stateResidencies[stateIdxMap[colIdx]].totalTimeInStateMs +=
+ std::atoll(split.c_str()) / mClockRate;
+ }
+ colIdx++;
+ }
+ lineIdx++;
+ }
+
+ residencies->emplace(ENTITY_NAME, stateResidencies);
+ return true;
+}
+
+std::unordered_map<std::string, std::vector<State>> TpuDvfsStateResidencyDataProvider::getInfo() {
+ std::vector<State> states;
+ for (int32_t id = 0; id < mFrequencies.size(); id++) {
+ State s =
+ {.id = id, .name = std::to_string(std::atol(mFrequencies[id].c_str()) / 1000) + "MHz"};
+ states.push_back(s);
+ }
+
+ return {{ENTITY_NAME, states}};
+}
+
+} // namespace stats
+} // namespace power
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/powerstats/include/DisplayMrrStateResidencyDataProvider.h b/powerstats/include/DisplayMrrStateResidencyDataProvider.h
new file mode 100644
index 0000000..81ea17e
--- /dev/null
+++ b/powerstats/include/DisplayMrrStateResidencyDataProvider.h
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+#pragma once
+
+#include <PowerStatsAidl.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+
+class DisplayMrrStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
+ public:
+ DisplayMrrStateResidencyDataProvider(const std::string& name, const std::string& path);
+ ~DisplayMrrStateResidencyDataProvider() = default;
+
+ /*
+ * See IStateResidencyDataProvider::getStateResidencies
+ */
+ bool getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
+
+ /*
+ * See IStateResidencyDataProvider::getInfo
+ */
+ std::unordered_map<std::string, std::vector<State>> getInfo() override;
+
+ private:
+ struct Config {
+ int32_t state; // Display state (On, HBM, LP, Off)
+ int32_t resX; // Resolution X
+ int32_t resY; // Resolution Y
+ int32_t rr; // Refresh rate
+
+ bool operator==(const Config& r) const {
+ return state == r.state && resX == r.resX && resY == r.resY && rr == r.rr;
+ }
+ };
+
+ bool parseConfig(char const *line, Config *config, uint64_t *duration);
+ bool parseAvailableState(char const *line, Config *config);
+ bool parseTimeInState(char const *line, Config *config, uint64_t *duration);
+ bool loadAvailableState();
+
+ const std::string mName;
+ const std::string mPath;
+ std::vector<Config> mConfigs;
+};
+
+} // namespace stats
+} // namespace power
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/powerstats/include/TpuDvfsStateResidencyDataProvider.h b/powerstats/include/TpuDvfsStateResidencyDataProvider.h
new file mode 100644
index 0000000..9ce3bd3
--- /dev/null
+++ b/powerstats/include/TpuDvfsStateResidencyDataProvider.h
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+#pragma once
+
+#include <PowerStatsAidl.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace power {
+namespace stats {
+
+class TpuDvfsStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
+ public:
+ TpuDvfsStateResidencyDataProvider(
+ const std::string& path, std::vector<std::string> frequencies, uint64_t clockRate);
+ ~TpuDvfsStateResidencyDataProvider() = default;
+
+ /*
+ * See IStateResidencyDataProvider::getStateResidencies
+ */
+ bool getStateResidencies(
+ std::unordered_map<std::string, std::vector<StateResidency>> *residencies) override;
+
+ /*
+ * See IStateResidencyDataProvider::getInfo
+ */
+ std::unordered_map<std::string, std::vector<State>> getInfo() override;
+
+ private:
+ const std::string mPath;
+ const std::vector<std::string> mFrequencies;
+ const uint64_t mClockRate;
+};
+
+} // namespace stats
+} // namespace power
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/storage/init.storage.rc b/storage/init.storage.rc
index 56e8e4f..948e820 100644
--- a/storage/init.storage.rc
+++ b/storage/init.storage.rc
@@ -1,3 +1,60 @@
on property:ro.build.type=userdebug
write /dev/sys/block/bootdevice/pixel/enable_pixel_ufs_logging 1
chown system /dev/sg3
+
+on default_storage_mode
+ # F2FS
+ write /dev/sys/fs/by-name/userdata/data_io_flag 8
+ write /dev/sys/fs/by-name/userdata/node_io_flag 8
+
+ # Block
+ write /dev/sys/block/by-name/rootdisk/queue/iostats 1
+ write /dev/sys/block/by-name/rootdisk/queue/nr_requests 128
+ write /dev/sys/block/by-name/rootdisk/queue/rq_affinity 2
+
+ # UFS
+ write /dev/sys/block/bootdevice/clkgate_enable 1
+
+on init
+ # Symlink /dev/sys/block/bootdevice
+ wait /dev/block/platform/${ro.boot.boot_devices}
+ symlink /dev/block/platform/${ro.boot.boot_devices} /dev/block/bootdevice
+ symlink /sys/devices/platform/${ro.boot.boot_devices} /dev/sys/block/bootdevice
+
+ # F2FS
+ write /dev/sys/fs/by-name/userdata/data_io_flag 56
+ write /dev/sys/fs/by-name/userdata/node_io_flag 56
+
+ # Block
+ write /dev/sys/block/by-name/rootdisk/queue/iostats 0
+ write /sys/sys/block/by-name/rootdisk/queue/nr_requests 256
+
+ # UFS
+ write /dev/sys/block/bootdevice/clkgate_enable 0
+
+on property:sys.boot_completed=1
+ # Health Storage HAL
+ chown system system /dev/sys/block/bootdevice/manual_gc
+
+ # Pixelstats
+ chown system system /dev/sys/block/bootdevice/slowio_read_cnt
+ chown system system /dev/sys/block/bootdevice/slowio_sync_cnt
+ chown system system /dev/sys/block/bootdevice/slowio_unmap_cnt
+ chown system system /dev/sys/block/bootdevice/slowio_write_cnt
+
+ chown system system /dev/sys/fs/by-name/userdata/committed_atomic_block
+ chown system system /dev/sys/fs/by-name/userdata/compr_new_inode
+ chown system system /dev/sys/fs/by-name/userdata/compr_saved_block
+ chown system system /dev/sys/fs/by-name/userdata/compr_written_block
+ chown system system /dev/sys/fs/by-name/userdata/gc_reclaimed_segments
+ chown system system /dev/sys/fs/by-name/userdata/gc_segment_mode
+ chown system system /dev/sys/fs/by-name/userdata/peak_atomic_write
+ chown system system /dev/sys/fs/by-name/userdata/revoked_atomic_block
+
+ trigger default_storage_mode
+
+on charger
+ trigger default_storage_mode
+
+on property:ro.boot.mode=charger && property:init.svc.vendor.charger=running
+ trigger default_storage_mode