use decode_combo in order to fix some memory issue

This commit is contained in:
strawmanbobi
2019-03-04 23:41:33 +08:00
parent 4120da5db2
commit 4ede47f9b1
2 changed files with 98 additions and 57 deletions

View File

@@ -3,6 +3,7 @@ package net.irext.decode.sdk;
import net.irext.decode.sdk.bean.ACStatus;
import net.irext.decode.sdk.bean.TemperatureRange;
import net.irext.decode.sdk.utils.Constants;
import net.irext.decode.service.utils.LoggerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.ServletContext;
@@ -34,6 +35,9 @@ public class IRDecode {
private native void irClose();
private native int[] irDecodeCombo(int category, int subCate, byte[] binaries, int binLength,
int keyCode, ACStatus acStatus, int changeWindDirection);
private native TemperatureRange irACGetTemperatureRange(int acMode);
private native int irACGetSupportedMode();
@@ -71,13 +75,38 @@ public class IRDecode {
int[] decoded;
synchronized (mSync) {
if (null == acStatus) {
LoggerUtil.getInstance().trace(TAG, "AC Status is null, create a default one");
acStatus = new ACStatus();
} else {
LoggerUtil.getInstance().trace(TAG, "AC Status = " +
acStatus.getAcPower() + ", " + acStatus.getAcMode() +
", " + acStatus.getAcTemp() + ", " + acStatus.getAcWindSpeed() +
", " + acStatus.getAcWindDir() + ", keyCode = " + keyCode);
}
decoded = irDecode(keyCode, acStatus, changeWindDir);
}
return decoded;
}
public int[] decodeBinary(int category, int subCate, byte[] binaries, int binLength,
int keyCode, ACStatus acStatus, int changeWindDir) {
int[] decoded;
synchronized (mSync) {
if (null == acStatus) {
LoggerUtil.getInstance().trace(TAG, "AC Status is null, create a default one");
acStatus = new ACStatus();
} else {
LoggerUtil.getInstance().trace(TAG, "AC Status = " +
acStatus.getAcPower() + ", " + acStatus.getAcMode() +
", " + acStatus.getAcTemp() + ", " + acStatus.getAcWindSpeed() +
", " + acStatus.getAcWindDir() + ", keyCode = " + keyCode);
}
decoded = irDecodeCombo(category, subCate, binaries, binLength,
keyCode, acStatus, changeWindDir);
}
return decoded;
}
public void closeBinary() {
irClose();
}

View File

@@ -103,6 +103,7 @@ public class DecodeLogic {
public int[] decode(RemoteIndex remoteIndex, ACStatus acStatus,
int keyCode, int changeWindDirection) {
try {
int[] decoded = null;
synchronized (this) {
if (null != remoteIndex) {
@@ -115,14 +116,22 @@ public class DecodeLogic {
decoded = irDecode.decodeBinary(keyCode, acStatus, changeWindDirection);
}
irDecode.closeBinary();
/*
decoded = irDecode.decodeBinary(categoryId, subCate, binaryContent, binaryContent.length,
keyCode, acStatus, changeWindDirection);
*/
return decoded;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
public ACParameters getACParameters(RemoteIndex remoteIndex, int mode) {
if (null != remoteIndex) {
try {
ACParameters acParameters = new ACParameters();
int categoryId = remoteIndex.getCategoryId();
int subCate = remoteIndex.getSubCate();
@@ -177,6 +186,9 @@ public class DecodeLogic {
}
irDecode.closeBinary();
return acParameters;
} catch (Exception ex) {
ex.printStackTrace();
}
}
return null;
}