[Android General] prototype74:
How to change DVFS, HQM and SSRM properties to stock on ported TW Oreo ROMs​

What's the purpose of this guide?

Some ported ROMs (especially flagship ported ROMs to mid range devices) might have performance drops or charging issues. Using stock properties might help a lot to fix such issues. I had that on my old A3 2015 once where my A3 didn't charged anymore after I had ported an A8 2018 ROM to it.

Now lets getting started :)

INFO: As example in this guide I have take A8 2018 as my port ROM and A5 2017 as my stock device

1. Change DVFS & SSRM

1.1

First we need to know the ssrm name and soc name from our stock ROM.

Decompile services.jar

Go to services.jar/smali/com/android/server/SsrmService.smali

You might see something like this in # static fields:

# static fields
.field public static final AIR_VIEW_PROVIDER_NAME:Ljava/lang/String; = ""

.field public static final BASE_MODEL:Ljava/lang/String; = ""

.field public static final COMMON_GESTURE_WITH_FINGERHOVER:Z

[COLOR="blue"].field public static final DVFS_FILENAME:Ljava/lang/String; = "dvfs_policy_XXXXXXXXXXXXXXXx_xx"[/COLOR]

.field public static GMS_BUNDLING:Z = false

[COLOR="Blue"].field public static final SSRM_FILENAME:Ljava/lang/String; = "ssrm_XXXXXX_xx"[/COLOR]

.field public static final SUPPORT_WEARABLE_HMT:Z = true

We need these 2 strings from blue lines to use them later in our ported ROM

Example from A5 2017:

.field public static final DVFS_FILENAME:Ljava/lang/String; = "dvfs_policy_exynos7880_xx"

.field public static final SSRM_FILENAME:Ljava/lang/String; = "ssrm_a5y17_xx"

So this means the DVFS name from A5 2017 is dvfs_policy_exynos7880_xx and SSRM is ssrm_a5y17_xx.

Now open SsrmService.smali in your ported ROM and get it's strings too (you'll need them later in framework.jar)

Example from A8 2018:

.field public static final DVFS_FILENAME:Ljava/lang/String; = "[COLOR="red"]dvfs_policy_exynos7885_xx[/COLOR]"

.field public static final SSRM_FILENAME:Ljava/lang/String; = "[COLOR="red"]ssrm_jackpotlte_xx[/COLOR]"

Now replace these strings with your stock one

Recompile services.jar

1.2

Now decompile framework.jar

Go to framework.jar/smali_classes3/com/samsung/android/os/SemDvfsCpuManager.smali

Search for all dvfs_policy_XXXXXXXX_xx strings in your port ROM (example: dvfs_policy_exynos7885_xx):

...

const-string/jumbo v3, "[COLOR="red"]dvfs_policy_exynos7885_xx[/COLOR]"

const-string/jumbo v4, "msm8996"

invoke-virtual {v3, v4}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
...

and replace them all with your stock (example: dvfs_policy_exynos7880_xx):

...

const-string/jumbo v3, "[COLOR="blue"]dvfs_policy_exynos7880_xx[/COLOR]"

const-string/jumbo v4, "msm8996"

invoke-virtual {v3, v4}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z

...

Search for all ssrm_XXXXXX_xx strings in same smali and replace them with stock strings like you did with dvfs_policy_XXXXXXXX_xx strings

Also replace these strings in these following smalis:

framework.jar/smali_classes3/com/samsung/android/os/SemDvfsGpuManager.smali (DVFS strings only)

framework.jar/smali_classes3/com/samsung/android/os/SemDvfsManager.smali

framework.jar/smali_classes3/com/samsung/android/os/SemDvfsPresets.smali (SSRM strings only)

framework.jar/smali_classes3/com/samsung/android/os/SemPerfManager.smali (SSRM string only)

Recompile framework.jar

2. HQM

We need to know the hqm name from our device first.

For this decompile hqm.jar and go to hqm.jar/smali/com/samsung/android/hqm/setting/Feature.smali

Search for this constructor:

.method public constructor <init>()V
.locals 1

invoke-direct {p0}, Ljava/lang/Object;-><init>()V

const-string/jumbo v0, "[COLOR="DarkRed"]hqm_XXXXXXXX[/COLOR]"

iput-object v0, p0, Lcom/samsung/android/hqm/setting/Feature;->configFile:Ljava/lang/String;

return-void
.end method

You probably saw the "hqm_XXXXXXXX" string. Now go to hqm.jar in ported ROM and replace this string with your stock

Example:

.method public constructor <init>()V
.locals 1

invoke-direct {p0}, Ljava/lang/Object;-><init>()V

const-string/jumbo v0, "[COLOR="red"]hqm_jackpotlte[/COLOR]"

iput-object v0, p0, Lcom/samsung/android/hqm/setting/Feature;->configFile:Ljava/lang/String;

return-void
.end method

replaced to

.method public constructor <init>()V
.locals 1

invoke-direct {p0}, Ljava/lang/Object;-><init>()V

const-string/jumbo v0, "[COLOR="Blue"]hqm_a5y17lte[/COLOR]"

iput-object v0, p0, Lcom/samsung/android/hqm/setting/Feature;->configFile:Ljava/lang/String;

return-void
.end method

Recompile hqm.jar

These strings are actually the names of .xml files. They're stored in framework-res.apk/res/raw.

Now your ported ROM uses stock properties again. Of course you can use this guide to change your ROMs properties to any other (custom) properties.

Enjoy!