Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd7eba40 authored by dianlujitao's avatar dianlujitao Committed by Michael Bestas
Browse files

perf: Add hooks used by lineage-sdk

Author: Steve Kondik <steve@cyngn.com>
Date:   Mon Nov 2 17:38:41 2015 -0800

    perf: Add plumbing for PerformanceManager

    * Expose a couple of helpers on PowerManagerInternal to handle
      features.

    Change-Id: Ic8df7d891dece4e678711a2a5ad1434b4971663a

Author: dianlujitao <dianlujitao@lineageos.org>
Date:   Thu Jan 18 17:09:33 2018 +0800

    perf: Adapt for HIDL Lineage power hal

    Change-Id: I90fd1438cc85d26777cf37d18c14e91dc38ea48f

Author: Luca Stefani <luca.stefani.ge1@gmail.com>
Date:   Wed, 29 Aug 2018 11:50:09 +0200

    perf: Update Lineage HAL impl to match AOSP

    Change-Id: I176e5687378cb14b4e2a9f41a9da81e735688a71

Change-Id: I2d170d86b6c90f4ef8145298bc142c1977db6037
parent 6fbd7964
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -317,4 +317,8 @@ public abstract class PowerManagerInternal {

    /** Allows power button to intercept a power key button press. */
    public abstract boolean interceptPowerKeyDown(KeyEvent event);

    public abstract boolean setPowerSaveMode(boolean mode);

    public abstract int getFeature(int featureId);
}
+11 −0
Original line number Diff line number Diff line
@@ -930,6 +930,7 @@ public final class PowerManagerService extends SystemService
    private static native void nativeSetAutoSuspend(boolean enable);
    private static native void nativeSetPowerBoost(int boost, int durationMs);
    private static native boolean nativeSetPowerMode(int mode, boolean enabled);
    private static native int nativeGetFeature(int featureId);
    private static native boolean nativeForceSuspend();

    public PowerManagerService(Context context) {
@@ -6139,5 +6140,15 @@ public final class PowerManagerService extends SystemService
        public boolean interceptPowerKeyDown(KeyEvent event) {
            return interceptPowerKeyDownInternal(event);
        }

        @Override
        public boolean setPowerSaveMode(boolean mode) {
            return setLowPowerModeInternal(mode);
        }

        @Override
        public int getFeature(int featureId) {
            return nativeGetFeature(featureId);
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ cc_defaults {
        "android.system.suspend.control.internal-cpp",
        "android.system.suspend@1.0",
        "service.incremental",
        "vendor.lineage.power-V1-cpp",
    ],

    static_libs: [
+11 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <android/system/suspend/ISuspendControlService.h>
#include <android/system/suspend/internal/ISuspendControlServiceInternal.h>
#include <nativehelper/JNIHelp.h>
#include <vendor/lineage/power/IPower.h>
#include "jni.h"

#include <nativehelper/ScopedUtfChars.h>
@@ -58,6 +59,7 @@ using android::system::suspend::V1_0::WakeLockType;
using IPowerV1_1 = android::hardware::power::V1_1::IPower;
using IPowerV1_0 = android::hardware::power::V1_0::IPower;
using IPowerAidl = android::hardware::power::IPower;
using LineageFeatureAidl = vendor::lineage::power::Feature;

namespace android {

@@ -198,6 +200,14 @@ void disableAutoSuspend() {
    }
}

static jint nativeGetFeature(JNIEnv* /* env */, jclass /* clazz */, jint featureId) {
    auto result = gPowerHalController.getFeature(static_cast<LineageFeatureAidl>(featureId));
    if (result.isOk()) {
        return static_cast<jint>(result.value());
    }
    return -1;
}

// ----------------------------------------------------------------------------

static void nativeInit(JNIEnv* env, jobject obj) {
@@ -260,6 +270,7 @@ static const JNINativeMethod gPowerManagerServiceMethods[] = {
        {"nativeSetAutoSuspend", "(Z)V", (void*)nativeSetAutoSuspend},
        {"nativeSetPowerBoost", "(II)V", (void*)nativeSetPowerBoost},
        {"nativeSetPowerMode", "(IZ)Z", (void*)nativeSetPowerMode},
        {"nativeGetFeature", "(I)I", (void*)nativeGetFeature},
};

#define FIND_CLASS(var, className) \