That fuck shit the fascists are using
1package org.tm.archive.util;
2
3import android.Manifest;
4import android.content.Context;
5import android.content.pm.PackageManager;
6import android.content.res.Configuration;
7import android.net.ConnectivityManager;
8import android.telephony.TelephonyManager;
9
10import androidx.annotation.NonNull;
11import androidx.core.content.ContextCompat;
12
13import org.signal.core.util.logging.Log;
14
15import java.util.Locale;
16
17public class TelephonyUtil {
18 private static final String TAG = Log.tag(TelephonyUtil.class);
19
20 public static TelephonyManager getManager(final Context context) {
21 return (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
22 }
23
24 public static String getMccMnc(final Context context) {
25 final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
26 final int configMcc = context.getResources().getConfiguration().mcc;
27 final int configMnc = context.getResources().getConfiguration().mnc;
28 if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) {
29 Log.i(TAG, "Choosing MCC+MNC info from TelephonyManager.getSimOperator()");
30 return tm.getSimOperator();
31 } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
32 Log.i(TAG, "Choosing MCC+MNC info from TelephonyManager.getNetworkOperator()");
33 return tm.getNetworkOperator();
34 } else if (configMcc != 0 && configMnc != 0) {
35 Log.i(TAG, "Choosing MCC+MNC info from current context's Configuration");
36 return String.format(Locale.ROOT, "%03d%d",
37 configMcc,
38 configMnc == Configuration.MNC_ZERO ? 0 : configMnc);
39 } else {
40 return null;
41 }
42 }
43
44 public static String getApn(final Context context) {
45 final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
46 return cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS).getExtraInfo();
47 }
48
49 public static boolean isAnyPstnLineBusy(@NonNull Context context) {
50 try {
51 if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
52 return getManager(context).getCallState() != TelephonyManager.CALL_STATE_IDLE;
53 } else {
54 return false;
55 }
56 } catch (SecurityException e) {
57 Log.w(TAG, "Failed to determine if busy!", e);
58 return false;
59 }
60 }
61}