Merge "Don't allow CBRS subscriptions to be set as default for Calls/SMS" into qt-dev
am: 6010c3a9a8
Change-Id: I1b51f0ac7d0bad02552d0f918d01da1b653550b9
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index fc8cc26..5c918fc 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -25,6 +25,19 @@
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true">
+ <!-- Phone index -->
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/phone_index_label"
+ style="@style/info_label"
+ />
+
+ <Spinner android:id="@+id/phoneIndex"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ />
+
<!-- IMEI -->
<LinearLayout style="@style/entry_layout">
<TextView android:text="@string/radio_info_imei_label" style="@style/info_label" />
@@ -37,6 +50,18 @@
<TextView android:id="@+id/number" style="@style/info_value" />
</LinearLayout>
+ <!-- Subscription ID -->
+ <LinearLayout style="@style/entry_layout">
+ <TextView android:text="@string/radio_info_subid" style="@style/info_label" />
+ <TextView android:id="@+id/subid" style="@style/info_value" />
+ </LinearLayout>
+
+ <!-- Default data subscription -->
+ <LinearLayout style="@style/entry_layout">
+ <TextView android:text="@string/radio_info_dds" style="@style/info_label" />
+ <TextView android:id="@+id/dds" style="@style/info_value" />
+ </LinearLayout>
+
<!-- IMSI -->
<LinearLayout style="@style/entry_layout">
<TextView android:text="@string/radio_info_imsi_label" style="@style/info_label" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4e1b32e..b9d2d28 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -485,6 +485,10 @@
<string name="proxy_url_title">"PAC URL: "</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
+ <string name="radio_info_subid">Current subId:</string>
+ <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
+ <string name="radio_info_dds">SubId of default data SIM:</string>
+ <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_dl_kbps">DL Bandwidth (kbps):</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_ul_kbps">UL Bandwidth (kbps):</string>
@@ -531,6 +535,8 @@
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_data_network_type_label">Data Network Type:</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
+ <string name="phone_index_label">Select phone index</string>
+ <!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_set_perferred_label">Set Preferred Network Type:</string>
<!-- Radio Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="radio_info_ping_hostname_v4">Ping Hostname(www.google.com) IPv4:</string>
diff --git a/src/com/android/settings/RadioInfo.java b/src/com/android/settings/RadioInfo.java
index 0b7d1be..9a06c3e 100644
--- a/src/com/android/settings/RadioInfo.java
+++ b/src/com/android/settings/RadioInfo.java
@@ -125,6 +125,7 @@
"Unknown"
};
+ private static String[] mPhoneIndexLabels;
private static final int CELL_INFO_LIST_RATE_DISABLED = Integer.MAX_VALUE;
private static final int CELL_INFO_LIST_RATE_MAX = 0;
@@ -160,7 +161,7 @@
60000
};
- private void log(String s) {
+ private static void log(String s) {
Log.d(TAG, s);
}
@@ -171,15 +172,17 @@
private static final int EVENT_QUERY_SMSC_DONE = 1005;
private static final int EVENT_UPDATE_SMSC_DONE = 1006;
- private static final int MENU_ITEM_SELECT_BAND = 0;
- private static final int MENU_ITEM_VIEW_ADN = 1;
- private static final int MENU_ITEM_VIEW_FDN = 2;
- private static final int MENU_ITEM_VIEW_SDN = 3;
- private static final int MENU_ITEM_GET_IMS_STATUS = 4;
- private static final int MENU_ITEM_TOGGLE_DATA = 5;
+ private static final int MENU_ITEM_SELECT_BAND = 0;
+ private static final int MENU_ITEM_VIEW_ADN = 1;
+ private static final int MENU_ITEM_VIEW_FDN = 2;
+ private static final int MENU_ITEM_VIEW_SDN = 3;
+ private static final int MENU_ITEM_GET_IMS_STATUS = 4;
+ private static final int MENU_ITEM_TOGGLE_DATA = 5;
private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
private TextView number;
+ private TextView mSubscriptionId;
+ private TextView mDds;
private TextView mSubscriberId;
private TextView callState;
private TextView operatorName;
@@ -219,6 +222,7 @@
private Switch cbrsDataSwitch;
private Switch dsdsSwitch;
private Spinner preferredNetworkType;
+ private Spinner mSelectPhoneIndex;
private Spinner cellInfoRefreshRateSpinner;
private ConnectivityManager mConnectivityManager;
@@ -237,6 +241,7 @@
private int mPreferredNetworkTypeResult;
private int mCellInfoRefreshRateIndex;
+ private int mSelectedPhoneIndex;
private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
@@ -346,6 +351,21 @@
preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
}
+ private void updatePhoneIndex(int phoneIndex, int subId) {
+ // unregister listeners on the old subId
+ mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
+ mTelephonyManager.setCellInfoListRate(CELL_INFO_LIST_RATE_DISABLED);
+
+ // update the subId
+ mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId);
+ mImsManager = ImsManager.getInstance(getApplicationContext(), phoneIndex);
+
+ // update the phoneId
+ phone = PhoneFactory.getPhone(phoneIndex);
+
+ updateAllFields();
+ }
+
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -406,13 +426,15 @@
mConnectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
phone = PhoneFactory.getDefaultPhone();
- //TODO: Need to update this if the default phoneId changes?
- // Better to have an instance per phone?
mImsManager = ImsManager.getInstance(getApplicationContext(),
SubscriptionManager.getDefaultVoicePhoneId());
+ mPhoneIndexLabels = getPhoneIndexLabels(mTelephonyManager);
+
mDeviceId = (TextView) findViewById(R.id.imei);
number = (TextView) findViewById(R.id.number);
+ mSubscriptionId = (TextView) findViewById(R.id.subid);
+ mDds = (TextView) findViewById(R.id.dds);
mSubscriberId = (TextView) findViewById(R.id.imsi);
callState = (TextView) findViewById(R.id.call);
operatorName = (TextView) findViewById(R.id.operator);
@@ -439,10 +461,17 @@
mPhyChanConfig = (TextView) findViewById(R.id.phy_chan_config);
preferredNetworkType = (Spinner) findViewById(R.id.preferredNetworkType);
- ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
+ ArrayAdapter<String> preferredNetworkTypeAdapter = new ArrayAdapter<String> (this,
android.R.layout.simple_spinner_item, mPreferredNetworkLabels);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- preferredNetworkType.setAdapter(adapter);
+ preferredNetworkTypeAdapter
+ .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ preferredNetworkType.setAdapter(preferredNetworkTypeAdapter);
+
+ mSelectPhoneIndex = (Spinner) findViewById(R.id.phoneIndex);
+ ArrayAdapter<String> phoneIndexAdapter = new ArrayAdapter<String> (this,
+ android.R.layout.simple_spinner_item, mPhoneIndexLabels);
+ phoneIndexAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ mSelectPhoneIndex.setAdapter(phoneIndexAdapter);
cellInfoRefreshRateSpinner = (Spinner) findViewById(R.id.cell_info_rate_select);
ArrayAdapter<String> cellInfoAdapter = new ArrayAdapter<String>(this,
@@ -513,6 +542,7 @@
mCellInfoRefreshRateIndex = 0; //disabled
mPreferredNetworkTypeResult = mPreferredNetworkLabels.length - 1; //Unknown
+ mSelectedPhoneIndex = 0; //phone 0
//FIXME: Replace with TelephonyManager call
phone.getPreferredNetworkType(
@@ -527,6 +557,10 @@
log("Started onResume");
+ updateAllFields();
+ }
+
+ private void updateAllFields() {
updateMessageWaiting();
updateCallRedirect();
updateDataState();
@@ -539,6 +573,7 @@
updateLocation(mCellLocationResult);
updateCellInfo(mCellInfoResult);
+ updateSubscriptionIds();
mPingHostnameV4.setText(mPingHostnameResultV4);
mPingHostnameV6.setText(mPingHostnameResultV6);
@@ -552,6 +587,10 @@
preferredNetworkType.setSelection(mPreferredNetworkTypeResult, true);
preferredNetworkType.setOnItemSelectedListener(mPreferredNetworkHandler);
+ // set phone index
+ mSelectPhoneIndex.setSelection(mSelectedPhoneIndex, true);
+ mSelectPhoneIndex.setOnItemSelectedListener(mSelectPhoneIndexHandler);
+
radioPowerOnSwitch.setOnCheckedChangeListener(mRadioPowerOnChangeListener);
imsVolteProvisionedSwitch.setOnCheckedChangeListener(mImsVolteCheckedChangeListener);
imsVtProvisionedSwitch.setOnCheckedChangeListener(mImsVtCheckedChangeListener);
@@ -563,19 +602,7 @@
cbrsDataSwitch.setOnCheckedChangeListener(mCbrsDataSwitchChangeListener);
}
- mTelephonyManager.listen(mPhoneStateListener,
- PhoneStateListener.LISTEN_CALL_STATE
- //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
- // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
- | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
- | PhoneStateListener.LISTEN_DATA_ACTIVITY
- | PhoneStateListener.LISTEN_CELL_LOCATION
- | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
- | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
- | PhoneStateListener.LISTEN_CELL_INFO
- | PhoneStateListener.LISTEN_SERVICE_STATE
- | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
- | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
+ registerPhoneStateListener();
mConnectivityManager.registerNetworkCallback(
mDefaultNetworkRequest, mNetworkCallback, mHandler);
@@ -611,6 +638,8 @@
mPreferredNetworkTypeResult = b.getInt("mPreferredNetworkTypeResult",
mPreferredNetworkLabels.length - 1);
+ mSelectedPhoneIndex = b.getInt("mSelectedPhoneIndex", 0);
+
mCellInfoRefreshRateIndex = b.getInt("mCellInfoRefreshRateIndex", 0);
}
@@ -621,6 +650,7 @@
outState.putString("mHttpClientTestResult", mHttpClientTestResult);
outState.putInt("mPreferredNetworkTypeResult", mPreferredNetworkTypeResult);
+ outState.putInt("mSelectedPhoneIndex", mSelectedPhoneIndex);
outState.putInt("mCellInfoRefreshRateIndex", mCellInfoRefreshRateIndex);
}
@@ -668,6 +698,34 @@
return true;
}
+ // returns array of string labels for each phone index. The array index is equal to the phone
+ // index.
+ private static String[] getPhoneIndexLabels(TelephonyManager tm) {
+ int phones = tm.getPhoneCount();
+ String[] labels = new String[phones];
+ for (int i = 0; i < phones; i++) {
+ labels[i] = "Phone " + i;
+ }
+ return labels;
+ }
+
+ // register mPhoneStateListener for relevant fields using the current TelephonyManager
+ private void registerPhoneStateListener() {
+ mTelephonyManager.listen(mPhoneStateListener,
+ PhoneStateListener.LISTEN_CALL_STATE
+ //b/27803938 - RadioInfo currently cannot read PRECISE_CALL_STATE
+ // | PhoneStateListener.LISTEN_PRECISE_CALL_STATE
+ | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
+ | PhoneStateListener.LISTEN_DATA_ACTIVITY
+ | PhoneStateListener.LISTEN_CELL_LOCATION
+ | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
+ | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
+ | PhoneStateListener.LISTEN_CELL_INFO
+ | PhoneStateListener.LISTEN_SERVICE_STATE
+ | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
+ | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION);
+ }
+
private void updateDnsCheckState() {
//FIXME: Replace with a TelephonyManager call
dnsCheckState.setText(phone.isDnsCheckDisabled() ?
@@ -889,6 +947,11 @@
mCellInfo.setText(buildCellInfoString(arrayCi));
}
+ private final void updateSubscriptionIds() {
+ mSubscriptionId.setText(Integer.toString(phone.getSubId()));
+ mDds.setText(Integer.toString(SubscriptionManager.getDefaultDataSubscriptionId()));
+ }
+
private final void
updateMessageWaiting() {
mMwi.setText(String.valueOf(mMwiValue));
@@ -1512,6 +1575,35 @@
}
};
+ AdapterView.OnItemSelectedListener mSelectPhoneIndexHandler =
+ new AdapterView.OnItemSelectedListener() {
+
+ public void onItemSelected(AdapterView parent, View v, int pos, long id) {
+ if (pos >= 0 && pos <= mPhoneIndexLabels.length - 1) {
+ // the array position is equal to the phone index
+ int phoneIndex = pos;
+ Phone[] phones = PhoneFactory.getPhones();
+ if (phones == null || phones.length <= phoneIndex) {
+ log("phoneIndex " + phoneIndex + " is invalid");
+ return;
+ }
+ log("switching to phone " + phoneIndex);
+ // getSubId says it takes a slotIndex, but it actually takes a phone index
+ int[] subIds = SubscriptionManager.getSubId(phoneIndex);
+ if (subIds == null || subIds.length < 1) {
+ log("no subscription found for phoneIndex " + phoneIndex);
+ return;
+ }
+ mSelectedPhoneIndex = phoneIndex;
+
+ updatePhoneIndex(phoneIndex, subIds[0]);
+ }
+ }
+
+ public void onNothingSelected(AdapterView parent) {
+ }
+ };
+
AdapterView.OnItemSelectedListener mCellInfoRefreshRateHandler =
new AdapterView.OnItemSelectedListener() {
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java
index d93a798..48e9eee 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingService.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java
@@ -124,7 +124,8 @@
.setLocalOnly(true);
PendingIntent pairIntent = PendingIntent.getActivity(this, 0,
- getPairingDialogIntent(this, intent), PendingIntent.FLAG_ONE_SHOT);
+ getPairingDialogIntent(this, intent),
+ PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent dismissIntent = PendingIntent.getBroadcast(this, 0,
new Intent(ACTION_DISMISS_PAIRING), PendingIntent.FLAG_ONE_SHOT);