universal7885: Organize tree

This commit is contained in:
roynatech2544 2022-09-22 13:31:14 +09:00
commit 340f28fe4b
64 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,47 @@
//
// Copyright (C) 2021 The LineageOS 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.
cc_binary {
name: "android.hardware.camera.provider@2.5-service.exynos7885",
defaults: [
"hidl_defaults",
"eureka_defaults",
],
compile_multilib: "32",
proprietary: true,
relative_install_path: "hw",
srcs: [
"SamsungCameraProvider.cpp",
"service.cpp",
],
init_rc: ["android.hardware.camera.provider@2.5-service.exynos7885.rc"],
shared_libs: [
"android.hardware.camera.provider@2.4",
"android.hardware.camera.provider@2.4-legacy",
"android.hardware.camera.provider@2.5",
"android.hardware.camera.provider@2.5-legacy",
"libbinder",
"libcamera_metadata",
"libcutils",
"libhardware",
"libhidlbase",
"liblog",
"libutils",
"libcorrectcamera",
],
static_libs: [
"android.hardware.camera.common@1.0-helper",
],
}

View file

@ -0,0 +1,93 @@
/*
* Copyright (C) 2021 The LineageOS 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.
*/
#define LOG_TAG "SamsungCameraProvider@2.5"
#include "SamsungCameraProvider.h"
#include <algorithm>
using ::android::NO_ERROR;
using ::android::OK;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Void;
const int kMaxCameraIdLen = 16;
SamsungCameraProvider::SamsungCameraProvider()
: LegacyCameraProviderImpl_2_5() {
mExtraIDs.push_back(23);
mExtraIDs.push_back(50);
mExtraIDs.push_back(52);
mDisabledIDs.push_back(2);
if (!mInitFailed) {
for (int i : mExtraIDs) {
struct camera_info info;
auto rc = mModule->getCameraInfo(i, &info);
if (rc != NO_ERROR) {
continue;
}
if (checkCameraVersion(i, info) != OK) {
ALOGE("Camera version check failed!");
mModule.clear();
mInitFailed = true;
return;
}
#ifdef SAMSUNG_CAMERA_DEBUG
ALOGI("ID=%d is at index %d", i, mNumberOfLegacyCameras);
#endif
char cameraId[kMaxCameraIdLen];
snprintf(cameraId, sizeof(cameraId), "%d", i);
std::string cameraIdStr(cameraId);
mCameraStatusMap[cameraIdStr] = CAMERA_DEVICE_STATUS_PRESENT;
addDeviceNames(i);
mNumberOfLegacyCameras++;
}
}
}
Return<void> SamsungCameraProvider::getCameraIdList(
const ICameraProvider::getCameraIdList_cb &_hidl_cb) {
std::vector<hidl_string> deviceNameList;
for (auto const &deviceNamePair : mCameraDeviceNames) {
int id = std::stoi(deviceNamePair.first);
if (id >= mNumberOfLegacyCameras ||
std::find(mDisabledIDs.begin(), mDisabledIDs.end(), id) !=
mDisabledIDs.end()) {
// External camera devices must be reported through the device status
// change callback, not in this list. Linux4: Also skip disabled camera
// IDs.
continue;
}
if (mCameraStatusMap[deviceNamePair.first] ==
CAMERA_DEVICE_STATUS_PRESENT) {
deviceNameList.push_back(deviceNamePair.second);
}
}
hidl_vec<hidl_string> hidlDeviceNameList(deviceNameList);
_hidl_cb(::android::hardware::camera::common::V1_0::Status::OK,
hidlDeviceNameList);
return Void();
}
SamsungCameraProvider::~SamsungCameraProvider() {}

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) 2021 The LineageOS 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.
*/
#ifndef SAMSUNG_CAMERA_PROVIDER_H
#include "LegacyCameraProviderImpl_2_5.h"
#define SAMSUNG_CAMERA_DEBUG
using ::android::hardware::Return;
using ::android::hardware::camera::provider::V2_5::ICameraProvider;
using ::android::hardware::camera::provider::V2_5::implementation::
LegacyCameraProviderImpl_2_5;
class SamsungCameraProvider : public LegacyCameraProviderImpl_2_5 {
public:
SamsungCameraProvider();
~SamsungCameraProvider();
Return<void> getCameraIdList(const ICameraProvider::getCameraIdList_cb &_hidl_cb);
private:
std::vector<int> mExtraIDs;
std::vector<int> mDisabledIDs;
};
#endif // SAMSUNG_CAMERA_PROVIDER_H

View file

@ -0,0 +1,9 @@
service vendor.camera-provider-2-5 /vendor/bin/hw/android.hardware.camera.provider@2.5-service.exynos7885
interface android.hardware.camera.provider@2.5::ICameraProvider legacy/0
interface android.hardware.camera.provider@2.4::ICameraProvider legacy/0
class hal
user cameraserver
group audio camera input drmrpc
ioprio rt 4
capabilities SYS_NICE
task_profiles CameraServiceCapacity MaxPerformance

View file

@ -0,0 +1,49 @@
/*
* Copyright 2019 The Android Open Source Project
* Copyright 2021 The LineageOS 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.
*/
#define LOG_TAG "android.hardware.camera.provider@2.5-service.samsung"
#include <android/hardware/camera/provider/2.5/ICameraProvider.h>
#include <binder/ProcessState.h>
#include <hidl/HidlLazyUtils.h>
#include <hidl/HidlTransportSupport.h>
#include "CameraProvider_2_5.h"
#include "SamsungCameraProvider.h"
using android::status_t;
using android::hardware::camera::provider::V2_5::ICameraProvider;
int main() {
using namespace android::hardware::camera::provider::V2_5::implementation;
ALOGI("CameraProvider@2.5 legacy service is starting.");
::android::hardware::configureRpcThreadpool(/*threads*/ HWBINDER_THREAD_COUNT,
/*willJoin*/ true);
::android::sp<ICameraProvider> provider =
new CameraProvider<SamsungCameraProvider>();
status_t status = provider->registerAsService("legacy/0");
LOG_ALWAYS_FATAL_IF(status != android::OK,
"Error while registering provider service: %d", status);
::android::hardware::joinRpcThreadpool();
return 0;
}

View file

@ -0,0 +1,29 @@
cc_library_shared {
name: "android.hardware.health@2.1-impl-exynos7885",
stem: "android.hardware.health@2.0-impl-2.1-exynos7885",
proprietary: true,
recovery_available: true,
relative_install_path: "hw",
defaults: ["eureka_defaults"],
shared_libs: [
"libbase",
"libcutils",
"libhidlbase",
"liblog",
"libutils",
"android.hardware.health@2.1",
"android.hardware.health@2.0",
],
static_libs: [
"android.hardware.health@1.0-convert",
"libbatterymonitor",
"libhealthloop",
"libhealth2impl",
],
srcs: [
"HealthImpl.cpp",
],
}

View file

