use decode_combo in order to fix some memory issue
This commit is contained in:
@@ -3,6 +3,7 @@ package net.irext.decode.sdk;
|
|||||||
import net.irext.decode.sdk.bean.ACStatus;
|
import net.irext.decode.sdk.bean.ACStatus;
|
||||||
import net.irext.decode.sdk.bean.TemperatureRange;
|
import net.irext.decode.sdk.bean.TemperatureRange;
|
||||||
import net.irext.decode.sdk.utils.Constants;
|
import net.irext.decode.sdk.utils.Constants;
|
||||||
|
import net.irext.decode.service.utils.LoggerUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
@@ -34,6 +35,9 @@ public class IRDecode {
|
|||||||
|
|
||||||
private native void irClose();
|
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 TemperatureRange irACGetTemperatureRange(int acMode);
|
||||||
|
|
||||||
private native int irACGetSupportedMode();
|
private native int irACGetSupportedMode();
|
||||||
@@ -71,13 +75,38 @@ public class IRDecode {
|
|||||||
int[] decoded;
|
int[] decoded;
|
||||||
synchronized (mSync) {
|
synchronized (mSync) {
|
||||||
if (null == acStatus) {
|
if (null == acStatus) {
|
||||||
|
LoggerUtil.getInstance().trace(TAG, "AC Status is null, create a default one");
|
||||||
acStatus = new ACStatus();
|
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);
|
decoded = irDecode(keyCode, acStatus, changeWindDir);
|
||||||
}
|
}
|
||||||
return decoded;
|
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() {
|
public void closeBinary() {
|
||||||
irClose();
|
irClose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,80 +103,92 @@ public class DecodeLogic {
|
|||||||
|
|
||||||
public int[] decode(RemoteIndex remoteIndex, ACStatus acStatus,
|
public int[] decode(RemoteIndex remoteIndex, ACStatus acStatus,
|
||||||
int keyCode, int changeWindDirection) {
|
int keyCode, int changeWindDirection) {
|
||||||
int[] decoded = null;
|
try {
|
||||||
synchronized(this) {
|
int[] decoded = null;
|
||||||
if (null != remoteIndex) {
|
synchronized (this) {
|
||||||
int categoryId = remoteIndex.getCategoryId();
|
if (null != remoteIndex) {
|
||||||
int subCate = remoteIndex.getSubCate();
|
int categoryId = remoteIndex.getCategoryId();
|
||||||
byte[] binaryContent = remoteIndex.getBinaries();
|
int subCate = remoteIndex.getSubCate();
|
||||||
IRDecode irDecode = IRDecode.getInstance();
|
byte[] binaryContent = remoteIndex.getBinaries();
|
||||||
int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length);
|
IRDecode irDecode = IRDecode.getInstance();
|
||||||
if (0 == ret) {
|
int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length);
|
||||||
decoded = irDecode.decodeBinary(keyCode, acStatus, changeWindDirection);
|
if (0 == ret) {
|
||||||
|
decoded = irDecode.decodeBinary(keyCode, acStatus, changeWindDirection);
|
||||||
|
}
|
||||||
|
irDecode.closeBinary();
|
||||||
|
/*
|
||||||
|
decoded = irDecode.decodeBinary(categoryId, subCate, binaryContent, binaryContent.length,
|
||||||
|
keyCode, acStatus, changeWindDirection);
|
||||||
|
*/
|
||||||
|
return decoded;
|
||||||
}
|
}
|
||||||
irDecode.closeBinary();
|
|
||||||
return decoded;
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ACParameters getACParameters(RemoteIndex remoteIndex, int mode) {
|
public ACParameters getACParameters(RemoteIndex remoteIndex, int mode) {
|
||||||
if (null != remoteIndex) {
|
if (null != remoteIndex) {
|
||||||
ACParameters acParameters = new ACParameters();
|
try {
|
||||||
int categoryId = remoteIndex.getCategoryId();
|
ACParameters acParameters = new ACParameters();
|
||||||
int subCate = remoteIndex.getSubCate();
|
int categoryId = remoteIndex.getCategoryId();
|
||||||
byte[] binaryContent = remoteIndex.getBinaries();
|
int subCate = remoteIndex.getSubCate();
|
||||||
IRDecode irDecode = IRDecode.getInstance();
|
byte[] binaryContent = remoteIndex.getBinaries();
|
||||||
int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length);
|
IRDecode irDecode = IRDecode.getInstance();
|
||||||
if (0 == ret) {
|
int ret = irDecode.openBinary(categoryId, subCate, binaryContent, binaryContent.length);
|
||||||
int []supportedModes = irDecode.getACSupportedMode();
|
if (0 == ret) {
|
||||||
|
int[] supportedModes = irDecode.getACSupportedMode();
|
||||||
if (DEBUG) {
|
|
||||||
LoggerUtil.getInstance().trace(TAG, "supported modes got : ");
|
|
||||||
for (int i = 0; i < supportedModes.length; i++) {
|
|
||||||
LoggerUtil.getInstance().trace(TAG, "supported mode [" + i + "] = " + supportedModes[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
acParameters.setSupportedModes(supportedModes);
|
|
||||||
if (1 == supportedModes[mode]) {
|
|
||||||
// if this mode is really supported by this AC, get other parameters
|
|
||||||
TemperatureRange temperatureRange = irDecode.getTemperatureRange(mode);
|
|
||||||
int[] supportedWindSpeed = irDecode.getACSupportedWindSpeed(mode);
|
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
LoggerUtil.getInstance().trace(TAG, "supported wind speed got for mode : " + mode);
|
LoggerUtil.getInstance().trace(TAG, "supported modes got : ");
|
||||||
for (int i = 0; i < supportedWindSpeed.length; i++) {
|
for (int i = 0; i < supportedModes.length; i++) {
|
||||||
LoggerUtil.getInstance().trace(TAG, "supported wind speed [" + i + "] = " + supportedWindSpeed[i]);
|
LoggerUtil.getInstance().trace(TAG, "supported mode [" + i + "] = " + supportedModes[i]);
|
||||||
}
|
|
||||||
}
|
|
||||||
int[] supportedSwing = irDecode.getACSupportedSwing(mode);
|
|
||||||
|
|
||||||
if (DEBUG) {
|
|
||||||
LoggerUtil.getInstance().trace(TAG, "supported swing got for mode : " + mode);
|
|
||||||
for (int i = 0; i < supportedSwing.length; i++) {
|
|
||||||
LoggerUtil.getInstance().trace(TAG, "supported swing [" + i + "] = " + supportedSwing[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int supportedWindDirection = irDecode.getACSupportedWindDirection(mode);
|
acParameters.setSupportedModes(supportedModes);
|
||||||
|
if (1 == supportedModes[mode]) {
|
||||||
|
// if this mode is really supported by this AC, get other parameters
|
||||||
|
TemperatureRange temperatureRange = irDecode.getTemperatureRange(mode);
|
||||||
|
int[] supportedWindSpeed = irDecode.getACSupportedWindSpeed(mode);
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
LoggerUtil.getInstance().trace(TAG,
|
LoggerUtil.getInstance().trace(TAG, "supported wind speed got for mode : " + mode);
|
||||||
"supported wind directions for mode : " + mode +
|
for (int i = 0; i < supportedWindSpeed.length; i++) {
|
||||||
" = " + supportedWindDirection);
|
LoggerUtil.getInstance().trace(TAG, "supported wind speed [" + i + "] = " + supportedWindSpeed[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int[] supportedSwing = irDecode.getACSupportedSwing(mode);
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
LoggerUtil.getInstance().trace(TAG, "supported swing got for mode : " + mode);
|
||||||
|
for (int i = 0; i < supportedSwing.length; i++) {
|
||||||
|
LoggerUtil.getInstance().trace(TAG, "supported swing [" + i + "] = " + supportedSwing[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int supportedWindDirection = irDecode.getACSupportedWindDirection(mode);
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
LoggerUtil.getInstance().trace(TAG,
|
||||||
|
"supported wind directions for mode : " + mode +
|
||||||
|
" = " + supportedWindDirection);
|
||||||
|
}
|
||||||
|
|
||||||
|
acParameters.setTempMax(temperatureRange.getTempMax());
|
||||||
|
acParameters.setTempMin(temperatureRange.getTempMin());
|
||||||
|
acParameters.setSupportedWindSpeed(supportedWindSpeed);
|
||||||
|
acParameters.setSupportedSwing(supportedSwing);
|
||||||
|
acParameters.setSupportedWindSpeed(supportedWindSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
acParameters.setTempMax(temperatureRange.getTempMax());
|
|
||||||
acParameters.setTempMin(temperatureRange.getTempMin());
|
|
||||||
acParameters.setSupportedWindSpeed(supportedWindSpeed);
|
|
||||||
acParameters.setSupportedSwing(supportedSwing);
|
|
||||||
acParameters.setSupportedWindSpeed(supportedWindSpeed);
|
|
||||||
}
|
}
|
||||||
|
irDecode.closeBinary();
|
||||||
|
return acParameters;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
irDecode.closeBinary();
|
|
||||||
return acParameters;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user