summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/settings/development/SmartDdsSwitchPreferenceController.java37
-rwxr-xr-xsrc/com/android/settings/network/telephony/UserPLMNEditorActivity.java5
-rwxr-xr-xsrc/com/android/settings/network/telephony/UserPLMNListActivity.java4
3 files changed, 36 insertions, 10 deletions
diff --git a/src/com/android/settings/development/SmartDdsSwitchPreferenceController.java b/src/com/android/settings/development/SmartDdsSwitchPreferenceController.java
index d216ed40b4..0a3a167dd0 100644
--- a/src/com/android/settings/development/SmartDdsSwitchPreferenceController.java
+++ b/src/com/android/settings/development/SmartDdsSwitchPreferenceController.java
@@ -29,12 +29,16 @@ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
package com.android.settings.development;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.provider.Settings;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import androidx.preference.Preference;
@@ -69,6 +73,12 @@ public class SmartDdsSwitchPreferenceController extends DeveloperOptionsPreferen
private boolean mFeatureAvailable = false;
private boolean mServiceConnected = false;
private boolean mSwitchEnabled = false;
+ private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ updateState(mPreference);
+ }
+ };
private SmartDdsSwitchPreferenceController(Context context) {
super(context);
@@ -78,6 +88,9 @@ public class SmartDdsSwitchPreferenceController extends DeveloperOptionsPreferen
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
mExtTelephonyManager = ExtTelephonyManager.getInstance(mContext);
mExtTelephonyManager.connectService(mExtTelManagerServiceCallback);
+ IntentFilter filter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
+ filter.addAction(TelephonyManager.ACTION_SIM_APPLICATION_STATE_CHANGED);
+ mContext.registerReceiver(mBroadcastReceiver, filter);
}
public static SmartDdsSwitchPreferenceController getInstance(Context context) {
@@ -96,7 +109,7 @@ public class SmartDdsSwitchPreferenceController extends DeveloperOptionsPreferen
private ServiceCallback mExtTelManagerServiceCallback = new ServiceCallback() {
@Override
public void onConnected() {
- Log.d(TAG, "mExtTelManagerServiceCallback: service connected");
+ Log.d(TAG, "ExtTelephonyService connected");
mServiceConnected = true;
mClient = mExtTelephonyManager.registerCallback(mPackageName, mCallback);
Log.d(TAG, "Client = " + mClient);
@@ -104,7 +117,8 @@ public class SmartDdsSwitchPreferenceController extends DeveloperOptionsPreferen
@Override
public void onDisconnected() {
- Log.d(TAG, "mExtTelManagerServiceCallback: service disconnected");
+ Log.d(TAG, "ExtTelephonyService disconnected");
+ mContext.unregisterReceiver(mBroadcastReceiver);
mServiceConnected = false;
mClient = null;
}
@@ -183,7 +197,7 @@ public class SmartDdsSwitchPreferenceController extends DeveloperOptionsPreferen
if (mFeatureAvailable) {
String defaultSummary = mContext.getResources().getString(
R.string.smart_dds_switch_summary);
- updateUi(defaultSummary, true);
+ updateUi(defaultSummary, isAvailable());
} else {
Log.d(TAG, "Feature unavailable");
preference.setVisible(false);
@@ -204,10 +218,17 @@ public class SmartDdsSwitchPreferenceController extends DeveloperOptionsPreferen
@Override
public boolean isAvailable() {
- // Only show the toggle if more than one phone is active
- int numActiveModemCount = mTelephonyManager.getActiveModemCount();
- Log.d(TAG, "numActiveModemCount: " + numActiveModemCount);
- return numActiveModemCount > 1;
+ // Only show the toggle if 1) APM is off and 2) more than one subscription is active
+ SubscriptionManager subscriptionManager = mContext.getSystemService(
+ SubscriptionManager.class);
+ int numActiveSubscriptionInfoCount = subscriptionManager.getActiveSubscriptionInfoCount();
+ Log.d(TAG, "numActiveSubscriptionInfoCount: " + numActiveSubscriptionInfoCount);
+ return !isAirplaneModeOn() && (numActiveSubscriptionInfoCount > 1);
+ }
+
+ private boolean isAirplaneModeOn() {
+ return Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
}
private void putSwitchValue(int state) {
@@ -218,4 +239,4 @@ public class SmartDdsSwitchPreferenceController extends DeveloperOptionsPreferen
return Settings.Global.getInt(mContext.getContentResolver(), getPreferenceKey(),
SETTING_VALUE_OFF);
}
-}
+} \ No newline at end of file
diff --git a/src/com/android/settings/network/telephony/UserPLMNEditorActivity.java b/src/com/android/settings/network/telephony/UserPLMNEditorActivity.java
index 47e0836dda..dfac3fa180 100755
--- a/src/com/android/settings/network/telephony/UserPLMNEditorActivity.java
+++ b/src/com/android/settings/network/telephony/UserPLMNEditorActivity.java
@@ -40,6 +40,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.text.InputType;
import android.text.Editable;
+import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
@@ -318,7 +319,9 @@ public class UserPLMNEditorActivity extends PreferenceActivity implements
Log.d(LOG_TAG, "plmn = " + plmn);
String[] CuPlmnArray = getResources().getStringArray(R.array.uplmn_cu_mcc_mnc_values);
for (String CuPlmn : CuPlmnArray) {
- if (plmn.equals(CuPlmn)) return R.array.uplmn_prefer_network_mode_w_choices;
+ if (!TextUtils.isEmpty(plmn) && plmn.equals(CuPlmn)) {
+ return R.array.uplmn_prefer_network_mode_w_choices;
+ }
}
return R.array.uplmn_prefer_network_mode_td_choices;
}
diff --git a/src/com/android/settings/network/telephony/UserPLMNListActivity.java b/src/com/android/settings/network/telephony/UserPLMNListActivity.java
index 283b1b4bf8..a49ce87e43 100755
--- a/src/com/android/settings/network/telephony/UserPLMNListActivity.java
+++ b/src/com/android/settings/network/telephony/UserPLMNListActivity.java
@@ -598,7 +598,9 @@ public class UserPLMNListActivity extends PreferenceActivity
list.add(mUPLMNList.get(i));
}
- list.remove(position);
+ if (position >= 0) {
+ list.remove(position);
+ }
network.setOperatorNumeric(null);
list.add(network);