compatibility to latest decode lib

This commit is contained in:
strawmanbobi
2026-01-08 16:29:38 +08:00
parent bf075bdec8
commit 5ac08d7451
7 changed files with 19 additions and 10 deletions

View File

@@ -205,6 +205,7 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
acStatus.setAcTemp(Constants.ACTemperature.TEMP_24.getValue());
acStatus.setAcWindSpeed(Constants.ACWindSpeed.SPEED_AUTO.getValue());
acStatus.setAcWindDir(Constants.ACSwing.SWING_ON.getValue());
acStatus.setChangeWindDir(0);
acStatus.setAcDisplay(0);
acStatus.setAcTimer(0);
acStatus.setAcSleep(0);
@@ -250,7 +251,7 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
/* translate key code for AC according to the mapping above */
/* ac status is useless for decoding devices other than AC, it's an optional parameter */
/* change wind dir is an optional parameter, set to 0 as default */
return mIRDecode.decodeBinary(inputKeyCode, acStatus, 0);
return mIRDecode.decodeBinary(inputKeyCode, acStatus);
}
private void onEmitterConnected() {

Binary file not shown.

Binary file not shown.

BIN
android-example/app/src/main/jniLibs/x86/libirdecode.so Normal file → Executable file

Binary file not shown.

Binary file not shown.

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
@@ -31,7 +30,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();
@@ -46,7 +45,6 @@ public class IRDecode {
private native int irACGetSupportedWindDirection(int acMode);
private static IRDecode mInstance;
public static IRDecode getInstance() {
if (null == mInstance) {
mInstance = new IRDecode();
@@ -66,17 +64,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;
}
@@ -129,7 +127,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;
@@ -150,7 +148,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;

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;
}
}