翰林优商.apk(点击下载) / AndroidTelephonyManagerBridge.java


package aegon.chrome.net;

import aegon.chrome.base.ContextUtils;
import aegon.chrome.base.ThreadUtils;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import javax.annotation.CheckForNull;

public class AndroidTelephonyManagerBridge {
    private static volatile AndroidTelephonyManagerBridge sInstance;
    private Listener mListener;
    @CheckForNull
    private volatile String mNetworkCountryIso;
    @CheckForNull
    private volatile String mNetworkOperator;
    @CheckForNull
    private volatile String mSimOperator;

    /* access modifiers changed from: package-private */
    public class Listener extends PhoneStateListener {
        @CheckForNull
        private ServiceState mServiceState;

        private Listener() {
        }

        public void onServiceStateChanged(ServiceState serviceState) {
            ServiceState serviceState2 = this.mServiceState;
            if (serviceState2 == null || !serviceState2.equals(serviceState)) {
                this.mServiceState = serviceState;
                AndroidTelephonyManagerBridge.this.update(AndroidTelephonyManagerBridge.getTelephonyManager());
            }
        }
    }

    private AndroidTelephonyManagerBridge() {
    }

    private static AndroidTelephonyManagerBridge create() {
        AndroidTelephonyManagerBridge androidTelephonyManagerBridge = new AndroidTelephonyManagerBridge();
        ThreadUtils.runOnUiThread(AndroidTelephonyManagerBridge$$Lambda$1.lambdaFactory$(androidTelephonyManagerBridge));
        return androidTelephonyManagerBridge;
    }

    public static AndroidTelephonyManagerBridge getInstance() {
        AndroidTelephonyManagerBridge androidTelephonyManagerBridge = sInstance;
        if (androidTelephonyManagerBridge == null) {
            synchronized (AndroidTelephonyManagerBridge.class) {
                androidTelephonyManagerBridge = sInstance;
                if (androidTelephonyManagerBridge == null) {
                    androidTelephonyManagerBridge = create();
                    sInstance = androidTelephonyManagerBridge;
                }
            }
        }
        return androidTelephonyManagerBridge;
    }

    /* access modifiers changed from: private */
    @CheckForNull
    public static TelephonyManager getTelephonyManager() {
        return (TelephonyManager) ContextUtils.getApplicationContext().getSystemService("phone");
    }

    static /* synthetic */ void lambda$create$0(AndroidTelephonyManagerBridge androidTelephonyManagerBridge) {
        TelephonyManager telephonyManager = getTelephonyManager();
        if (telephonyManager != null) {
            androidTelephonyManagerBridge.listenTelephonyServiceState(telephonyManager);
        }
    }

    private void listenTelephonyServiceState(TelephonyManager telephonyManager) {
        ThreadUtils.assertOnUiThread();
        Listener listener = new Listener();
        this.mListener = listener;
        telephonyManager.listen(listener, 1);
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void update(@CheckForNull TelephonyManager telephonyManager) {
        if (telephonyManager != null) {
            this.mNetworkCountryIso = telephonyManager.getNetworkCountryIso();
            this.mNetworkOperator = telephonyManager.getNetworkOperator();
            this.mSimOperator = telephonyManager.getSimOperator();
        }
    }

    public String getNetworkCountryIso() {
        if (this.mNetworkCountryIso == null) {
            TelephonyManager telephonyManager = getTelephonyManager();
            if (telephonyManager == null) {
                return "";
            }
            this.mNetworkCountryIso = telephonyManager.getNetworkCountryIso();
        }
        return this.mNetworkCountryIso;
    }

    public String getNetworkOperator() {
        if (this.mNetworkOperator == null) {
            TelephonyManager telephonyManager = getTelephonyManager();
            if (telephonyManager == null) {
                return "";
            }
            this.mNetworkOperator = telephonyManager.getNetworkOperator();
        }
        return this.mNetworkOperator;
    }

    public String getSimOperator() {
        if (this.mSimOperator == null) {
            TelephonyManager telephonyManager = getTelephonyManager();
            if (telephonyManager == null) {
                return "";
            }
            this.mSimOperator = telephonyManager.getSimOperator();
        }
        return this.mSimOperator;
    }
}