summaryrefslogtreecommitdiff
path: root/src/com/android/settings/development
diff options
context:
space:
mode:
authoralk3pInjection <webmaster@raspii.tech>2022-08-05 20:43:06 +0800
committeralk3pInjection <webmaster@raspii.tech>2022-08-05 20:43:06 +0800
commit2421590cd1bf7c844002c217f7e726a0d4887bde (patch)
treed7be99a9f5094bff3e3fce516f7e082d16242b02 /src/com/android/settings/development
parent3008f5ade14bf5a079a565061e96900cce2dc74b (diff)
parenta8f32342c189d1470647d49f63fec2cb3e86fe99 (diff)
Merge tag 'LA.QSSI.12.0.r1-08300-qssi.0' into sugisawa-mr1HEADsugisawa-mr1
"LA.QSSI.12.0.r1-08300-qssi.0" Change-Id: I4693d4e59416ffc3f2679fc8959757e92325b445
Diffstat (limited to 'src/com/android/settings/development')
-rw-r--r--src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java4
-rw-r--r--src/com/android/settings/development/SmartDdsSwitchPreferenceController.java37
2 files changed, 31 insertions, 10 deletions
diff --git a/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java b/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java
index be7704fd73..7c3d3b120e 100644
--- a/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java
+++ b/src/com/android/settings/development/DefaultUsbConfigurationPreferenceController.java
@@ -24,7 +24,7 @@ import android.os.UserHandle;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
-import com.android.settingslib.RestrictedSwitchPreference;
+import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class DefaultUsbConfigurationPreferenceController extends
@@ -32,7 +32,7 @@ public class DefaultUsbConfigurationPreferenceController extends
private static final String PREFERENCE_KEY = "default_usb_configuration";
- private RestrictedSwitchPreference mPreference;
+ private RestrictedPreference mPreference;
public DefaultUsbConfigurationPreferenceController(Context context) {
super(context);
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