Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/main/java/dev/altavision/pnrgatewayclient/PDUReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import androidx.preference.PreferenceManager;

import java.nio.charset.StandardCharsets;

public class PDUReceiver extends BroadcastReceiver {
private SharedPreferences mPrefs = null;

Expand Down Expand Up @@ -48,6 +50,14 @@ public void onReceive(Context context, Intent intent) {
// REG-RESP?v=3;r=72325403;n=+11234567890;s=CA21C50C645469B25F4B65C38A7DCEC56592E038F39489F35C7CD6972D
String messageBody = recMsg.getMessageBody();

//On some carriers, the PDU received is not readable by the default Android functions.
//This results in the message body being null despite receiving the data
if (messageBody == null) {
messageBody = new String((byte[]) pdus[i], StandardCharsets.US_ASCII);
int startIndex = messageBody.indexOf("REG-RESP");
messageBody = messageBody.substring(startIndex);
}

//Hands the REG-RESP message off to the SMSReceiver to notify the user
SMSReceiver.processResponseMessage(messageBody, context);

Expand Down