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

Commit 257f85e4 authored by Naina Nalluri's avatar Naina Nalluri Committed by Android (Google) Code Review
Browse files

Merge "Add switch to enable/disable cbrs"

parents 2b80334b d1b57f62
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -174,6 +174,20 @@
            android:layout_height="1dip"
            android:background="?android:attr/listDivider" />

        <!-- Enable/Disable CBRS data -->
        <Switch android:id="@+id/cbrs_data_switch"
                android:textSize="14sp"
                android:layout_marginTop="8dip"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/cbrs_data_switch_string" />

        <!-- Horizontal Rule -->
        <View
            android:layout_width="fill_parent"
            android:layout_height="1dip"
            android:background="?android:attr/listDivider" />

        <!-- Ping stats -->
        <Button android:id="@+id/ping_test"
                android:textSize="14sp"
+3 −0
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@
    <!-- 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>
    <!-- Cbrs enable disable flag. Only shown in diagnostic screen, so precise translation is not needed -->
    <string name="cbrs_data_switch_string">Cbrs Data</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>
+43 −0
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ public class RadioInfo extends Activity {
    private Switch imsVtProvisionedSwitch;
    private Switch imsWfcProvisionedSwitch;
    private Switch eabProvisionedSwitch;
    private Switch cbrsDataSwitch;
    private Spinner preferredNetworkType;
    private Spinner cellInfoRefreshRateSpinner;

@@ -450,6 +451,9 @@ public class RadioInfo extends Activity {
        imsWfcProvisionedSwitch = (Switch) findViewById(R.id.wfc_provisioned_switch);
        eabProvisionedSwitch = (Switch) findViewById(R.id.eab_provisioned_switch);

        cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
        cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);

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

        mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
@@ -526,6 +530,11 @@ public class RadioInfo extends Activity {
        imsWfcProvisionedSwitch.setOnCheckedChangeListener(mImsWfcCheckedChangeListener);
        eabProvisionedSwitch.setOnCheckedChangeListener(mEabCheckedChangeListener);

        if (isCbrsSupported()) {
            cbrsDataSwitch.setChecked(getCbrsDataState());
            cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
        }

        mTelephonyManager.listen(mPhoneStateListener,
                  PhoneStateListener.LISTEN_CALL_STATE
        //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
@@ -1483,4 +1492,38 @@ public class RadioInfo extends Activity {
        }
    };

    boolean isCbrsSupported() {
        return getResources().getBoolean(
              com.android.internal.R.bool.config_cbrs_supported);
    }

    void updateCbrsDataState(boolean state) {
        Log.d(TAG, "setCbrsDataSwitchState() state:" + ((state)? "on":"off"));
        if (mTelephonyManager != null) {
            QueuedWork.queue(new Runnable() {
                public void run() {
                  mTelephonyManager.setOpportunisticNetworkState(state);
                  cbrsDataSwitch.setChecked(getCbrsDataState());
                }
            }, false);
        }
    }

    boolean getCbrsDataState() {
        boolean state = false;
        if (mTelephonyManager != null) {
            state = mTelephonyManager.isOpportunisticNetworkEnabled();
        }
        Log.d(TAG, "getCbrsDataState() state:" +((state)? "on":"off"));
        return state;
    }

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


}