Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 586741cc authored by Meng Wang's avatar Meng Wang
Browse files

Allow view/update EAB Provisioning status

Bug: 37433707
Test: make
Change-Id: I8cafe72015a9d80c3711b7cf472ae8fadcfd8170
parent 10ad0293
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -206,6 +206,14 @@
                android:layout_height="wrap_content"
                android:text="@string/wfc_provisioned_switch_string"/>

        <!-- EAB/Presence provisioned -->
        <Switch android:id="@+id/eab_provisioned_switch"
                android:textSize="14sp"
                android:layout_marginTop="8dip"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/eab_provisioned_switch_string"/>

        <!-- SMSC -->
        <RelativeLayout android:layout_width="match_parent"
                        android:layout_height="wrap_content">
+3 −0
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@
    <!-- Wifi Calling provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
    <string name="wfc_provisioned_switch_string">Wifi Calling Provisioned</string>
    <!-- EAB provisioning flag on. Only shown in diagnostic screen, so precise translation is not needed. -->
    <string name="eab_provisioned_switch_string">EAB/Presence Provisioned</string>
    <!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
    <string name="radio_info_radio_power">Mobile Radio Power</string>
+60 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.app.QueuedWork;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -32,6 +33,7 @@ import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.telephony.CarrierConfigManager;
import android.telephony.CellInfo;
import android.telephony.CellInfoCdma;
import android.telephony.CellInfoGsm;
@@ -130,6 +132,9 @@ public class RadioInfo extends Activity {
    private static final int IMS_WFC_PROVISIONED_CONFIG_ID =
        ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED;

    private static final int EAB_PROVISIONED_CONFIG_ID =
        ImsConfig.ConfigConstants.EAB_SETTING_ENABLED;

    //Values in must match mCellInfoRefreshRates
    private static final String[] mCellInfoRefreshRateLabels = {
            "Disabled",
@@ -201,6 +206,7 @@ public class RadioInfo extends Activity {
    private Switch imsVolteProvisionedSwitch;
    private Switch imsVtProvisionedSwitch;
    private Switch imsWfcProvisionedSwitch;
    private Switch eabProvisionedSwitch;
    private Spinner preferredNetworkType;
    private Spinner cellInfoRefreshRateSpinner;

@@ -406,6 +412,7 @@ public class RadioInfo extends Activity {
        imsVolteProvisionedSwitch = (Switch) findViewById(R.id.volte_provisioned_switch);
        imsVtProvisionedSwitch = (Switch) findViewById(R.id.vt_provisioned_switch);
        imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
        eabProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);

        radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);

@@ -478,6 +485,7 @@ public class RadioInfo extends Activity {
        imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
        imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
        imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
        eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);

        mTelephonyManager.listen(mPhoneStateListener,
                  PhoneStateListener.LISTEN_CALL_STATE
@@ -1170,6 +1178,11 @@ public class RadioInfo extends Activity {
        setImsConfigProvisionedState(IMS_WFC_PROVISIONED_CONFIG_ID, state);
    }

    void setEabProvisionedState(boolean state) {
        Log.d(TAG, "setEabProvisioned() state: " + ((state)? "on":"off"));
        setImsConfigProvisionedState(EAB_PROVISIONED_CONFIG_ID, state);
    }

    void setImsConfigProvisionedState(int configItem, boolean state) {
        if (phone != null && mImsManager != null) {
            QueuedWork.queue(new Runnable() {
@@ -1239,6 +1252,48 @@ public class RadioInfo extends Activity {
        }
    };

    private boolean isEabProvisioned() {
        return isFeatureProvisioned(EAB_PROVISIONED_CONFIG_ID, false);
    }

    OnCheckedChangeListener mEabCheckedChangeListener = new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setEabProvisionedState(isChecked);
        }
    };

    private boolean isFeatureProvisioned(int featureId, boolean defaultValue) {
        boolean provisioned = defaultValue;
        if (mImsManager != null) {
            try {
                ImsConfig imsConfig = mImsManager.getConfigInterface();
                if (imsConfig != null) {
                    provisioned =
                            (imsConfig.getProvisionedValue(featureId)
                                    == ImsConfig.FeatureValueConstants.ON);
                }
            } catch (ImsException ex) {
                Log.e(TAG, "isFeatureProvisioned() exception:", ex);
            }
        }

        log("isFeatureProvisioned() featureId=" + featureId + " provisioned=" + provisioned);
        return provisioned;
    }

    private static boolean isEabEnabledByPlatform(Context context) {
        if (context != null) {
            CarrierConfigManager configManager = (CarrierConfigManager)
                    context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
            if (configManager != null && configManager.getConfig().getBoolean(
                        CarrierConfigManager.KEY_USE_RCS_PRESENCE_BOOL)) {
                return true;
            }
        }
        return false;
    }

    private void updateImsProvisionedState() {
        log("updateImsProvisionedState isImsVolteProvisioned()=" + isImsVolteProvisioned());
        //delightful hack to prevent on-checked-changed calls from
@@ -1260,6 +1315,11 @@ public class RadioInfo extends Activity {
        imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
        imsWfcProvisionedSwitch.setEnabled(
            mImsManager.isWfcEnabledByPlatform(phone.getContext()));

        eabProvisionedSwitch.setOnCheckedChangeListener(null);
        eabProvisionedSwitch.setChecked(isEabProvisioned());
        eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);
        eabProvisionedSwitch.setEnabled(isEabEnabledByPlatform(phone.getContext()));
    }

    OnClickListener mDnsCheckButtonHandler = new OnClickListener() {