@ -0,0 +1,155 @@
#include <memory>
#include <string_view>
#include <unordered_map>
#include <fstream>
#include <sstream>
#include <health/utils.h>
#include <health2impl/Health.h>
#include <hidl/Status.h>
using ::android::hardware::Return;
using ::android::hardware::health::InitHealthdConfig;
using ::android::hardware::health::V2_1::IHealth;
using ::android::hardware::health::V2_0::Result;
using ::android::hardware::health::V1_0::BatteryStatus;
using namespace std::literals;
enum battery_stats {
CHARGE_CNT,
CURRENT_NOW,
CURRENT_AVG,
CAPACITY,
CHARGE_ENABLED,
FULL
};
std::unordered_map<battery_stats, std::string> battery_sysfs = {
{ CHARGE_CNT, "/efs/FactoryApp/batt_cable_count" },
{ CURRENT_NOW, "/sys/devices/platform/battery/power_supply/battery/current_now" },
{ CURRENT_AVG, "/sys/devices/platform/battery/power_supply/battery/current_avg" },
{ CAPACITY, "/sys/devices/platform/battery/power_supply/battery/charge_full" },
{ CHARGE_ENABLED, "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode" },
{ FULL, "/sys/devices/platform/battery/power_supply/battery/capacity" },
};
struct callBack {
Result result;
std::string value;
};
namespace android {
namespace hardware {
namespace health {
namespace V2_1 {
namespace implementation {
// android::hardware::health::V2_1::implementation::Health implements most
// defaults. Uncomment functions that you need to override.
class HealthImpl : public Health {
public:
explicit HealthImpl(std::unique_ptr<healthd_config>&& config)
: Health(std::move(config)) {}
static struct callBack ReadFile(const std::string &sysfs, const std::string &def) {
std::string ret = def;
std::ifstream file;
file.open(sysfs);
Result result = Result::SUCCESS;
if (file.is_open()){
getline(file, ret);
file.close();
} else {
result = Result::NOT_FOUND;
}
ALOGI ("%s: sysfs : %s, returns : %s", __func__, sysfs.c_str(), ret.c_str());
struct callBack cb = { result, ret };
return cb;
}
static struct callBack ReadBattFile(battery_stats type, const std::string &def) {
return ReadFile(battery_sysfs[type], def);
}
Return<void> getChargeCounter(getChargeCounter_cb _hidl_cb) {
struct callBack ret = ReadBattFile(CHARGE_CNT, "-1");
_hidl_cb(ret.result, std::stoi(ret.value));
return Void();
}
Return<void> getCurrentNow(getCurrentNow_cb _hidl_cb){
struct callBack ret = ReadBattFile(CURRENT_NOW, "-1");
_hidl_cb(ret.result, std::stoi(ret.value));
return Void();
}
Return<void> getCurrentAverage(getCurrentAverage_cb _hidl_cb){
struct callBack ret = ReadBattFile(CURRENT_NOW, "-1");
_hidl_cb(ret.result, std::stoi(ret.value));
return Void();
}
Return<void> getCapacity(getCapacity_cb _hidl_cb){
struct callBack ret = ReadBattFile(CURRENT_NOW, "-1");
_hidl_cb(ret.result, std::stoi(ret.value));
return Void();
}
Return<void> getChargeStatus(getChargeStatus_cb _hidl_cb){
struct callBack ret = ReadBattFile(CURRENT_NOW, "-1");
Result result = ret.result;
BatteryStatus batt = BatteryStatus::UNKNOWN;
if (std::stoi(ret.value) > 0) {
struct callBack res = ReadBattFile(FULL, "0");
if (std::stoi(res.value) == 100){
batt = BatteryStatus::FULL;
} else if (std::stoi(res.value) > 0) {
batt = BatteryStatus::CHARGING;
}
result = res.result;
} else if (std::stoi(ret.value) < 0) {
struct callBack res = ReadBattFile(CHARGE_ENABLED, "0");
if (std::stoi(res.value) == 0){
batt = BatteryStatus::DISCHARGING;
} else if (std::stoi(res.value) == 1) {
batt = BatteryStatus::NOT_CHARGING;
}
result = res.result;
}
_hidl_cb(result, batt);
return Void();
}
// Return<void> getDiskStats(getDiskStats_cb _hidl_cb) override;
// Return<void> getHealthInfo(getHealthInfo_cb _hidl_cb) override;
// Functions introduced in Health HAL 2.1.
// Return<void> getHealthConfig(getHealthConfig_cb _hidl_cb) override;
// Return<void> getHealthInfo_2_1(getHealthInfo_2_1_cb _hidl_cb) override;
// Return<void> shouldKeepScreenOn(shouldKeepScreenOn_cb _hidl_cb) override;
protected:
// A subclass can override this to modify any health info object before
// returning to clients. This is similar to healthd_board_battery_update().
// By default, it does nothing.
// void UpdateHealthInfo(HealthInfo* health_info) override;
};
} // namespace implementation
} // namespace V2_1
} // namespace health
} // namespace hardware
} // namespace android
extern "C" IHealth* HIDL_FETCH_IHealth(const char* instance) {
using ::android::hardware::health::V2_1::implementation::HealthImpl;
if (instance != "default"sv) {
return nullptr;
}
auto config = std::make_unique<healthd_config>();
InitHealthdConfig(config.get());
// healthd_board_init(config.get());
return new HealthImpl(std::move(config));
}

View file

@ -0,0 +1,3 @@
hidl_package_root{
name: "vendor.samsung.hardware",
}

View file

@ -0,0 +1,17 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "vendor.samsung.hardware.radio@2.0",
root: "vendor.samsung.hardware",
srcs: [
"ISehRadio.hal",
"ISehRadioIndication.hal",
"ISehRadioResponse.hal",
"types.hal"
],
interfaces: [
"android.hardware.radio@1.0",
"android.hidl.base@1.0",
],
gen_java: true,
}

View file

@ -0,0 +1,54 @@
package vendor.samsung.hardware.radio@2.0;
import ISehRadioIndication;
import ISehRadioResponse;
import android.hardware.radio@1.0::CdmaSmsMessage;
import android.hardware.radio@1.0::GsmSmsMessage;
import android.hardware.radio@1.0::ImsSmsMessage;
interface ISehRadio {
oneway setResponseFunctions(ISehRadioResponse radioResponse,
ISehRadioIndication radioIndication);
oneway getIccCardStatus(int32_t serial);
supplyNetworkDepersonalization(int32_t serial, string netpin,
int32_t lockstate);
dial(int32_t serial, SehDial dial);
getCurrentCalls(int32_t serial);
getImsRegistrationState();
getAvailableNetworks(int32_t serial);
setImsCallList(int32_t serial, vec<SehImsCall> imscalls);
getPreferredNetworkList(int32_t serial);
setPreferredNetworkList(int32_t serial, SehPreferredNetworkInfo info);
sendEncodedUssd(int32_t serial, SehEncodedUssd ussd);
getDisable2g(int32_t serial);
setDisable2g(int32_t serial, int32_t mode);
getCnap(int32_t serial);
getPhonebookStorageInfo(int32_t serial, int32_t fileid);
getUsimPhonebookCapability(int32_t serial);
setSimOnOff(int32_t serial, int32_t mode);
setSimInitEvent(int32_t serial);
getSimLockInfo(int32_t serial, int32_t numLockType, int32_t lockType);
supplyIccPersonalization(int32_t serial, string pin);
changeIccPersonalization(int32_t serial, string oldpass, string newpass);
sendCdmaSmsExpectMore(int32_t serial, CdmaSmsMessage msg);
getPhonebookEntry(int32_t serial, int32_t fileid, int32_t index);
accessPhonebookEntry(int32_t serial, int32_t command, int32_t fileid,
int32_t index, SehAdnRecord record, string pin);
getCellBroadcastConfig(int32_t serial);
emergencySearch(int32_t serial);
emergencyControl(int32_t serial, int32_t control);
getAtr(int32_t serial);
sendSms(int32_t serial, GsmSmsMessage msg);
sendSMSExpectMore(int32_t serial, GsmSmsMessage msg);
sendCdmaSms(int32_t serial, CdmaSmsMessage msg);
sendImsSms(int32_t serial, ImsSmsMessage msg);
getStoredMsgCountFromSim(int32_t serial);
readSmsFromSim(int32_t serial, int32_t index);
writeSmsToSim(int32_t serial, SehSimMsgArgs args);
getCsgList(int32_t serial);
selectCsgManual(int32_t serial, SehCsgInfo info);
setDataAllowed(int32_t serial, bool allowed, SehAllowDataParam ap);
setMobileDataSetting(int32_t serial, bool enabled, bool roamingenabled);
oneway sendRequestRaw(int32_t serial, vec<uint8_t> data);
oneway sendRequestStrings(int32_t serial, vec<string> strings);
};

