Loading services/core/jni/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -177,7 +177,7 @@ cc_defaults { "android.hardware.power@1.1", "android.hardware.power@1.2", "android.hardware.power@1.3", "android.hardware.power-V4-cpp", "android.hardware.power-V4-ndk", "android.hardware.power.stats@1.0", "android.hardware.power.stats-V1-ndk", "android.hardware.thermal@1.0", Loading services/core/jni/com_android_server_hint_HintManagerService.cpp +23 −22 Original line number Diff line number Diff line Loading @@ -18,77 +18,78 @@ //#define LOG_NDEBUG 0 #include <aidl/android/hardware/power/IPower.h> #include <android-base/stringprintf.h> #include <android/hardware/power/IPower.h> #include <android_runtime/AndroidRuntime.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedPrimitiveArray.h> #include <powermanager/PowerHalController.h> #include <utils/Log.h> #include <unistd.h> #include <cinttypes> #include <sys/types.h> #include <unordered_map> #include "jni.h" using android::hardware::power::IPowerHintSession; using android::hardware::power::SessionHint; using android::hardware::power::WorkDuration; using aidl::android::hardware::power::IPowerHintSession; using aidl::android::hardware::power::SessionHint; using aidl::android::hardware::power::WorkDuration; using android::base::StringPrintf; namespace android { static power::PowerHalController gPowerHalController; static std::unordered_map<jlong, std::shared_ptr<IPowerHintSession>> gSessionMap; static std::mutex gSessionMapLock; static jlong createHintSession(JNIEnv* env, int32_t tgid, int32_t uid, std::vector<int32_t> threadIds, int64_t durationNanos) { auto result = gPowerHalController.createHintSession(tgid, uid, std::move(threadIds), durationNanos); auto result = gPowerHalController.createHintSession(tgid, uid, threadIds, durationNanos); if (result.isOk()) { sp<IPowerHintSession> appSession = result.value(); if (appSession) appSession->incStrong(env); return reinterpret_cast<jlong>(appSession.get()); auto session_ptr = reinterpret_cast<jlong>(result.value().get()); { std::unique_lock<std::mutex> sessionLock(gSessionMapLock); auto res = gSessionMap.insert({session_ptr, result.value()}); return res.second ? session_ptr : 0; } } return 0; } static void pauseHintSession(JNIEnv* env, int64_t session_ptr) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->pause(); } static void resumeHintSession(JNIEnv* env, int64_t session_ptr) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->resume(); } static void closeHintSession(JNIEnv* env, int64_t session_ptr) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->close(); appSession->decStrong(env); std::unique_lock<std::mutex> sessionLock(gSessionMapLock); gSessionMap.erase(session_ptr); } static void updateTargetWorkDuration(int64_t session_ptr, int64_t targetDurationNanos) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->updateTargetWorkDuration(targetDurationNanos); } static void reportActualWorkDuration(int64_t session_ptr, const std::vector<WorkDuration>& actualDurations) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->reportActualWorkDuration(actualDurations); } static void sendHint(int64_t session_ptr, SessionHint hint) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->sendHint(hint); } static void setThreads(int64_t session_ptr, const std::vector<int32_t>& threadIds) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->setThreads(threadIds); } Loading services/core/jni/com_android_server_power_PowerManagerService.cpp +13 −21 Original line number Diff line number Diff line Loading @@ -18,48 +18,40 @@ //#define LOG_NDEBUG 0 #include "com_android_server_power_PowerManagerService.h" #include <aidl/android/hardware/power/Boost.h> #include <aidl/android/hardware/power/Mode.h> #include <aidl/android/system/suspend/ISystemSuspend.h> #include <aidl/android/system/suspend/IWakeLock.h> #include <android/hardware/power/1.1/IPower.h> #include <android/hardware/power/Boost.h> #include <android/hardware/power/IPower.h> #include <android/hardware/power/Mode.h> #include <android/system/suspend/ISuspendControlService.h> #include <android/system/suspend/internal/ISuspendControlServiceInternal.h> #include <nativehelper/JNIHelp.h> #include "jni.h" #include <nativehelper/ScopedUtfChars.h> #include <powermanager/PowerHalController.h> #include <limits.h> #include <android-base/chrono_utils.h> #include <android/binder_manager.h> #include <android/system/suspend/ISuspendControlService.h> #include <android/system/suspend/internal/ISuspendControlServiceInternal.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <binder/IServiceManager.h> #include <gui/SurfaceComposerClient.h> #include <hardware/power.h> #include <hardware_legacy/power.h> #include <hidl/ServiceManagement.h> #include <limits.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedUtfChars.h> #include <powermanager/PowerHalController.h> #include <utils/Log.h> #include <utils/String8.h> #include <utils/Timers.h> #include <utils/misc.h> #include "com_android_server_power_PowerManagerService.h" #include "jni.h" using aidl::android::hardware::power::Boost; using aidl::android::hardware::power::Mode; using aidl::android::system::suspend::ISystemSuspend; using aidl::android::system::suspend::IWakeLock; using aidl::android::system::suspend::WakeLockType; using android::String8; using android::hardware::power::Boost; using android::hardware::power::Mode; using android::system::suspend::ISuspendControlService; using IPowerV1_1 = android::hardware::power::V1_1::IPower; using IPowerV1_0 = android::hardware::power::V1_0::IPower; using IPowerAidl = android::hardware::power::IPower; namespace android { Loading services/core/jni/com_android_server_power_PowerManagerService.h +3 −2 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ #define _ANDROID_SERVER_POWER_MANAGER_SERVICE_H #include <nativehelper/JNIHelp.h> #include "jni.h" #include <powermanager/PowerManager.h> #include <utils/Timers.h> #include "jni.h" namespace android { Loading Loading
services/core/jni/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -177,7 +177,7 @@ cc_defaults { "android.hardware.power@1.1", "android.hardware.power@1.2", "android.hardware.power@1.3", "android.hardware.power-V4-cpp", "android.hardware.power-V4-ndk", "android.hardware.power.stats@1.0", "android.hardware.power.stats-V1-ndk", "android.hardware.thermal@1.0", Loading
services/core/jni/com_android_server_hint_HintManagerService.cpp +23 −22 Original line number Diff line number Diff line Loading @@ -18,77 +18,78 @@ //#define LOG_NDEBUG 0 #include <aidl/android/hardware/power/IPower.h> #include <android-base/stringprintf.h> #include <android/hardware/power/IPower.h> #include <android_runtime/AndroidRuntime.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedPrimitiveArray.h> #include <powermanager/PowerHalController.h> #include <utils/Log.h> #include <unistd.h> #include <cinttypes> #include <sys/types.h> #include <unordered_map> #include "jni.h" using android::hardware::power::IPowerHintSession; using android::hardware::power::SessionHint; using android::hardware::power::WorkDuration; using aidl::android::hardware::power::IPowerHintSession; using aidl::android::hardware::power::SessionHint; using aidl::android::hardware::power::WorkDuration; using android::base::StringPrintf; namespace android { static power::PowerHalController gPowerHalController; static std::unordered_map<jlong, std::shared_ptr<IPowerHintSession>> gSessionMap; static std::mutex gSessionMapLock; static jlong createHintSession(JNIEnv* env, int32_t tgid, int32_t uid, std::vector<int32_t> threadIds, int64_t durationNanos) { auto result = gPowerHalController.createHintSession(tgid, uid, std::move(threadIds), durationNanos); auto result = gPowerHalController.createHintSession(tgid, uid, threadIds, durationNanos); if (result.isOk()) { sp<IPowerHintSession> appSession = result.value(); if (appSession) appSession->incStrong(env); return reinterpret_cast<jlong>(appSession.get()); auto session_ptr = reinterpret_cast<jlong>(result.value().get()); { std::unique_lock<std::mutex> sessionLock(gSessionMapLock); auto res = gSessionMap.insert({session_ptr, result.value()}); return res.second ? session_ptr : 0; } } return 0; } static void pauseHintSession(JNIEnv* env, int64_t session_ptr) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->pause(); } static void resumeHintSession(JNIEnv* env, int64_t session_ptr) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->resume(); } static void closeHintSession(JNIEnv* env, int64_t session_ptr) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->close(); appSession->decStrong(env); std::unique_lock<std::mutex> sessionLock(gSessionMapLock); gSessionMap.erase(session_ptr); } static void updateTargetWorkDuration(int64_t session_ptr, int64_t targetDurationNanos) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->updateTargetWorkDuration(targetDurationNanos); } static void reportActualWorkDuration(int64_t session_ptr, const std::vector<WorkDuration>& actualDurations) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->reportActualWorkDuration(actualDurations); } static void sendHint(int64_t session_ptr, SessionHint hint) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->sendHint(hint); } static void setThreads(int64_t session_ptr, const std::vector<int32_t>& threadIds) { sp<IPowerHintSession> appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); auto appSession = reinterpret_cast<IPowerHintSession*>(session_ptr); appSession->setThreads(threadIds); } Loading
services/core/jni/com_android_server_power_PowerManagerService.cpp +13 −21 Original line number Diff line number Diff line Loading @@ -18,48 +18,40 @@ //#define LOG_NDEBUG 0 #include "com_android_server_power_PowerManagerService.h" #include <aidl/android/hardware/power/Boost.h> #include <aidl/android/hardware/power/Mode.h> #include <aidl/android/system/suspend/ISystemSuspend.h> #include <aidl/android/system/suspend/IWakeLock.h> #include <android/hardware/power/1.1/IPower.h> #include <android/hardware/power/Boost.h> #include <android/hardware/power/IPower.h> #include <android/hardware/power/Mode.h> #include <android/system/suspend/ISuspendControlService.h> #include <android/system/suspend/internal/ISuspendControlServiceInternal.h> #include <nativehelper/JNIHelp.h> #include "jni.h" #include <nativehelper/ScopedUtfChars.h> #include <powermanager/PowerHalController.h> #include <limits.h> #include <android-base/chrono_utils.h> #include <android/binder_manager.h> #include <android/system/suspend/ISuspendControlService.h> #include <android/system/suspend/internal/ISuspendControlServiceInternal.h> #include <android_runtime/AndroidRuntime.h> #include <android_runtime/Log.h> #include <binder/IServiceManager.h> #include <gui/SurfaceComposerClient.h> #include <hardware/power.h> #include <hardware_legacy/power.h> #include <hidl/ServiceManagement.h> #include <limits.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/ScopedUtfChars.h> #include <powermanager/PowerHalController.h> #include <utils/Log.h> #include <utils/String8.h> #include <utils/Timers.h> #include <utils/misc.h> #include "com_android_server_power_PowerManagerService.h" #include "jni.h" using aidl::android::hardware::power::Boost; using aidl::android::hardware::power::Mode; using aidl::android::system::suspend::ISystemSuspend; using aidl::android::system::suspend::IWakeLock; using aidl::android::system::suspend::WakeLockType; using android::String8; using android::hardware::power::Boost; using android::hardware::power::Mode; using android::system::suspend::ISuspendControlService; using IPowerV1_1 = android::hardware::power::V1_1::IPower; using IPowerV1_0 = android::hardware::power::V1_0::IPower; using IPowerAidl = android::hardware::power::IPower; namespace android { Loading
services/core/jni/com_android_server_power_PowerManagerService.h +3 −2 Original line number Diff line number Diff line Loading @@ -18,9 +18,10 @@ #define _ANDROID_SERVER_POWER_MANAGER_SERVICE_H #include <nativehelper/JNIHelp.h> #include "jni.h" #include <powermanager/PowerManager.h> #include <utils/Timers.h> #include "jni.h" namespace android { Loading