Add enable/disable DSDS setting switch
This add a switch settings in the Phone Information screen to allow the user enable/disable the DSDS mode. Bug: 123088078 Test: build & manual test Change-Id: Ia3722fb26ce8825820ee96550a1d523da35c7a71
This commit is contained in:
@@ -182,6 +182,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cbrs_data_switch_string" />
|
||||
|
||||
<!-- Switch between SSSS(single sim single standby) and DSDS(dual sim dual standby). -->
|
||||
<Switch android:id="@+id/dsds_switch"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginTop="8dip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dsds_switch_string" />
|
||||
|
||||
<!-- Horizontal Rule -->
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
|
@@ -66,6 +66,21 @@
|
||||
<!-- Cbrs enable disable flag. Only shown in diagnostic screen, so precise translation is not needed -->
|
||||
<string name="cbrs_data_switch_string">Cbrs Data</string>
|
||||
|
||||
<!-- Dsds enable/disable flag. Only shown in diagnostic screen, so precise translation is not needed, [CHAR LIMIT=none] -->
|
||||
<string name="dsds_switch_string">Enable DSDS</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_title">Restart Device?</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_message">You need to restart your device to change this setting.</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_confirm">Restart</string>
|
||||
|
||||
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
|
||||
<string name="dsds_dialog_cancel">Cancel</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>
|
||||
|
||||
|
@@ -23,6 +23,7 @@ import android.app.Activity;
|
||||
import android.app.QueuedWork;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -40,6 +41,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Telephony;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.CellIdentityCdma;
|
||||
import android.telephony.CellIdentityGsm;
|
||||
@@ -81,11 +83,13 @@ import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AlertDialog.Builder;
|
||||
|
||||
import com.android.ims.ImsConfig;
|
||||
import com.android.ims.ImsException;
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.internal.telephony.Phone;
|
||||
import com.android.internal.telephony.PhoneConfigurationManager;
|
||||
import com.android.internal.telephony.PhoneFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -93,6 +97,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
// TODO(b/123598192) consider to move this activity to telephony package.
|
||||
public class RadioInfo extends Activity {
|
||||
private static final String TAG = "RadioInfo";
|
||||
|
||||
@@ -214,6 +219,7 @@ public class RadioInfo extends Activity {
|
||||
private Switch imsWfcProvisionedSwitch;
|
||||
private Switch eabProvisionedSwitch;
|
||||
private Switch cbrsDataSwitch;
|
||||
private Switch dsdsSwitch;
|
||||
private Spinner preferredNetworkType;
|
||||
private Spinner cellInfoRefreshRateSpinner;
|
||||
|
||||
@@ -454,6 +460,23 @@ public class RadioInfo extends Activity {
|
||||
cbrsDataSwitch = (Switch) findViewById(R.id.cbrs_data_switch);
|
||||
cbrsDataSwitch.setVisibility(isCbrsSupported() ? View.VISIBLE : View.GONE);
|
||||
|
||||
dsdsSwitch = findViewById(R.id.dsds_switch);
|
||||
if (isDsdsSupported()) {
|
||||
dsdsSwitch.setVisibility(View.VISIBLE);
|
||||
dsdsSwitch.setOnClickListener(v -> {
|
||||
if (mTelephonyManager.isRebootRequiredForModemConfigChange()) {
|
||||
// Undo the click action until user clicks the confirm dialog.
|
||||
dsdsSwitch.toggle();
|
||||
showDsdsChangeDialog();
|
||||
} else {
|
||||
performDsdsSwitch();
|
||||
}
|
||||
});
|
||||
dsdsSwitch.setChecked(isDsdsEnabled());
|
||||
} else {
|
||||
dsdsSwitch.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
radioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
|
||||
|
||||
mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
|
||||
@@ -1525,5 +1548,38 @@ public class RadioInfo extends Activity {
|
||||
}
|
||||
};
|
||||
|
||||
private void showDsdsChangeDialog() {
|
||||
final AlertDialog confirmDialog = new Builder(RadioInfo.this)
|
||||
.setTitle(R.string.dsds_dialog_title)
|
||||
.setMessage(R.string.dsds_dialog_message)
|
||||
.setPositiveButton(R.string.dsds_dialog_confirm, mOnDsdsDialogConfirmedListener)
|
||||
.setNegativeButton(R.string.dsds_dialog_cancel, mOnDsdsDialogConfirmedListener)
|
||||
.create();
|
||||
confirmDialog.show();
|
||||
}
|
||||
|
||||
private static boolean isDsdsSupported() {
|
||||
return PhoneConfigurationManager.getInstance().getStaticPhoneCapability()
|
||||
.logicalModemList.size() >= 2
|
||||
&& !TelephonyManager.getDefault().isMultisimCarrierRestricted();
|
||||
}
|
||||
|
||||
private static boolean isDsdsEnabled() {
|
||||
return TelephonyManager.getDefault().getPhoneCount() > 1;
|
||||
}
|
||||
|
||||
private void performDsdsSwitch() {
|
||||
mTelephonyManager.switchMultiSimConfig(dsdsSwitch.isChecked() ? 2 : 1);
|
||||
}
|
||||
|
||||
DialogInterface.OnClickListener mOnDsdsDialogConfirmedListener =
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
dsdsSwitch.toggle();
|
||||
performDsdsSwitch();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user