This commit is contained in:
Moxie Marlinspike
2014-01-14 00:26:43 -08:00
parent 4851a555e7
commit 49daa45dca
19 changed files with 1674 additions and 244 deletions

View File

@@ -2,6 +2,7 @@ package org.whispersystems.textsecure.util;
import android.app.AlertDialog;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.widget.EditText;
import java.io.ByteArrayOutputStream;
@@ -169,6 +170,22 @@ public class Util {
return results;
}
public static String getDeviceE164Number(Context context) {
String localNumber = ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE))
.getLine1Number();
if (!org.whispersystems.textsecure.util.Util.isEmpty(localNumber) &&
!localNumber.startsWith("+"))
{
if (localNumber.length() == 10) localNumber = "+1" + localNumber;
else localNumber = "+" + localNumber;
return localNumber;
}
return null;
}
public static SecureRandom getSecureRandom() {
try {
return SecureRandom.getInstance("SHA1PRNG");