View file

@ -0,0 +1,32 @@
package vendor.samsung.hardware.radio@2.0;
interface ISehRadioIndication {
oneway acbInfoChanged(int32_t type, vec<int32_t> acbInfo);
oneway csFallback(int32_t type, int32_t state);
oneway imsPreferenceChanged(int32_t type, vec<int32_t> imsPref);
oneway voiceRadioBearerHandoverStatusChanged(int32_t type, int32_t state);
oneway timerStatusChangedInd(int32_t type, vec<int32_t> eventNoti);
oneway modemCapabilityIndication(int32_t type, vec<int8_t> data);
oneway needTurnOnRadioIndication(int32_t type);
oneway simPhonebookReadyIndication(int32_t type);
oneway phonebookInitCompleteIndication(int32_t type);
oneway deviceReadyNoti(int32_t type);
oneway stkSmsSendResultIndication(int32_t type, int32_t reesult);
oneway stkCallControlResultIndication(int32_t type, string cmd);
oneway simSwapStateChangedIndication(int32_t type, int32_t state);
oneway simCountMismatchedIndication(int32_t type, int32_t state);
oneway simOnOffStateChangedNotify(int32_t type, int32_t mode);
oneway releaseCompleteMessageIndication(int32_t type, SehSsReleaseComplete result);
oneway sapNotify(int32_t type, vec<int8_t> data);
oneway nrBearerAllocationChanged(int32_t type, int32_t status);
oneway nrNetworkTypeAdded(int32_t type, int32_t status);
oneway rrcStateChanged(int32_t type, SehRrcStateInfo state);
oneway configModemCapabilityChangeNoti(int32_t type, SehConfigModemCapability configModemCapa);
needApnProfileIndication(string select) generates (SehApnProfile apnProf);
needSettingValueIndication(string key, string table) generates(int32_t xx);
oneway execute(int32_t type, string cmd);
signalLevelInfoChanged(int32_t type, SehSignalBar signalBarInfo);
extendedRegistrationState(int32_t type, SehExtendedRegStateResult state);
needPacketUsage(string iface) generates (int32_t error, SehPacketUsage usage);
nrIconTypeChanged(int32_t indicationType, int32_t nrIconType);
};

View file

@ -0,0 +1,48 @@
package vendor.samsung.hardware.radio@2.0;
import android.hardware.radio@1.0::RadioResponseInfo;
interface ISehRadioResponse {
oneway getIccCardStatusResponse(RadioResponseInfo info, SehCardStatus cardStatus);
oneway supplyNetworkDepersonalizationResponse(RadioResponseInfo info, int32_t remainingRetries);
oneway dialResponse(RadioResponseInfo info);
oneway getCurrentCallsResponse(RadioResponseInfo info, vec<SehCall> calls);
oneway getImsRegistrationStateResponse(RadioResponseInfo info, vec<int32_t> networkInfos);
oneway setImsCallListResponse(RadioResponseInfo info);
oneway getPreferredNetworkListResponse(RadioResponseInfo info, vec<SehPreferredNetworkInfo> infos);
oneway setPreferredNetworkListResponse(RadioResponseInfo info);
oneway sendEncodedUssdResponse(RadioResponseInfo info);
oneway getDisable2gResponse(RadioResponseInfo info, int32_t isDisable);
oneway setDisable2gResponse(RadioResponseInfo info);
oneway getCnapResponse(RadioResponseInfo info, int32_t m);
oneway getPhonebookStorageInfoResponse(RadioResponseInfo info, SehPhonebookInfo sehinfo);
oneway getUsimPhonebookCapabilityResponse(RadioResponseInfo info, vec<int32_t> phonebookCapability);
oneway setSimOnOffResponse(RadioResponseInfo info);
oneway setSimInitEventResponse(RadioResponseInfo info);
oneway getSimLockInfoResponse(RadioResponseInfo info, SehSimLockInfo simLockInfo);
oneway supplyIccPersonalizationResponse(RadioResponseInfo info);
oneway changeIccPersonalizationResponse(RadioResponseInfo info);
oneway getPhonebookEntryResponse(RadioResponseInfo info, SehSimPhonebookResponse sehinfo);
oneway accessPhonebookEntryResponse(RadioResponseInfo info, int32_t SimPhonmebookAccessResp);
oneway getCellBroadcastConfigResponse(RadioResponseInfo info, SehCbConfigArgs args);
oneway emergencySearchResponse(RadioResponseInfo info, int32_t respEmergencySearch);
oneway emergencyControlResponse(RadioResponseInfo info);
oneway getAtrResponse(RadioResponseInfo info, string atr);
oneway sendCdmaSmsExpectMoreResponse(RadioResponseInfo info, SehSendSmsResult result);
oneway sendSmsResponse(RadioResponseInfo info, SehSendSmsResult result);
oneway sendSMSExpectMoreResponse(RadioResponseInfo info, SehSendSmsResult result);
oneway sendCdmaSmsResponse(RadioResponseInfo info, SehSendSmsResult result);
oneway sendImsSmsResponse(RadioResponseInfo info, SehSendSmsResult result);
oneway getStoredMsgCountFromSimResponse(RadioResponseInfo info, SehStoredMsgCount count);
oneway readSmsFromSimResponse(RadioResponseInfo info, SehSimMsgArgs args);
oneway writeSmsToSimResponse(RadioResponseInfo info, int32_t index);
oneway setDataAllowedResponse(RadioResponseInfo info);
oneway getCsgListResponse(RadioResponseInfo info, vec<SehCsgInfo> csginfo);
oneway selectCsgManualResponse(RadioResponseInfo info);
oneway setMobileDataSettingResponse(RadioResponseInfo info);
oneway sendRequestRawResponse(RadioResponseInfo info, vec<int8_t> data);
oneway sendRequestStringsResponse(RadioResponseInfo info, vec<string> data);
oneway setNrModeResponse(RadioResponseInfo responseInfo);
oneway getNrModeResponse(RadioResponseInfo responseInfo, int32_t mode);
oneway getNrIconTypeResponse(RadioResponseInfo responseInfo, int32_t icontype);
};

View file

