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

Commit 41730287 authored by Aaron Kling's avatar Aaron Kling Committed by Paul Keith
Browse files

Add nvcpl hook interfaces

NvCPL works in conjunction with the PowerHAL in order to adjust various
performance knobs based on the app or device specific profiles.

Change-Id: I4953cbb96d729dbe0cee6d7071b5933586770330
parent 86f0e8bb
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
package com.nvidia.NvCPLSvc;

import android.content.Intent;
import java.util.List;

import com.nvidia.NvCPLSvc.NvAppProfile;
import com.nvidia.NvCPLSvc.NvSaverAppInfo;

/** @hide */
interface INvCPLRemoteService {
    IBinder getToolsApiInterface(String str);
    String getAppProfileSettingString(String pkgName, int settingId);
    int getAppProfileSettingInt(String pkgName, int settingId);
    int getAppProfileSettingBoolean(String pkgName, int settingId);
    byte[] getAppProfileSetting3DVStruct(String pkgName);
    void handleIntent(in Intent intent);
    boolean setNvSaverAppInfo(String pkgName, int list);
    boolean setNvSaverAppInfoAll(in List<NvSaverAppInfo> appList);
    List<NvSaverAppInfo> getNvSaverAppInfo(int i);
    boolean setAppProfileSetting(String packageName, int typeId, int settingId, String value);
    int getActiveProfileType(String packageName);
    int[] getProfileTypes(String str);
    boolean setActiveProfileType(String packageName, int typeId);
    NvAppProfile[] getAppProfiles(in String[] strArr);
    String getDeviceSerial();
    void powerHint(String str);
}
+2 −0
Original line number Diff line number Diff line
package com.nvidia.NvCPLSvc;
parcelable NvAppProfile;
+65 −0
Original line number Diff line number Diff line
package com.nvidia.NvCPLSvc;

import android.net.ProxyInfo;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseArray;

public class NvAppProfile implements Parcelable {
    public static final Creator<NvAppProfile> CREATOR = new Creator<NvAppProfile>() {
        public NvAppProfile createFromParcel(Parcel parcel) {
            return NvAppProfile.createFromParcel(parcel);
        }

        public NvAppProfile[] newArray(int size) {
            return new NvAppProfile[size];
        }
    };
    public final String pkgName;
    public final String pkgVersion;
    public final int typeId;
    public SparseArray<String> settings;

    public NvAppProfile(int typeId, String pkgName, String pkgVersion,
            SparseArray<String> settings) {
        this.typeId = typeId;
        this.pkgName = pkgName;
        this.pkgVersion = pkgVersion;
        this.settings = settings;
    }

    private static NvAppProfile createFromParcel(Parcel parcel) {
        int typeId = parcel.readInt();
        String pkgName = decodeNull(parcel.readString());
        String pkgVersion = decodeNull(parcel.readString());
        int numSettings = parcel.readInt();
        SparseArray<String> settings = new SparseArray();
        for (int i = 0; i < numSettings; i++) {
            settings.append(parcel.readInt(), parcel.readString());
        }
        return new NvAppProfile(typeId, pkgName, pkgVersion, settings);
    }

    private static String encodeNull(String string) {
        return string != null ? string : ProxyInfo.LOCAL_EXCL_LIST;
    }

    private static String decodeNull(String string) {
        return !string.equals(ProxyInfo.LOCAL_EXCL_LIST) ? string : null;
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel parcel, int flag) {
        parcel.writeInt(this.typeId);
        parcel.writeString(encodeNull(this.pkgName));
        parcel.writeString(encodeNull(this.pkgVersion));
        parcel.writeInt(this.settings.size());
        for (int i = 0; i < this.settings.size(); i++) {
            parcel.writeInt(this.settings.keyAt(i));
            parcel.writeString((String) this.settings.valueAt(i));
        }
    }
}
+2 −0
Original line number Diff line number Diff line
package com.nvidia.NvCPLSvc;
parcelable NvSaverAppInfo;
+166 −0
Original line number Diff line number Diff line
package com.nvidia.NvCPLSvc;

import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;

