Skip to content

Commit

Permalink
Tweak(pref-detection): Verify all cores aren't the same frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias-Boulay committed Dec 19, 2024
1 parent f205209 commit b57a0cd
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import net.kdt.pojavlaunch.multirt.MultiRTUtils;
import net.kdt.pojavlaunch.utils.JREUtils;

import java.io.IOException;

public class LauncherPreferences {
public static final String PREF_KEY_CURRENT_PROFILE = "currentProfile";
public static final String PREF_KEY_SKIP_NOTIFICATION_CHECK = "skipNotificationPermissionCheck";
Expand Down Expand Up @@ -175,9 +177,22 @@ private static boolean isDevicePowerful(Context context) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
if (Math.min(metrics.widthPixels, metrics.heightPixels) < 1080) return false;
if (Runtime.getRuntime().availableProcessors() <= 4) return false;
if (hasAllCoreSameFreq()) return false;
return true;
}

private static boolean hasAllCoreSameFreq() {
int coreCount = Runtime.getRuntime().availableProcessors();
try {
String freq0 = Tools.read("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");
String freqX = Tools.read("/sys/devices/system/cpu/cpu" + (coreCount - 1) + "/cpufreq/cpuinfo_max_freq");
if(freq0.equals(freqX)) return true;
} catch (IOException e) {
Log.e("LauncherPreferences", "Failed to read CPU frequencies", e);
}
return false;
}

/** Compute the notch size to avoid being out of bounds */
public static void computeNotchSize(Activity activity) {
if (Build.VERSION.SDK_INT < P) return;
Expand Down

0 comments on commit b57a0cd

Please sign in to comment.