@ -0,0 +1,225 @@
package vendor.samsung.hardware.radio@2.0;
import android.hardware.radio@1.0::Call;
import android.hardware.radio@1.0::AppStatus;
import android.hardware.radio@1.0::Dial;
import android.hardware.radio@1.0::OperatorInfo;
struct SehAdnRecord {
vec<uint8_t> name;
int32_t nameDcs;
int32_t nameLength;
string number;
vec<uint8_t> gsm8bitEmail;
int32_t gsm8bitEmailLength;
string anr;
string anrA;
string anrB;
string anrC;
vec<uint8_t> sne;
int32_t sneLength;
int32_t sneDcs;
};
struct SehAllowDataParam {
int32_t defaultDataPhoneId;
};
struct SehApnProfile {
string apn;
string proto;
string roamingProto;
string user;
string pw;
string auth;
};
struct SehAppStatus {
AppStatus base;
int32_t pin1NumRetries;
int32_t puk1NumRetries;
int32_t pin2NumRetries;
int32_t puk2NumRetries;
int32_t persoUnblockRetries;
};
enum SehBearerStatus : int32_t {
NR_BEARER_STATUS_ALLOCATED = 1,
NR_BEARER_STATUS_MMW_ALLOCATED = 2,
NR_BEARER_STATUS_NOT_ALLOCATED = 0,
};
enum SehCallType : int32_t {
VOICE = 0,
VS_RX = 2,
VS_TX = 1,
VT = 3,
};
struct SehCallDetails {
int32_t callType;
vec<string> extras;
};
struct SehCall {
Call base;
int32_t audioQuality;
vec<SehCallDetails> callDetails;
};
struct SehCardStatus {
int32_t cardState;
int32_t universalPinState;
int32_t gsmUmtsSubscriptionAppIndex;
int32_t cdmaSubscriptionAppIndex;
int32_t imsSubscriptionAppIndex;
vec<SehAppStatus> applications;
int32_t physicalSlotId;
string atr;
string iccid;
};
struct SehCbConfigArgs {
int32_t enabled;
int32_t selectedId;
int32_t msgIdMaxCount;
int32_t msgIdCount;
string msgIDs;
};
struct SehCommandExcute {
string mainCmd;
string subCmd;
};
struct SehConfigModemCapability {
int32_t supportCltcp;
};
struct SehCsgInfo {
int32_t csgId;
string name;
string plmn;
int32_t rat;
int32_t category;
int32_t signalStrength;
};
struct SehDial {
Dial base;
vec<SehCallDetails> callDetails;
};
struct SehEncodedUssd {
vec<uint8_t> encodedUssd;
int32_t ussdLength;
int32_t dcsCode;
};
struct SehExtendedRegStateResult {
bool isValid;
int32_t snapshotStatus;
int32_t unprocessedDataRegState;
int32_t unprocessedDataRat;
int32_t mobileOptionalRat;
int32_t imsEmergencyCallBarring;
int32_t unprocessedVoiceRegState;
bool isPsOnlyReg;
};
struct SehImsCall {
int32_t state;
int32_t type;
int32_t isMt;
int32_t isMpty;
string number;
};
struct SehOperatorInfo {
OperatorInfo base;
string rat;
string lac;
};
struct SehPacketUsage {
int64_t rxBytes;
int64_t txBytes;
};
struct SehPhonebookInfo {
int32_t totalCount;
int32_t usedCount;
int32_t firstIndex;
int32_t maxTextLength;
int32_t maxNumberLength;
};
struct SehPreferredNetworkInfo {
int32_t index;
string oper;
string plmn;
int32_t gsmAct;
int32_t gsmCompactAct;
int32_t utranAct;
int32_t mode;
};
struct SehRrcStateInfo {
int32_t rat;
int32_t state;
};
struct SehSendSmsResult {
int32_t messageRef;
string ackPDU;
int32_t errorCode;
int32_t errorClass;
};
struct SehSignalBar {
int32_t cdmaLevel;
int32_t evdoLevel;
int32_t gsmLevel;
int32_t wcdmaLevel;
int32_t tdscdmaLevel;
int32_t lteLevel;
int32_t nrLevel;
};
struct SehSimLockInfo {
int32_t numberOfLockTypes;
int32_t lockType;
int32_t lockKey;
int32_t numberOfRetry;
};
struct SehSimMsgArgs {
int32_t index;
int32_t status;
string pdu;
string smsc;
};
struct SehSimPhonebookResponse {
vec<int32_t> lengthAlphas;
vec<int32_t> dataTypeAlphas;
vec<string> alphaTags;
vec<int32_t> lengthNumbers;
vec<int32_t> dataTypeNumbers;
vec<string> numbers;
int32_t recordIndex;
int32_t nextIndex;
};
struct SehSsReleaseComplete {
int32_t size;
int32_t dataLen;
int32_t params;
int32_t status;
string data;
};
struct SehStoredMsgCount {
int32_t usedCount;
int32_t totalCount;
};

View file

@ -0,0 +1,18 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "vendor.samsung.hardware.radio@2.1",
root: "vendor.samsung.hardware",
srcs: [
"ISehRadio.hal",
"ISehRadioIndication.hal",
"ISehRadioResponse.hal",
"types.hal"
],
interfaces: [
"android.hardware.radio@1.0",
"android.hidl.base@1.0",
"vendor.samsung.hardware.radio@2.0",
],
gen_java: true,
}

View file

@ -0,0 +1,9 @@
package vendor.samsung.hardware.radio@2.1;
import vendor.samsung.hardware.radio@2.0::ISehRadio;
interface ISehRadio extends @2.0::ISehRadio {
oneway setNrMode(int32_t serial, int32_t mode);
oneway getNrMode(int32_t serial);
oneway getNrIconType(int32_t serial);
};

View file

@ -0,0 +1,5 @@
package vendor.samsung.hardware.radio@2.1;
import @2.0::ISehRadioIndication;
interface ISehRadioIndication extends @2.0::ISehRadioIndication {};

View file

@ -0,0 +1,5 @@
package vendor.samsung.hardware.radio@2.1;
import @2.0::ISehRadioResponse;
interface ISehRadioResponse extends @2.0::ISehRadioResponse {};

View file

@ -0,0 +1,9 @@
package vendor.samsung.hardware.radio@2.1;
import @2.0::SehCardStatus;
struct SehCardStatus {
@2.0::SehCardStatus base;
string eid;
};

View file

@ -0,0 +1,14 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "vendor.samsung.hardware.radio.channel@2.0",
root: "vendor.samsung.hardware",
srcs: [
"ISehChannel.hal",
"ISehChannelCallback.hal",
],
interfaces: [
"android.hidl.base@1.0",
],
gen_java: true,
}

View file

@ -0,0 +1,8 @@
package vendor.samsung.hardware.radio.channel@2.0;
import @2.0::ISehChannelCallback;
interface ISehChannel {
oneway send(vec<uint8_t> data);
oneway setCallback(ISehChannelCallback callback);
};

View file

@ -0,0 +1,5 @@
package vendor.samsung.hardware.radio.channel@2.0;
interface ISehChannelCallback {
oneway receive(vec<uint8_t> data);
};

View file

@ -0,0 +1,3 @@
hidl_package_root {
name: "vendor.eureka",
}

View file

@ -0,0 +1,12 @@
hidl_interface {
name: "vendor.eureka.hardware.fmradio@1.0",
root: "vendor.eureka",
srcs: [
"types.hal",
"IFMRadio.hal",
],
interfaces: [
"android.hidl.base@1.0",
],
gen_java: true,
}

