Re-enabling the lost touch key backlight duration option on Samsung Galaxy S7


One feature that is somehow missing from Samsung Galaxy S7 is an option to configure “Touch key light duration”. Because of how firmwares are built today, all the “code and screens” are still there, it’s just limited to AT&T (for some strange reason).

To get it back you could use Galaxy Button Lights 2 app. This however wasn’t good/elegant/clean enough for me so I added support for bringing the native configuration screen back to system Settings via my “All My… (Xposed Tweaks)” collection.

samsung-galaxy-s7-touch-key-light-duration

Isn’t that nicer? It’s way cleaner and more simple solution (if you’re rooted & Xposed). The actual code looks like this:

package com.smartmadsoft.xposed.aio.tweaks;

import android.os.Bundle;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class S7TouchKeyLight {
    public static boolean spoofATT = false;
    
    public static void hook(final XC_LoadPackage.LoadPackageParam lpparam) {
        try {
            XposedHelpers.findAndHookMethod(XposedHelpers.findClass("com.android.settings.DisplaySettings", lpparam.classLoader), "onCreate", Bundle.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
                    spoofATT = true;
                }

                @Override
                protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
                    spoofATT = false;
                }
            });

            XposedHelpers.findAndHookMethod(XposedHelpers.findClass("com.android.settings.Utils", lpparam.classLoader), "readSalesCode", new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(final MethodHookParam param) throws Throwable {
                    if (spoofATT)
                        param.setResult("ATT");
                }
            });
        } catch (Throwable t) {
            XposedBridge.log(t);
        }
    }
}

I’m not fully satisfied with the code but so far I can’t think of anything better (mainly because of the trouble of hooking abstract classes).

Leave a comment