Fix NXDN transmit issue and android USB device buffer overflow crash bug

pull/2/head
Doug McLain 3 years ago
parent f8585ccc04
commit 8afe4f4a1f

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<manifest package="org.dudetronics.droidstar" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="57" android:installLocation="auto"> <manifest package="org.dudetronics.droidstar" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="57" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. --> Remove the comment if you do not require these default permissions. -->

@ -64,6 +64,7 @@ int AndroidSerialPort::write(char *data, int s)
jbyteArray buffer = env->NewByteArray(s); jbyteArray buffer = env->NewByteArray(s);
env->SetByteArrayRegion(buffer, 0, s, (jbyte *)data); env->SetByteArrayRegion(buffer, 0, s, (jbyte *)data);
serialJavaObject.callMethod<void>("write", "([B)V", buffer); serialJavaObject.callMethod<void>("write", "([B)V", buffer);
env->DeleteLocalRef(buffer);
return 0; return 0;
} }
@ -73,6 +74,7 @@ int AndroidSerialPort::write(QByteArray data)
jbyteArray buffer = env->NewByteArray(data.size()); jbyteArray buffer = env->NewByteArray(data.size());
env->SetByteArrayRegion(buffer, 0, data.size(), (jbyte *)data.data()); env->SetByteArrayRegion(buffer, 0, data.size(), (jbyte *)data.data());
serialJavaObject.callMethod<void>("write", "([B)V", buffer); serialJavaObject.callMethod<void>("write", "([B)V", buffer);
env->DeleteLocalRef(buffer);
return 0; return 0;
} }

@ -282,7 +282,6 @@ void NXDNCodec::send_disconnect()
void NXDNCodec::transmit() void NXDNCodec::transmit()
{ {
uint8_t ambe_frame[49];
uint8_t ambe[7]; uint8_t ambe[7];
int16_t pcm[160]; int16_t pcm[160];
@ -314,13 +313,11 @@ void NXDNCodec::transmit()
} }
else{ else{
if(m_modeinfo.sw_vocoder_loaded){ if(m_modeinfo.sw_vocoder_loaded){
m_mbevocoder->encode_2450(pcm, ambe_frame); m_mbevocoder->encode_2450(pcm, ambe);
}
for(int i = 0; i < 7; ++i){
for(int j = 0; j < 8; ++j){
ambe[i] |= (ambe_frame[(i*8)+j] << (7-j));
} }
ambe[6] &= 0x80; ambe[6] &= 0x80;
for(int i = 0; i < 7; ++i){
m_txcodecq.append(ambe[i]); m_txcodecq.append(ambe[i]);
} }
} }

Loading…
Cancel
Save