compatibility to latest decode lib

This commit is contained in:
strawmanbobi
2026-01-08 16:43:24 +08:00
parent 5ac08d7451
commit a8074a8f0d
3 changed files with 30 additions and 12 deletions

View File

@@ -4,7 +4,6 @@ import net.irext.decode.sdk.bean.ACStatus;
import net.irext.decode.sdk.bean.TemperatureRange;
import net.irext.decode.sdk.utils.Constants;
/**
* Filename: IRDecode.java
* Revised: Date: 2017-04-22
@@ -27,7 +26,7 @@ public class IRDecode {
private native int irOpenBinary(int category, int subCate, byte[] binaries, int binLength);
private native int[] irDecode(int keyCode, ACStatus acStatus, int changeWindDirection);
private native int[] irDecode(int keyCode, ACStatus acStatus);
private native void irClose();
@@ -42,7 +41,6 @@ public class IRDecode {
private native int irACGetSupportedWindDirection(int acMode);
private static IRDecode mInstance;
public static IRDecode getInstance() {
if (null == mInstance) {
mInstance = new IRDecode();
@@ -51,11 +49,10 @@ public class IRDecode {
}
private IRDecode() {
String libPath = "/data/irext/libir_decode.so";
String libPath = "/data/irext/libirdecode_jni.so";
System.out.println("loading decode library " + libPath);
System.load(libPath);
}
public String getVersion() {
return irGetVersion();
}
@@ -68,17 +65,17 @@ public class IRDecode {
return irOpenBinary(category, subCate, binaries, binLength);
}
public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) {
public int[] decodeBinary(int keyCode, ACStatus acStatus) {
int []decoded;
synchronized (mSync) {
if (null == acStatus) {
acStatus = new ACStatus();
}
// validate ac status
if (!validateAcStatus(acStatus, keyCode, changeWindDir)) {
if (!validateAcStatus(acStatus, keyCode)) {
return new int[0];
}
decoded = irDecode(keyCode, acStatus, changeWindDir);
decoded = irDecode(keyCode, acStatus);
}
return decoded;
}
@@ -131,7 +128,7 @@ public class IRDecode {
return irACGetSupportedWindDirection(acMode);
}
private boolean validateAcStatus(ACStatus acStatus, int keyCode, int changeWindDir) {
private boolean validateAcStatus(ACStatus acStatus, int keyCode) {
if (acStatus.getAcPower() != Constants.ACPower.POWER_ON.getValue() &&
acStatus.getAcPower() != Constants.ACPower.POWER_OFF.getValue()) {
return false;
@@ -152,7 +149,7 @@ public class IRDecode {
acStatus.getAcWindDir() > Constants.ACSwing.SWING_OFF.getValue()) {
return false;
}
if (changeWindDir != 0 && changeWindDir != 1) {
if (acStatus.getChangeWindDir() != 0 && acStatus.getChangeWindDir() != 1) {
return false;
}
return true;
@@ -166,7 +163,7 @@ public class IRDecode {
1,
"/home/strawmanbobi/Downloads/test.bin")) {
int[] decoded =
irDecoder.decodeBinary(1, null, 0);
irDecoder.decodeBinary(1, null);
for (int i = 0; i < decoded.length; i++) {
System.out.print(decoded[i]);
if (i != decoded.length - 1) {

View File

@@ -24,6 +24,7 @@ public class ACStatus {
private int acDisplay;
private int acSleep;
private int acTimer;
private int changeWindDir;
public ACStatus() {
this.acPower = Constants.ACPower.POWER_OFF.getValue();
@@ -34,10 +35,11 @@ public class ACStatus {
this.acTimer = 0;
this.acDisplay = 0;
this.acSleep = 0;
this.changeWindDir = 0;
}
public ACStatus(int acPower, int acMode, int acTemp, int acWindSpeed, int acWindDir,
int acDisplay, int acSleep, int acTimer) {
int acDisplay, int acSleep, int acTimer, int changeWindDir) {
this.acPower = acPower;
this.acTemp = acTemp;
this.acMode = acMode;
@@ -46,6 +48,7 @@ public class ACStatus {
this.acDisplay = acDisplay;
this.acSleep = acSleep;
this.acTimer = acTimer;
this.changeWindDir = changeWindDir;
}
public int getAcPower() {
@@ -112,4 +115,11 @@ public class ACStatus {
this.acTimer = acTimer;
}
public int getChangeWindDir() {
return changeWindDir;
}
public void setChangeWindDir(int changeWindDir) {
this.changeWindDir = changeWindDir;
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/decodesdk/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>