public class NvSaverAppInfo implements Parcelable {
    public static final Creator<NvSaverAppInfo> CREATOR = new Creator<NvSaverAppInfo>() {
        public NvSaverAppInfo createFromParcel(Parcel source) {
            return new NvSaverAppInfo(source);
        }

        public NvSaverAppInfo[] newArray(int size) {
            return new NvSaverAppInfo[size];
        }
    };

    public static final int NVSAVER_ACTIVITY_HIGH = 1;
    public static final int NVSAVER_ACTIVITY_LOW = 3;
    public static final int NVSAVER_ACTIVITY_MIDIUM = 2;
    public static final int NVSAVER_LIST_BLACKLIST = 3;
    public static final int NVSAVER_LIST_NONE = 1;
    public static final int NVSAVER_LIST_WHITELIST = 2;
    public static final int NV_APP_OPTIMIZE_LIST = 4;
    public int mAppList;
    public String mPkgName;
    public long mTotalWakeupStatsTime;
    public int mUid;
    public long mWakeupStatsTime;
    public int mWakeupTimes;
    public int mWowWakeupTimes;
    private int mAppActivity;
    private Drawable mAppIcon;
    private String mAppLabel;
    private float mPowerSaver;

    public NvSaverAppInfo(Parcel pl) {
        mUid = pl.readInt();
        mAppList = pl.readInt();
        mWakeupTimes = pl.readInt();
        mWowWakeupTimes = pl.readInt();
        mPkgName = pl.readString();
        mWakeupStatsTime = pl.readLong();
        mTotalWakeupStatsTime = pl.readLong();
        mAppLabel = null;
        mAppIcon = null;
        mAppActivity = 0;
        mPowerSaver = 0.0f;
    }

    public NvSaverAppInfo(int u, int a, int w, int wow, String pkg, long t1, long t2) {
        mUid = u;
        mAppList = a;
        mWakeupTimes = w;
        mWowWakeupTimes = wow;
        mPkgName = pkg;
        mWakeupStatsTime = t1;
        mTotalWakeupStatsTime = t2;
        mAppLabel = null;
        mAppIcon = null;
        mAppActivity = 0;
        mPowerSaver = 0.0f;
    }

    public String getAppLabel() {
        return mAppLabel;
    }

    public void setAppLabel(String appLabel) {
        mAppLabel = appLabel;
    }

    public Drawable getAppIcon() {
        return mAppIcon;
    }

    public void setAppIcon(Drawable appIcon) {
        mAppIcon = appIcon;
    }

    public int getAppActivity() {
        return mAppActivity;
    }

    public void setAppActivity(int activity) {
        mAppActivity = activity;
    }

    public String getPkgName() {
        return mPkgName;
    }

    public void setPkgName(String pkgName) {
        mPkgName = pkgName;
    }

    public int getUid() {
        return mUid;
    }

    public void setUid(int uid) {
        mUid = uid;
    }

    public int getWakeupTimes() {
        return mWakeupTimes;
    }

    public void setWakeupTimes(int wakeupTimes) {
        mWakeupTimes = wakeupTimes;
    }

    public int getWowWakeupTimes() {
        return mWowWakeupTimes;
    }

    public void setWowWakeupTimes(int wowWakeupTimes) {
        mWowWakeupTimes = wowWakeupTimes;
    }

    public long getTotalWakeupStatsTime() {
        return mTotalWakeupStatsTime;
    }

    public void setTotalWakeupStatsTime(long totalWakeupStatsTime) {
        mTotalWakeupStatsTime = totalWakeupStatsTime;
    }

    public long getWakeupStatsTime() {
        return mWakeupStatsTime;
    }

    public void setWakeupStatsTime(long wakeupStatsTime) {
        mWakeupStatsTime = wakeupStatsTime;
    }

    public int getAppList() {
        return mAppList;
    }

    public void setAppList(int appList) {
        mAppList = appList;
    }

    public float getPowerSaver() {
        return mPowerSaver;
    }

    public void setPowerSaver(float powerSaver) {
        mPowerSaver = powerSaver;
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mUid);
        dest.writeInt(mAppList);
        dest.writeInt(mWakeupTimes);
        dest.writeInt(mWowWakeupTimes);
        dest.writeString(mPkgName);
        dest.writeLong(mWakeupStatsTime);
        dest.writeLong(mTotalWakeupStatsTime);
    }
}