Add switch to enable/disable cbrs

Add switch to enable or disable cbrs
based on whether it is supported or not

Bug: 121291721
Test: Tested enable/disable of the setting on device

Change-Id: Ia79b177966412b2128a6d9cab3549d704253d7b5
This commit is contained in:
Naina Nalluri
2019-01-08 15:19:58 -08:00
parent 8b9529e533
commit d1b57f62d8
3 changed files with 60 additions and 0 deletions

View File

@@ -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"

View File

@@ -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>

View File

@@ -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);
}
};
}