|
|
@@ -24,6 +24,7 @@ import android.content.Context;
|
|
|
import android.net.ConnectivityManager;
|
|
|
import android.net.NetworkInfo;
|
|
|
import android.os.Build;
|
|
|
+import android.telephony.TelephonyManager;
|
|
|
import android.util.Base64;
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
@@ -43,6 +44,7 @@ import java.security.cert.X509Certificate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Enumeration;
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
import go.psi.Psi;
|
|
|
@@ -224,6 +226,8 @@ public class PsiphonTunnel extends Psi.PsiphonProvider.Stub {
|
|
|
mTunneledApp.onDiagnosticMessage(e.getMessage());
|
|
|
}
|
|
|
|
|
|
+ json.put("DeviceRegion", getDeviceRegion(mTunneledApp.getContext()));
|
|
|
+
|
|
|
return json.toString();
|
|
|
}
|
|
|
|
|
|
@@ -381,4 +385,22 @@ public class PsiphonTunnel extends Psi.PsiphonProvider.Stub {
|
|
|
throw new Exception(errorMessage, e);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private static String getDeviceRegion(Context context) {
|
|
|
+ String region = "";
|
|
|
+ TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
+ if (telephonyManager != null) {
|
|
|
+ region = telephonyManager.getSimCountryIso();
|
|
|
+ if (region.length() == 0 && telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
|
|
|
+ region = telephonyManager.getNetworkCountryIso();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (region.length() == 0) {
|
|
|
+ Locale defaultLocale = Locale.getDefault();
|
|
|
+ if (defaultLocale != null) {
|
|
|
+ region = defaultLocale.getCountry();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return region.toUpperCase();
|
|
|
+ }
|
|
|
}
|