Snap for 9470759 from a3792b2a2f26a8a11ec530c2ba1d3d52a57b2304 to udc-release
Change-Id: I2680e7d1d1cae5f7497eb0bb0f83bec79db17ae8
This commit is contained in:
commit
325ca8bbcb
146
powerstats/CpupmStateResidencyDataProvider.cpp
Normal file
146
powerstats/CpupmStateResidencyDataProvider.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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 "CpupmStateResidencyDataProvider.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/parseint.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using android::base::ParseUint;
|
||||
using android::base::Split;
|
||||
using android::base::StartsWith;
|
||||
using android::base::Trim;
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace stats {
|
||||
|
||||
CpupmStateResidencyDataProvider::CpupmStateResidencyDataProvider(
|
||||
const std::string &path, const Config &config)
|
||||
: mPath(std::move(path)), mConfig(std::move(config)) {}
|
||||
|
||||
int32_t CpupmStateResidencyDataProvider::matchState(char const *line) {
|
||||
for (int32_t i = 0; i < mConfig.states.size(); i++) {
|
||||
if (mConfig.states[i].second == Trim(std::string(line))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t CpupmStateResidencyDataProvider::matchEntity(char const *line) {
|
||||
for (int32_t i = 0; i < mConfig.entities.size(); i++) {
|
||||
if (StartsWith(Trim(std::string(line)), mConfig.entities[i].second)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CpupmStateResidencyDataProvider::parseState(
|
||||
char const *line, uint64_t *duration, uint64_t *count) {
|
||||
std::vector<std::string> parts = Split(line, " ");
|
||||
if (parts.size() != 5) {
|
||||
return false;
|
||||
}
|
||||
if (!ParseUint(Trim(parts[1]), count)) {
|
||||
return false;
|
||||
}
|
||||
if (!ParseUint(Trim(parts[3]), duration)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CpupmStateResidencyDataProvider::getStateResidencies(
|
||||
std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
|
||||
std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(mPath.c_str(), "r"), fclose);
|
||||
if (!fp) {
|
||||
PLOG(ERROR) << __func__ << ":Failed to open file " << mPath;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < mConfig.entities.size(); i++) {
|
||||
std::vector<StateResidency> stateResidencies(mConfig.states.size());
|
||||
for (int32_t j = 0; j < stateResidencies.size(); j++) {
|
||||
stateResidencies[j].id = j;
|
||||
}
|
||||
residencies->emplace(mConfig.entities[i].first, stateResidencies);
|
||||
}
|
||||
|
||||
size_t len = 0;
|
||||
char *line = nullptr;
|
||||
|
||||
int32_t temp, entityIndex, stateId = -1;
|
||||
uint64_t duration, count;
|
||||
auto it = residencies->end();
|
||||
|
||||
while (getline(&line, &len, fp.get()) != -1) {
|
||||
temp = matchState(line);
|
||||
// Assign new id only when a new valid state is encountered.
|
||||
if (temp >= 0) {
|
||||
stateId = temp;
|
||||
}
|
||||
|
||||
if (stateId >= 0) {
|
||||
entityIndex = matchEntity(line);
|
||||
it = residencies->find(mConfig.entities[entityIndex].first);
|
||||
|
||||
if (it != residencies->end()) {
|
||||
if (parseState(line, &duration, &count)) {
|
||||
it->second[stateId].totalTimeInStateMs = duration / US_TO_MS;
|
||||
it->second[stateId].totalStateEntryCount = count;
|
||||
} else {
|
||||
LOG(ERROR) << "Failed to parse duration and count from [" << std::string(line)
|
||||
<< "]";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(line);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::vector<State>> CpupmStateResidencyDataProvider::getInfo() {
|
||||
std::unordered_map<std::string, std::vector<State>> info;
|
||||
for (auto const &entity : mConfig.entities) {
|
||||
std::vector<State> stateInfo(mConfig.states.size());
|
||||
int32_t stateId = 0;
|
||||
for (auto const &state : mConfig.states) {
|
||||
stateInfo[stateId] = State{
|
||||
.id = stateId,
|
||||
.name = state.first
|
||||
};
|
||||
stateId++;
|
||||
}
|
||||
info.emplace(entity.first, stateInfo);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
} // namespace stats
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
4
powerstats/OWNERS
Normal file
4
powerstats/OWNERS
Normal file
@ -0,0 +1,4 @@
|
||||
darrenhsu@google.com
|
||||
joaodias@google.com
|
||||
krossmo@google.com
|
||||
vincentwang@google.com
|
70
powerstats/include/CpupmStateResidencyDataProvider.h
Normal file
70
powerstats/include/CpupmStateResidencyDataProvider.h
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 CpupmStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
|
||||
public:
|
||||
class Config {
|
||||
public:
|
||||
// List of power entity name pairs (name to display, name to parse)
|
||||
std::vector<std::pair<std::string, std::string>> entities;
|
||||
|
||||
// List of state pairs (state to display, state to parse).
|
||||
std::vector<std::pair<std::string, std::string>> states;
|
||||
};
|
||||
|
||||
/*
|
||||
* path - path to cpupm sysfs node.
|
||||
*/
|
||||
CpupmStateResidencyDataProvider(const std::string &path, const Config &config);
|
||||
~CpupmStateResidencyDataProvider() = 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:
|
||||
int32_t matchEntity(char const *line);
|
||||
int32_t matchState(char const *line);
|
||||
bool parseState(char const *line, uint64_t *duration, uint64_t *count);
|
||||
|
||||
// A constant to represent the number of microseconds in one millisecond.
|
||||
const uint64_t US_TO_MS = 1000;
|
||||
|
||||
const std::string mPath;
|
||||
const Config mConfig;
|
||||
};
|
||||
|
||||
} // namespace stats
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
@ -5,6 +5,7 @@ package {
|
||||
sh_binary {
|
||||
name: "dump_gti.sh",
|
||||
src: "dump_gti.sh",
|
||||
init_rc: ["init.touch.gti.rc"],
|
||||
vendor: true,
|
||||
sub_dir: "dump",
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
#!/vendor/bin/sh
|
||||
path="/sys/devices/virtual/goog_touch_interface/gti.0"
|
||||
procfs_path="/proc/goog_touch_interface/gti.0"
|
||||
|
||||
if [[ -d "$procfs_path" ]]; then
|
||||
heatmap_path=$procfs_path
|
||||
else
|
||||
heatmap_path=$path
|
||||
fi
|
||||
|
||||
echo "------ Force Touch Active ------"
|
||||
echo 1 > $path/force_active
|
||||
@ -8,22 +15,22 @@ echo "------ Touch Firmware Version ------"
|
||||
cat $path/fw_ver
|
||||
|
||||
echo "------ Get Mutual Sensing Data - Baseline ------"
|
||||
cat $path/ms_base
|
||||
cat $heatmap_path/ms_base
|
||||
|
||||
echo "------ Get Mutual Sensing Data - Delta ------"
|
||||
cat $path/ms_diff
|
||||
cat $heatmap_path/ms_diff
|
||||
|
||||
echo "------ Get Mutual Sensing Data - Raw ------"
|
||||
cat $path/ms_raw
|
||||
cat $heatmap_path/ms_raw
|
||||
|
||||
echo "------ Get Self Sensing Data - Baseline ------"
|
||||
cat $path/ss_base
|
||||
cat $heatmap_path/ss_base
|
||||
|
||||
echo "------ Get Self Sensing Data - Delta ------"
|
||||
cat $path/ss_diff
|
||||
cat $heatmap_path/ss_diff
|
||||
|
||||
echo "------ Get Self Sensing Data - Raw ------"
|
||||
cat $path/ss_raw
|
||||
cat $heatmap_path/ss_raw
|
||||
|
||||
echo "------ Self Test ------"
|
||||
cat $path/self_test
|
||||
|
9
touch/gti/init.touch.gti.rc
Normal file
9
touch/gti/init.touch.gti.rc
Normal file
@ -0,0 +1,9 @@
|
||||
on property:vendor.device.modules.ready=1
|
||||
chown system system /proc/goog_touch_interface
|
||||
chown system system /proc/goog_touch_interface/gti.0
|
||||
chown system system /proc/goog_touch_interface/gti.0/ms_base
|
||||
chown system system /proc/goog_touch_interface/gti.0/ms_diff
|
||||
chown system system /proc/goog_touch_interface/gti.0/ms_raw
|
||||
chown system system /proc/goog_touch_interface/gti.0/ss_base
|
||||
chown system system /proc/goog_touch_interface/gti.0/ss_diff
|
||||
chown system system /proc/goog_touch_interface/gti.0/ss_raw
|
@ -1,5 +1,7 @@
|
||||
pixel_bugreport(dump_gti)
|
||||
|
||||
allow dump_gti proc_touch_gti:dir r_dir_perms;
|
||||
allow dump_gti proc_touch_gti:file rw_file_perms;
|
||||
allow dump_gti sysfs_touch_gti:dir r_dir_perms;
|
||||
allow dump_gti sysfs_touch_gti:file rw_file_perms;
|
||||
allow dump_gti vendor_toolbox_exec:file execute_no_trans;
|
||||
|
@ -1,2 +1,3 @@
|
||||
type proc_touch_gti, proc_type, fs_type;
|
||||
type sysfs_touch_gti, sysfs_type, fs_type;
|
||||
|
||||
|
@ -1,2 +1,4 @@
|
||||
# Touch
|
||||
genfscon sysfs /devices/virtual/goog_touch_interface u:object_r:sysfs_touch_gti:s0
|
||||
genfscon proc /goog_touch_interface u:object_r:proc_touch_gti:s0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user