diff --git a/Android.mk b/Android.mk index 9d7f222..5a6e19b 100644 --- a/Android.mk +++ b/Android.mk @@ -12,13 +12,16 @@ LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libxml2 libbase libutils libbin ifeq ($(call math_gt_or_eq, 33, $(PLATFORM_SDK_VERSION)), true) LOCAL_SHARED_LIBRARIES += android.hardware.power-V3-ndk +endif +ifeq ($(call math_gt_or_eq, 34, $(PLATFORM_SDK_VERSION)), true) + LOCAL_SHARED_LIBRARIES += android.hardware.power-V4-ndk else LOCAL_SHARED_LIBRARIES += android.hardware.power-V1-ndk_platform endif LOCAL_HEADER_LIBRARIES += libutils_headers LOCAL_HEADER_LIBRARIES += libhardware_headers -LOCAL_SRC_FILES := power-common.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c Power.cpp main.cpp +LOCAL_SRC_FILES := power-common.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c Power.cpp main.cpp PowerHintSession.cpp LOCAL_C_INCLUDES := external/libxml2/include \ external/icu/icu4c/source/common diff --git a/Power.cpp b/Power.cpp index c37fb31..0820013 100644 --- a/Power.cpp +++ b/Power.cpp @@ -25,11 +25,16 @@ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Changes from Qualcomm Innovation Center are provided under the following license: + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + * SPDX-License-Identifier: BSD-3-Clause-Clear */ #define LOG_TAG "QTI PowerHAL" #include "Power.h" +#include "PowerHintSession.h" #include @@ -125,15 +130,22 @@ ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool* _aidl_return) { *_aidl_return = false; return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus Power::createHintSession(int32_t, int32_t, const std::vector&, int64_t, +ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid, const std::vector& threadIds, int64_t durationNanos, std::shared_ptr* _aidl_return) { - *_aidl_return = nullptr; - return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + LOG(INFO) << "Power createHintSession"; + if (threadIds.size() == 0) { + LOG(ERROR) << "Error: threadIds.size() shouldn't be " << threadIds.size(); + *_aidl_return = nullptr; + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + *_aidl_return = setPowerHintSession(); + return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t* outNanoseconds) { - *outNanoseconds = -1; - return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + LOG(INFO) << "Power getHintSessionPreferredRate"; + *outNanoseconds = getSessionPreferredRate(); + return ndk::ScopedAStatus::ok(); } } // namespace impl diff --git a/PowerHintSession.cpp b/PowerHintSession.cpp new file mode 100644 index 0000000..3fec48c --- /dev/null +++ b/PowerHintSession.cpp @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. +* SPDX-License-Identifier: BSD-3-Clause-Clear +*/ + +#include "PowerHintSession.h" +#include +#define LOG_TAG "QTI PowerHAL" + +std::shared_ptr setPowerHintSession(){ + std::shared_ptr mPowerSession = ndk::SharedRefBase::make(); + return mPowerSession; +} + +int64_t getSessionPreferredRate(){ + return 16666666L; +} + +ndk::ScopedAStatus PowerHintSessionImpl::updateTargetWorkDuration(int64_t in_targetDurationNanos){ + return ndk::ScopedAStatus::ok(); + } +ndk::ScopedAStatus PowerHintSessionImpl::reportActualWorkDuration(const std::vector<::aidl::android::hardware::power::WorkDuration>& in_durations){ + return ndk::ScopedAStatus::ok(); + } +ndk::ScopedAStatus PowerHintSessionImpl::pause(){ + return ndk::ScopedAStatus::ok(); + } +ndk::ScopedAStatus PowerHintSessionImpl::resume(){ + return ndk::ScopedAStatus::ok(); +} +ndk::ScopedAStatus PowerHintSessionImpl::close(){ + return ndk::ScopedAStatus::ok(); +} +ndk::ScopedAStatus PowerHintSessionImpl::sendHint(aidl::android::hardware::power::SessionHint hint){ + return ndk::ScopedAStatus::ok(); +} +ndk::ScopedAStatus PowerHintSessionImpl::setThreads(const std::vector& threadIds){ + if (threadIds.size() == 0) { + LOG(ERROR) << "Error: threadIds.size() shouldn't be " << threadIds.size(); + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + return ndk::ScopedAStatus::ok(); +} diff --git a/PowerHintSession.h b/PowerHintSession.h new file mode 100644 index 0000000..bdf7428 --- /dev/null +++ b/PowerHintSession.h @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. +* SPDX-License-Identifier: BSD-3-Clause-Clear +*/ + +#ifndef __POWERHINTSESSION__ +#define __POWERHINTSESSION__ + +#include +#include +#include + +std::shared_ptr setPowerHintSession(); +int64_t getSessionPreferredRate(); + +class PowerHintSessionImpl : public aidl::android::hardware::power::BnPowerHintSession{ +public: + ndk::ScopedAStatus updateTargetWorkDuration(int64_t targetDurationNanos) override; + ndk::ScopedAStatus reportActualWorkDuration( + const std::vector& durations) override; + ndk::ScopedAStatus pause() override; + ndk::ScopedAStatus resume() override; + ndk::ScopedAStatus close() override; + ndk::ScopedAStatus sendHint(aidl::android::hardware::power::SessionHint hint) override; + ndk::ScopedAStatus setThreads(const std::vector& threadIds) override; +}; +#endif /* __POWERHINTSESSION__ */ \ No newline at end of file diff --git a/power.xml b/power.xml index 6185c42..b6aa04b 100644 --- a/power.xml +++ b/power.xml @@ -24,11 +24,15 @@ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Changes from Qualcomm Innovation Center are provided under the following license: +Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. +SPDX-License-Identifier: BSD-3-Clause-Clear --> android.hardware.power - 3 + 4 IPower/default \ No newline at end of file