View file

@ -0,0 +1,20 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.fmradio@1.0;
interface IFMRadio {
setManualFreq(float freq);
adjustFreqByStep(Direction dir);
};

View file

@ -0,0 +1,20 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.fmradio@1.0;
enum Direction : int32_t {
UP,
DOWN,
};

View file

@ -0,0 +1,13 @@
hidl_interface {
name: "vendor.eureka.hardware.fmradio@1.1",
root: "vendor.eureka",
srcs: [
"types.hal",
"IFMRadio.hal",
],
interfaces: [
"android.hidl.base@1.0",
"vendor.eureka.hardware.fmradio@1.0",
],
gen_java: true,
}

View file

@ -0,0 +1,22 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.fmradio@1.1;
import @1.0::IFMRadio;
interface IFMRadio extends @1.0::IFMRadio {
getFreqFromSysfs() generates (int32_t freq);
isAvailable() generates (Status status);
};

View file

@ -0,0 +1,20 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.fmradio@1.1;
enum Status : int32_t {
YES,
NO,
};

View file

@ -0,0 +1,14 @@
hidl_interface {
name: "vendor.eureka.hardware.fmradio@1.2",
root: "vendor.eureka",
srcs: [
"types.hal",
"IFMRadio.hal",
],
interfaces: [
"android.hidl.base@1.0",
"vendor.eureka.hardware.fmradio@1.1",
"vendor.eureka.hardware.fmradio@1.0",
],
gen_java: true,
}

View file

@ -0,0 +1,22 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.fmradio@1.2;
import @1.1::IFMRadio;
interface IFMRadio extends @1.1::IFMRadio {
setChannelSpacing(Space space);
getChannelSpacing() generates (Space space);
};

View file

@ -0,0 +1,20 @@
// FIXME: your file license if you have one
cc_binary {
name: "vendor.eureka.hardware.fmradio@1.2-service",
srcs: [
"FMRadio.cpp",
"service.cpp",
],
defaults: ["eureka_defaults"],
shared_libs: [
"libhidlbase",
"libutils",
"liblog",
"vendor.eureka.hardware.fmradio@1.0",
"vendor.eureka.hardware.fmradio@1.1",
"vendor.eureka.hardware.fmradio@1.2",
],
init_rc: ["vendor.eureka.hardware.fmradio@1.2-service.rc"],
vintf_fragments: ["vendor.eureka.hardware.fmradio@1.2.xml"],
}

View file

@ -0,0 +1,84 @@
// Copyright (C) 2021 Eureka Team
//
// 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 "FMRadio.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <sys/stat.h>
#include <sys/types.h>
static int mChannelSpacing = 3;
namespace vendor::eureka::hardware::fmradio::V1_2 {
Return<void> FMRadio::setManualFreq(float freq) {
std::ofstream file;
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
file << freq * 1000;
file.close();
return Void();
}
Return<void> FMRadio::adjustFreqByStep(fmradio::V1_0::Direction dir) {
std::ofstream file;
std::string value = "";
if (dir == V1_0::Direction::UP) {
value = "1 " + std::to_string(mChannelSpacing * 10);
} else if (dir == V1_0::Direction::DOWN) {
value = "0 " + std::to_string(mChannelSpacing * 10);
}
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_seek");
file << value;
file.close();
return Void();
}
Return<V1_1::Status> FMRadio::isAvailable() {
struct stat info;
if (stat("/sys/devices/virtual/s610_radio/s610_radio/", &info) != 0) {
return V1_1::Status::NO;
} else {
return V1_1::Status::YES;
}
}
Return<void> FMRadio::setChannelSpacing(V1_2::Space space) {
mChannelSpacing = (int)space;
return Void();
}
Return<int32_t> FMRadio::getFreqFromSysfs() {
std::ifstream file;
std::string value;
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
std::getline(file, value);
file.close();
return std::stoi(value);
}
Return<V1_2::Space> FMRadio::getChannelSpacing() {
switch (mChannelSpacing) {
case 1:
return V1_2::Space::CHANNEL_SPACING_10HZ;
case 2:
return V1_2::Space::CHANNEL_SPACING_20HZ;
case 3:
return V1_2::Space::CHANNEL_SPACING_30HZ;
case 4:
return V1_2::Space::CHANNEL_SPACING_40HZ;
case 5:
return V1_2::Space::CHANNEL_SPACING_50HZ;
default:
return V1_2::Space::CHANNEL_SPACING_30HZ;
}
}
IFMRadio *FMRadio::getInstance(void) { return new FMRadio(); }
} // namespace vendor::eureka::hardware::fmradio::V1_2

View file

@ -0,0 +1,44 @@
// Copyright (C) 2021 Eureka Team
//
// 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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
namespace vendor::eureka::hardware::fmradio::V1_2 {
using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
struct FMRadio : public IFMRadio {
// Methods from ::vendor::eureka::hardware::fmradio::V1_0::IFMRadio follow.
Return<void> setManualFreq(float freq);
Return<void> adjustFreqByStep(V1_0::Direction dir);
// Methods from ::vendor::eureka::hardware::fmradio::V1_1::IFMRadio follow.
Return<V1_1::Status> isAvailable();
Return<int32_t> getFreqFromSysfs();
// Methods from ::vendor::eureka::hardware::fmradio::V1_2::IFMRadio follow.
Return<void> setChannelSpacing(V1_2::Space space);
Return<V1_2::Space> getChannelSpacing();
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IFMRadio *getInstance(void);
};
} // namespace vendor::eureka::hardware::fmradio::V1_2

View file

@ -0,0 +1,47 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
#define LOG_TAG "vendor.eureka.hardware.fmradio@1.2-service"
#include <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
#include <hidl/LegacySupport.h>
#include "FMRadio.h"
using android::sp;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using vendor::eureka::hardware::fmradio::V1_2::FMRadio;
using vendor::eureka::hardware::fmradio::V1_2::IFMRadio;
int main() {
int ret;
android::sp<IFMRadio> mFMService = FMRadio::getInstance();
configureRpcThreadpool(1, true /*callerWillJoin*/);
if (mFMService != nullptr) {
ret = mFMService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of FMRadio HAL, nullptr");
} else {
ALOGI("registered FMRadio HAL");
}
} else {
ALOGE("Can't create instance of FMRadio HAL, nullptr");
}
joinRpcThreadpool();
return -1; // should never get here
}

View file

@ -0,0 +1,7 @@
service fm-hal /system/bin/vendor.eureka.hardware.fmradio@1.2-service
interface vendor.eureka.hardware.fmradio@1.0::IFMRadio default
interface vendor.eureka.hardware.fmradio@1.1::IFMRadio default
interface vendor.eureka.hardware.fmradio@1.2::IFMRadio default
class hal
user root
group root

View file

@ -0,0 +1,11 @@
<manifest version="1.0" type="framework">
<hal>
<name>vendor.eureka.hardware.fmradio</name>
<transport>hwbinder</transport>
<version>1.2</version>
<interface>
<name>IFMRadio</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View file

@ -0,0 +1,23 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.fmradio@1.2;
enum Space : int32_t {
CHANNEL_SPACING_10HZ = 1,
CHANNEL_SPACING_20HZ,
CHANNEL_SPACING_30HZ,
CHANNEL_SPACING_40HZ,
CHANNEL_SPACING_50HZ = 5,
};

View file

