mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Work around SmsMessage.calculateLength NPE on broken ROMs
//FREEBIE
This commit is contained in:
parent
37a5622525
commit
66062f200a
@ -17,16 +17,30 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.telephony.SmsMessage;
|
||||
import android.util.Log;
|
||||
|
||||
public class SmsCharacterCalculator extends CharacterCalculator {
|
||||
|
||||
private static final String TAG = SmsCharacterCalculator.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
public CharacterState calculateCharacters(String messageBody) {
|
||||
int[] length;
|
||||
int messagesSpent;
|
||||
int charactersSpent;
|
||||
int charactersRemaining;
|
||||
|
||||
int[] length = SmsMessage.calculateLength(messageBody, false);
|
||||
int messagesSpent = length[0];
|
||||
int charactersSpent = length[1];
|
||||
int charactersRemaining = length[2];
|
||||
try {
|
||||
length = SmsMessage.calculateLength(messageBody, false);
|
||||
messagesSpent = length[0];
|
||||
charactersSpent = length[1];
|
||||
charactersRemaining = length[2];
|
||||
} catch (NullPointerException e) {
|
||||
Log.w(TAG, e);
|
||||
messagesSpent = 1;
|
||||
charactersSpent = messageBody.length();
|
||||
charactersRemaining = 1000;
|
||||
}
|
||||
|
||||
int maxMessageSize;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user