Skip to content
This repository was archived by the owner on Oct 5, 2019. It is now read-only.

Commit 7721c2d

Browse files
committed
sound: Fix faux checksum properly
1 parent e46b817 commit 7721c2d

File tree

1 file changed

+6
-4
lines changed
  • app/src/main/java/com/grarak/kerneladiutor/utils/kernel/sound

1 file changed

+6
-4
lines changed

app/src/main/java/com/grarak/kerneladiutor/utils/kernel/sound/Sound.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,15 @@ public static boolean supported() {
354354
|| hasMicrophoneGain() || hasVolumeGain();
355355
}
356356

357-
private static int getChecksum(int arg0, int arg1) {
358-
return 0xff & (Integer.MAX_VALUE ^ (arg0 & 0xff) + (arg1 & 0xff));
357+
private static long getChecksum(int a, int b) {
358+
return (Integer.MAX_VALUE * 2L + 1L) ^ (a + b);
359359
}
360360

361361
private static void fauxRun(String value, String path, String id, Context context) {
362-
int checksum = value.contains(" ") ? getChecksum(Utils.strToInt(value.split(" ")[0]),
363-
Utils.strToInt(value.split(" ")[1])) : getChecksum(Utils.strToInt(value), 0);
362+
long checksum = value.contains(" ") ?
363+
getChecksum(Utils.strToInt(value.split(" ")[0]),
364+
Utils.strToInt(value.split(" ")[1])) :
365+
getChecksum(Utils.strToInt(value), 0);
364366
run(Control.write(value + " " + checksum, path), id, context);
365367
run(Control.write(value, path), id + "nochecksum", context);
366368
}

0 commit comments

Comments
 (0)