@ -0,0 +1,13 @@
hidl_interface {
name: "vendor.eureka.hardware.parts@1.0",
root: "vendor.eureka",
srcs: [
"types.hal",
"IBatteryStats.hal",
"IFlashBrightness.hal",
"IDisplayConfigs.hal",
"ISwapOnData.hal",
],
interfaces: ["android.hidl.base@1.0"],
gen_java: false,
}

View file

@ -0,0 +1,20 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.parts@1.0;
interface IBatteryStats {
getBatteryStats(SysfsType stats) generates (int32_t result);
setBatteryWritable(SysfsType stats, Number value);
};

View file

@ -0,0 +1,19 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.parts@1.0;
interface IDisplayConfigs {
writeDisplay(Number enable, Display type);
};

View file

@ -0,0 +1,21 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.parts@1.0;
interface IFlashBrightness {
setFlashlightWritable(Value value);
setFlashlightEnable(Number enable);
readFlashlightstats(Device device) generates (int32_t value);
};

View file

@ -0,0 +1,21 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.parts@1.0;
interface ISwapOnData {
setSwapSize(int32_t size /* Size in megabytes */);
setSwapOn();
setSwapOff();
};

View file

@ -0,0 +1,22 @@
// FIXME: your file license if you have one
cc_binary {
name: "vendor.eureka.hardware.parts@1.0-service",
defaults: ["eureka_defaults"],
srcs: [
"Battery.cpp",
"FlashLight.cpp",
"Display.cpp",
"Swap.cpp",
"SwapHelpers.cpp",
"service.cpp",
],
shared_libs: [
"libhidlbase",
"libutils",
"liblog",
"vendor.eureka.hardware.parts@1.0",
],
init_rc: ["vendor.eureka.hardware.parts@1.0-service.rc"],
vintf_fragments: ["vendor.eureka.hardware.parts@1.0.xml"],
}

View file

