Skip to content

Commit

Permalink
misc_android: Fix SysPeakRefreshRate not worning in MIUI14
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Yang <[email protected]>
  • Loading branch information
yc9559 committed Jan 15, 2023
1 parent bd88a38 commit 6571dca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions magisk/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ on_remove() {
mkdir -p $USER_PATH
mv /sdcard/dfps.txt $USER_PATH/

cmd settings delete system min_refresh_rate
cmd settings delete system miui_refresh_rate
cmd settings delete system peak_refresh_rate
cmd settings reset system min_refresh_rate
cmd settings reset system peak_refresh_rate
cmd settings reset system miui_refresh_rate
cmd settings reset secure miui_refresh_rate
}

# do not block boot
Expand Down
11 changes: 6 additions & 5 deletions source/utils/misc_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,19 @@ int GetScreenBrightness(void) {
return -1;
}

void SyncCallPutRefreshRate(const char *key, const char *hz) {
ExecCmdSync(nullptr, "/system/bin/cmd", "settings", "put", "system", key, hz);
void CallSettingsPut(const char *ns, const char *key, const char *val) {
ExecCmd(nullptr, "/system/bin/cmd", "settings", "put", ns, key, val);
}

void SyncCallSurfaceflingerBackdoor(const char *code, const char *hz) {
ExecCmdSync(nullptr, "/system/bin/service", "call", "SurfaceFlinger", code, "i32", hz);
}

void SysPeakRefreshRate(const std::string &hz, bool force) {
SyncCallPutRefreshRate("peak_refresh_rate", hz.c_str());
SyncCallPutRefreshRate("min_refresh_rate", hz.c_str());
SyncCallPutRefreshRate("miui_refresh_rate", hz.c_str());
CallSettingsPut("system", "peak_refresh_rate", hz.c_str());
CallSettingsPut("system", "min_refresh_rate", hz.c_str());
CallSettingsPut("system", "miui_refresh_rate", hz.c_str());
CallSettingsPut("secure", "miui_refresh_rate", hz.c_str());
}

void SysSurfaceflingerBackdoor(const std::string &idx, bool force) {
Expand Down

0 comments on commit 6571dca

Please sign in to comment.