@ -0,0 +1,111 @@
// Copyright (C) 2021 Eureka Team
//
// 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 "Battery.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <unistd.h>
namespace vendor::eureka::hardware::parts::V1_0 {
// Methods from ::android::hardware::battery::V1_0::IBattery follow.
Return<int32_t> BatteryStats::getBatteryStats(parts::V1_0::SysfsType stats) {
std::ifstream file;
std::string filename;
switch (stats) {
case SysfsType::CAPACITY_MAX:
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
break;
case SysfsType::TEMP:
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
break;
case SysfsType::CAPACITY_CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
break;
case SysfsType::CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
break;
case SysfsType::FASTCHARGE:
filename = "/sys/class/sec/switch/afc_disable";
break;
case SysfsType::CHARGE:
filename =
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
break;
default:
filename = "";
break;
}
std::string value;
int32_t intvalue;
file.open(filename);
if (file.is_open()) {
getline(file, value);
file.close();
std::stringstream val(value);
val >> intvalue;
return intvalue;
}
return -1;
}
Return<void> BatteryStats::setBatteryWritable(parts::V1_0::SysfsType stats,
parts::V1_0::Number value) {
std::ofstream file;
std::string filename;
bool FastCharge = false;
switch (stats) {
case SysfsType::CAPACITY_MAX:
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
break;
case SysfsType::TEMP:
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
break;
case SysfsType::CAPACITY_CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
break;
case SysfsType::CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
break;
case SysfsType::FASTCHARGE:
filename = "/sys/class/sec/switch/afc_disable";
FastCharge = true;
break;
case SysfsType::CHARGE:
filename =
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
break;
default:
filename = "";
break;
}
if (FastCharge)
seteuid(ANDROID_SYSTEM_UID);
file.open(filename);
int write;
if (value == Number::ENABLE) {
write = 1;
} else {
write = 0;
}
file << write;
file.close();
if (FastCharge)
seteuid(ANDROID_ROOT_UID);
return Void();
}
IBatteryStats *BatteryStats::getInstance(void) { return new BatteryStats(); }
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,42 @@
// Copyright (C) 2021 Eureka Team
//
// 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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
#define ANDROID_SYSTEM_UID 1000
#define ANDROID_ROOT_UID 0
namespace vendor::eureka::hardware::parts::V1_0 {
using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
struct BatteryStats : public IBatteryStats {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IBatteryStats follow.
Return<int32_t> getBatteryStats(SysfsType stats) override;
Return<void> setBatteryWritable(SysfsType stats, Number value) override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IBatteryStats *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,45 @@
// Copyright (C) 2021 Eureka Team
//
// 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 "Display.h"
#include <fstream>
#include <iostream>
#include <sstream>
namespace vendor::eureka::hardware::parts::V1_0 {
Return<void> DisplayConfigs::writeDisplay(parts::V1_0::Number enable,
parts::V1_0::Display type) {
std::ofstream file;
std::string writevalue;
if (type == Display::DOUBLE_TAP) {
writevalue = "aot_enable";
} else if (type == Display::GLOVE_MODE) {
writevalue = "glove_mode";
}
writevalue += ",";
if (enable == Number::ENABLE) {
writevalue += "1";
} else {
writevalue += "0";
}
file.open("/sys/class/sec/tsp/cmd");
file << writevalue;
file.close();
return Void();
}
IDisplayConfigs *DisplayConfigs::getInstance(void) {
return new DisplayConfigs();
}
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,38 @@
// Copyright (C) 2021 Eureka Team
//
// 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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
namespace vendor::eureka::hardware::parts::V1_0 {
using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
struct DisplayConfigs : public IDisplayConfigs {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs
// follow.
Return<void> writeDisplay(Number enable, Display type);
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IDisplayConfigs *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,76 @@
// Copyright (C) 2021 Eureka Team
//
// 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 "FlashLight.h"
#include <fstream>
#include <iostream>
#include <sstream>
namespace vendor::eureka::hardware::parts::V1_0 {
// Methods from ::android::hardware::parts::V1_0::IFlashLight follow.
Return<void> FlashBrightness::setFlashlightEnable(parts::V1_0::Number enable) {
std::ofstream file;
std::string writevalue;
switch (enable) {
case Number::ENABLE:
writevalue = "1";
break;
case Number::DISABLE:
writevalue = "0";
break;
default:
writevalue = "";
break;
}
file.open("/sys/class/camera/flash/torch_brightness_lvl_enable");
file << writevalue;
file.close();
return Void();
}
Return<void> FlashBrightness::setFlashlightWritable(parts::V1_0::Value value) {
std::ofstream file;
std::string writevalue = std::to_string((int)value);
file.open("/sys/class/camera/flash/torch_brightness_lvl");
file << writevalue;
file.close();
return Void();
}
Return<int32_t>
FlashBrightness::readFlashlightstats(parts::V1_0::Device device) {
std::ifstream file;
std::string value;
int32_t intvalue;
file.open("/sys/class/camera/flash/torch_brightness_lvl");
if (file.is_open()) {
getline(file, value);
file.close();
std::stringstream val(value);
val >> intvalue;
if (device == Device::A10) {
return intvalue;
} else if (device == Device::NOTA10) {
return intvalue / 21;
}
// Never Here
return -1;
}
return -1;
}
IFlashBrightness *FlashBrightness::getInstance(void) {
return new FlashBrightness();
}
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,40 @@
// Copyright (C) 2021 Eureka Team
//
// 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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
namespace vendor::eureka::hardware::parts::V1_0 {
using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
struct FlashBrightness : public IFlashBrightness {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness
// follow.
Return<void> setFlashlightEnable(Number enable);
Return<void> setFlashlightWritable(Value value);
Return<int32_t> readFlashlightstats(Device device);
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IFlashBrightness *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,48 @@
// Copyright (C) 2021 Eureka Team
//
// 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 "Swap.h"
#include <fstream>
#include <iostream>
#include <sys/swap.h>
#include <stdio.h>
static int mSwapSize = 100;
extern int mkswap (std::string filename);
extern void mkfile(int filesize, std::string name);
static std::string SWAP_PATH = "/data/swap/swapfile";
namespace vendor::eureka::hardware::parts::V1_0 {
Return<void> SwapOnData::setSwapSize(int32_t size) {
mSwapSize = size;
return Void();
}
Return<void> SwapOnData::setSwapOn() {
mkfile(mSwapSize * 10, SWAP_PATH);
mkswap(SWAP_PATH);
swapon(SWAP_PATH.c_str(), (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK);
return Void();
}
Return<void> SwapOnData::setSwapOff() {
swapoff(SWAP_PATH.c_str());
remove(SWAP_PATH.c_str());
return Void();
}
ISwapOnData *SwapOnData::getInstance(void) { return new SwapOnData(); }
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,40 @@
// Copyright (C) 2021 Eureka Team
//
// 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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/eureka/hardware/parts/1.0/ISwapOnData.h>
namespace vendor::eureka::hardware::parts::V1_0 {
using ::android::sp;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
struct SwapOnData : public ISwapOnData {
// Methods from ::vendor::eureka::hardware::parts::V1_0::ISwapOnData
// follow.
Return<void> setSwapSize(int32_t size);
Return<void> setSwapOn();
Return<void> setSwapOff();
// Methods from ::android::hidl::base::V2_0::IBase follow.
static ISwapOnData *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,83 @@
#include <cstring>
#include <cerrno>
#include <fcntl.h>
#include <iostream>
#include <cstdio>
#include <sys/stat.h>
#include <sys/swap.h>
#include <sys/types.h>
#include <unistd.h>
#include <fstream>
#include <vector>
/* XXX This needs to be obtained from kernel headers. See b/9336527 */
struct linux_swap_header {
char bootbits[1024]; /* Space for disklabel etc. */
u_int32_t version;
u_int32_t last_page;
u_int32_t nr_badpages;
unsigned char sws_uuid[16];
unsigned char sws_volume[16];
u_int32_t padding[117];
u_int32_t badpages[1];
};
void mkfile(int filesize, std::string name){
std::vector<char> empty(1024, 0);
std::ofstream ofs(name, std::ios::binary | std::ios::out);
for(int i = 0; i < 1024 * filesize; i++)
{
ofs.write(&empty[0], empty.size());
}
}
#define MAGIC_SWAP_HEADER "SWAPSPACE2"
#define MAGIC_SWAP_HEADER_LEN 10
#define MIN_PAGES 10
int mkswap(std::string filename) {
int err = 0;
int fd;
ssize_t len;
off_t swap_size;
int pagesize;
struct linux_swap_header sw_hdr;
fd = open(filename.c_str(), O_WRONLY | O_CLOEXEC);
if (fd < 0) {
err = errno;
return err;
}
pagesize = getpagesize();
/* Determine the length of the swap file */
swap_size = lseek(fd, 0, SEEK_END);
if (swap_size < MIN_PAGES * pagesize) {
err = -ENOSPC;
goto err;
}
if (lseek(fd, 0, SEEK_SET)) {
err = errno;
goto err;
}
memset(&sw_hdr, 0, sizeof(sw_hdr));
sw_hdr.version = 1;
sw_hdr.last_page = (swap_size / pagesize) - 1;
len = write(fd, &sw_hdr, sizeof(sw_hdr));
if (len != sizeof(sw_hdr)) {
err = errno;
goto err;
}
/* Write the magic header */
if (lseek(fd, pagesize - MAGIC_SWAP_HEADER_LEN, SEEK_SET) < 0) {
err = errno;
goto err;
}
len = write(fd, MAGIC_SWAP_HEADER, MAGIC_SWAP_HEADER_LEN);
if (len != MAGIC_SWAP_HEADER_LEN) {
err = errno;
goto err;
}
if (fsync(fd) < 0) {
err = errno;
goto err;
}
err:
close(fd);
return err;
}

View file

@ -0,0 +1,92 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
#define LOG_TAG "vendor.eureka.hardware.parts@1.0-service"
#include <hidl/LegacySupport.h>
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
#include <vendor/eureka/hardware/parts/1.0/ISwapOnData.h>
#include "Battery.h"
#include "Display.h"
#include "FlashLight.h"
#include "Swap.h"
using android::sp;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using vendor::eureka::hardware::parts::V1_0::BatteryStats;
using vendor::eureka::hardware::parts::V1_0::DisplayConfigs;
using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
using vendor::eureka::hardware::parts::V1_0::ISwapOnData;
using vendor::eureka::hardware::parts::V1_0::SwapOnData;
int main() {
int ret;
android::sp<IBatteryStats> mBatteryService = BatteryStats::getInstance();
android::sp<IFlashBrightness> mFlashLightService =
FlashBrightness::getInstance();
android::sp<IDisplayConfigs> mDisplayService = DisplayConfigs::getInstance();
android::sp<ISwapOnData> mSwapService = SwapOnData::getInstance();
configureRpcThreadpool(4, true /*callerWillJoin*/);
if (mBatteryService != nullptr) {
ret = mBatteryService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of Battery HAL, nullptr");
} else {
ALOGI("registered Battery HAL");
}
} else {
ALOGE("Can't create instance of Battery HAL, nullptr");
}
if (mFlashLightService != nullptr) {
ret = mFlashLightService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of FlashLight HAL, nullptr");
} else {
ALOGI("registered FlashLight HAL");
}
} else {
ALOGE("Can't create instance of FlashLight HAL, nullptr");
}
if (mDisplayService != nullptr) {
ret = mDisplayService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of Display HAL, nullptr");
} else {
ALOGI("registered Display HAL");
}
} else {
ALOGE("Can't create instance of Display HAL, nullptr");
}
if (mSwapService != nullptr) {
ret = mSwapService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of Swap HAL, nullptr");
} else {
ALOGI("registered Swap HAL");
}
} else {
ALOGE("Can't create instance of Swap HAL, nullptr");
}
joinRpcThreadpool();
return -1; // should never get here
}

View file

@ -0,0 +1,11 @@
service parts-hal /system/bin/vendor.eureka.hardware.parts@1.0-service
interface vendor.eureka.hardware.parts@1.0::IBatteryStats default
interface vendor.eureka.hardware.parts@1.0::IDisplayConfigs default
interface vendor.eureka.hardware.parts@1.0::IFlashBrightness default
interface vendor.eureka.hardware.parts@1.0::ISwapOnData default
class hal
user root
group root
on post-fs-data
mkdir /data/swap 0755 root root encryption=None

View file

@ -0,0 +1,23 @@
<manifest version="1.0" type="framework">
<hal>
<name>vendor.eureka.hardware.parts</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IBatteryStats</name>
<instance>default</instance>
</interface>
<interface>
<name>IFlashBrightness</name>
<instance>default</instance>
</interface>
<interface>
<name>IDisplayConfigs</name>
<instance>default</instance>
</interface>
<interface>
<name>ISwapOnData</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View file

@ -0,0 +1,52 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.parts@1.0;
enum SysfsType : int32_t {
CAPACITY_MAX,
TEMP,
CAPACITY_CURRENT,
CURRENT,
FASTCHARGE,
CHARGE,
};
enum Display : int32_t {
DOUBLE_TAP,
GLOVE_MODE,
};
enum Number : int32_t {
ENABLE = 1,
DISABLE = 0,
};
enum Device : int32_t {
A10,
NOTA10,
};
enum Value : int32_t {
ONEUI = 1,
TWOUI,
THREEUI,
FOURUI,
FIVEUI,
SIXUI,
SEVENUI,
EIGHTUI,
NINEUI,
TENUI = 10,
};

View file

@ -0,0 +1,16 @@
cc_binary {
name: "android.hardware.power.stats-service.exynos7",
srcs: [
"*.cc",
],
relative_install_path: "hw",
vendor: true,
defaults: [
"eureka_defaults",
"powerstats_pixel_defaults",
],
cflags: ["-Wno-thread-safety-negative"],
shared_libs: ["android.hardware.power.stats-impl.pixel"],
init_rc: ["android.hardware.power.stats-service.exynos7.rc"],
vintf_fragments: ["android.hardware.power.stats-service.exynos7.xml"],
}

View file

@ -0,0 +1,111 @@
/*
* Copyright (C) 2021 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 "DevFreq.h"
#include <android-base/logging.h>
static const std::string nameSuffix = "-DVFS";
static const std::string pathSuffix = "/time_in_state";
namespace aidl {
namespace android {
namespace hardware {
namespace power {
namespace stats {
DevfreqStateResidencyDataProvider::DevfreqStateResidencyDataProvider(const std::string& name,
const std::string& path) : mName(name + nameSuffix), mPath(path + pathSuffix) {}
bool DevfreqStateResidencyDataProvider::extractNum(const char *str, char **str_end, int base,
int64_t* num) {
// errno can be set to any non-zero value by a library function call
// regardless of whether there was an error, so it needs to be cleared
// in order to check the error set by strtoll
errno = 0;
*num = std::strtoll(str, str_end, base);
return (errno != ERANGE);
}
std::vector<std::pair<int64_t, int64_t>> DevfreqStateResidencyDataProvider::parseTimeInState() {
// 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 {};
}
std::vector<std::pair<int64_t, int64_t>> timeInState;
char *line = nullptr;
size_t len = 0;
while (getline(&line, &len, fp.get()) != -1) {
char* pEnd;
int64_t frequencyHz, totalTimeMs;
if (!extractNum(line, &pEnd, 10, &frequencyHz) ||
!extractNum(pEnd, &pEnd, 10, &totalTimeMs)) {
PLOG(ERROR) << "Failed to parse " << mPath;
free(line);
return {};
}
timeInState.push_back({frequencyHz, totalTimeMs});
}
free(line);
return timeInState;
}
bool DevfreqStateResidencyDataProvider::getStateResidencies(
std::unordered_map<std::string, std::vector<StateResidency>> *residencies) {
std::vector<std::pair<int64_t, int64_t>> timeInState = parseTimeInState();
if (timeInState.empty()) {
return false;
}
int32_t id = 0;
std::vector<StateResidency> stateResidencies;
for (const auto[frequencyHz, totalTimeMs] : timeInState) {
StateResidency s = {.id = id++, .totalTimeInStateMs = totalTimeMs};
stateResidencies.push_back(s);
}
residencies->emplace(mName, stateResidencies);
return true;
}
std::unordered_map<std::string, std::vector<State>> DevfreqStateResidencyDataProvider::getInfo() {
std::vector<std::pair<int64_t, int64_t>> timeInState = parseTimeInState();
if (timeInState.empty()) {
return {};
}
int32_t id = 0;
std::vector<State> states;
for (const auto[frequencyHz, totalTimeMs] : timeInState) {
State s = {.id = id++, .name = std::to_string(frequencyHz / 1000) + "MHz"};
states.push_back(s);
}
return {{mName, states}};
}
} // namespace stats
} // namespace power
} // namespace hardware
} // namespace android
} // namespace aidl

View file

@ -0,0 +1,53 @@
/*
* Copyright (C) 2021 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 DevfreqStateResidencyDataProvider : public PowerStats::IStateResidencyDataProvider {
public:
DevfreqStateResidencyDataProvider(const std::string& name, const std::string& path);
~DevfreqStateResidencyDataProvider() = 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:
bool extractNum(const char *str, char **str_end, int base, int64_t* num);
std::vector<std::pair<int64_t, int64_t>> parseTimeInState();
const std::string mName;
const std::string mPath;
};
} // namespace stats
} // namespace power
} // namespace hardware
} // namespace android
} // namespace aidl

View file

@ -0,0 +1,4 @@
service vendor.power.stats-hal /vendor/bin/hw/android.hardware.power.stats-service.exynos7
class hal
user system
group system

View file

@ -0,0 +1,6 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.power.stats</name>
<fqname>IPowerStats/default</fqname>
</hal>
</manifest>

View file

@ -0,0 +1,70 @@
/*
* Copyright (C) 2020 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 "DevFreq.h"
#include <PowerStatsAidl.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <log/log.h>
using aidl::android::hardware::power::stats::DevfreqStateResidencyDataProvider;
using aidl::android::hardware::power::stats::PowerStats;
void addDevFreq(std::shared_ptr<PowerStats> p) {
p->addStateResidencyDataProvider(
std::make_unique<DevfreqStateResidencyDataProvider>(
"MIF", "/sys/devices/platform/17000010.devfreq_mif/devfreq/"
"17000010.devfreq_mif"));
p->addStateResidencyDataProvider(
std::make_unique<DevfreqStateResidencyDataProvider>(
"INT", "/sys/devices/platform/17000020.devfreq_int/devfreq/"
"17000020.devfreq_int"));
p->addStateResidencyDataProvider(
std::make_unique<DevfreqStateResidencyDataProvider>(
"DISP", "/sys/devices/platform/17000040.devfreq_disp/devfreq/"
"17000040.devfreq_disp"));
p->addStateResidencyDataProvider(
std::make_unique<DevfreqStateResidencyDataProvider>(
"CAM", "/sys/devices/platform/17000050.devfreq_cam/devfreq/"
"17000050.devfreq_cam"));
p->addStateResidencyDataProvider(
std::make_unique<DevfreqStateResidencyDataProvider>(
"AUD", "/sys/devices/platform/17000060.devfreq_aud/devfreq/"
"17000060.devfreq_aud"));
p->addStateResidencyDataProvider(
std::make_unique<DevfreqStateResidencyDataProvider>(
"FSYS", "/sys/devices/platform/17000070.devfreq_fsys/devfreq/"
"17000070.devfreq_fsys"));
}
int main() {
LOG(INFO) << "PowerStats HAL AIDL Service is starting.";
// single thread
ABinderProcess_setThreadPoolMaxThreadCount(0);
std::shared_ptr<PowerStats> p = ndk::SharedRefBase::make<PowerStats>();
addDevFreq(p);
const std::string instance = std::string() + PowerStats::descriptor + "/default";
binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str());
LOG_ALWAYS_FATAL_IF(status != STATUS_OK);
ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // should not reach
}