Merge "Fix user starts by using startProfile" into udc-dev
diff --git a/res/drawable/flip_camera_for_selfie.xml b/res/drawable/flip_camera_for_selfie.xml
deleted file mode 100644
index dcbf9f4..0000000
--- a/res/drawable/flip_camera_for_selfie.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape>
-</shape>
diff --git a/res/layout/locale_order_list.xml b/res/layout/locale_order_list.xml
index a1f93cd..acde145 100644
--- a/res/layout/locale_order_list.xml
+++ b/res/layout/locale_order_list.xml
@@ -36,7 +36,7 @@
<Button
android:id="@+id/add_language"
android:layout_width="match_parent"
- android:layout_height="?android:listPreferredItemHeight"
+ android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:drawableStart="@drawable/ic_add_24dp"
diff --git a/res/raw/flip_camera_for_selfie_lottie.json b/res/raw/flip_camera_for_selfie_lottie.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/res/raw/flip_camera_for_selfie_lottie.json
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f593db9..f23fb5f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1126,6 +1126,10 @@
<string name="auto_pin_confirm_user_message">Auto-confirm correct PIN</string>
<!-- Message shown to explain the security concern if a user opts-in to the auto-pin feature. [CHAR LIMIT=NONE] -->
<string name="auto_pin_confirm_opt_in_security_message">Confirming your PIN by tapping Enter is more secure than using auto-confirm</string>
+ <!-- Description of pin confirmation screen when auto confirm setting is turned on. [CHAR LIMIT=NONE] -->
+ <string name="auto_confirm_on_pin_verify_description">Enter device PIN to enable auto-confirm</string>
+ <!-- Description of pin confirmation screen when auto confirm setting is turned off. [CHAR LIMIT=NONE] -->
+ <string name="auto_confirm_off_pin_verify_description">Enter device PIN to disable auto-confirm</string>
<!-- Main Security lock settings --><skip />
<!-- Title for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=22] -->
diff --git a/res/xml/double_twist_gesture_settings.xml b/res/xml/double_twist_gesture_settings.xml
index b825a2c..674ba51 100644
--- a/res/xml/double_twist_gesture_settings.xml
+++ b/res/xml/double_twist_gesture_settings.xml
@@ -24,7 +24,8 @@
<com.android.settingslib.widget.IllustrationPreference
android:key="gesture_double_twist_video"
settings:searchable="false"
- app:lottie_rawRes="@drawable/flip_camera_for_selfie"/>
+ settings:lottie_rawRes="@raw/flip_camera_for_selfie_lottie"
+ settings:dynamicColor="true"/>
<SwitchPreference
android:key="gesture_double_twist"
diff --git a/res/xml/keyboard_settings.xml b/res/xml/keyboard_settings.xml
index 9a3ac1a..bb1c3da 100644
--- a/res/xml/keyboard_settings.xml
+++ b/res/xml/keyboard_settings.xml
@@ -30,8 +30,7 @@
<Preference
android:key="physical_keyboard_pref"
android:title="@string/physical_keyboard_title"
- android:summary="@string/summary_placeholder"
- android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
+ android:summary="@string/summary_placeholder"/>
</PreferenceCategory>
<PreferenceCategory
diff --git a/src/com/android/settings/SettingsDumpService.java b/src/com/android/settings/SettingsDumpService.java
index 38987f5..4feb6b2 100644
--- a/src/com/android/settings/SettingsDumpService.java
+++ b/src/com/android/settings/SettingsDumpService.java
@@ -31,12 +31,15 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
+import android.util.IndentingPrintWriter;
+import android.util.Log;
import androidx.annotation.VisibleForTesting;
import com.android.settings.applications.ProcStatsData;
import com.android.settings.datausage.lib.DataUsageLib;
import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
+import com.android.settings.network.MobileNetworkRepository;
import com.android.settingslib.net.DataUsageController;
import org.json.JSONArray;
@@ -48,6 +51,10 @@
import java.io.PrintWriter;
public class SettingsDumpService extends Service {
+
+ public static final String EXTRA_KEY_SHOW_NETWORK_DUMP = "show_network_dump";
+
+ private static final String TAG = "SettingsDumpService";
@VisibleForTesting
static final String KEY_SERVICE = "service";
@VisibleForTesting
@@ -64,6 +71,16 @@
static final Intent BROWSER_INTENT =
new Intent("android.intent.action.VIEW", Uri.parse("http://"));
+ private boolean mShouldShowNetworkDump = false;
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ if (intent != null) {
+ mShouldShowNetworkDump = intent.getBooleanExtra(EXTRA_KEY_SHOW_NETWORK_DUMP, false);
+ }
+ return Service.START_REDELIVER_INTENT;
+ }
+
@Override
public IBinder onBind(Intent intent) {
return null;
@@ -71,20 +88,27 @@
@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
- JSONObject dump = new JSONObject();
-
- try {
- dump.put(KEY_SERVICE, "Settings State");
- dump.put(KEY_STORAGE, dumpStorage());
- dump.put(KEY_DATAUSAGE, dumpDataUsage());
- dump.put(KEY_MEMORY, dumpMemory());
- dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
- dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
- } catch (Exception e) {
- e.printStackTrace();
+ IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
+ if (!mShouldShowNetworkDump) {
+ JSONObject dump = new JSONObject();
+ pw.println(TAG + ": ");
+ pw.increaseIndent();
+ try {
+ dump.put(KEY_SERVICE, "Settings State");
+ dump.put(KEY_STORAGE, dumpStorage());
+ dump.put(KEY_DATAUSAGE, dumpDataUsage());
+ dump.put(KEY_MEMORY, dumpMemory());
+ dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
+ dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
+ } catch (Exception e) {
+ Log.w(TAG, "exception in dump: ", e);
+ }
+ pw.println(dump);
+ pw.flush();
+ pw.decreaseIndent();
+ } else {
+ dumpMobileNetworkSettings(pw);
}
-
- writer.println(dump);
}
private JSONObject dumpMemory() throws JSONException {
@@ -186,4 +210,8 @@
return obj;
}
+
+ private void dumpMobileNetworkSettings(IndentingPrintWriter writer) {
+ MobileNetworkRepository.getInstance(this).dump(writer);
+ }
}
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
index 370392b..a0dac5a 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
@@ -23,6 +23,7 @@
import android.util.Log;
import android.util.TypedValue;
+import androidx.window.embedding.ActivityEmbeddingController;
import androidx.window.embedding.SplitController;
import com.android.settings.R;
@@ -81,4 +82,13 @@
return dm.widthPixels >= (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, MIN_REGULAR_HOMEPAGE_LAYOUT_WIDTH_DP, dm);
}
+
+ /**
+ * Check if activity is already embedded
+ */
+ public static boolean isAlreadyEmbedded(Activity activity) {
+ return ActivityEmbeddingController
+ .getInstance(activity)
+ .isActivityEmbedded(activity);
+ }
}
diff --git a/src/com/android/settings/applications/InstalledAppDetailsTop.java b/src/com/android/settings/applications/InstalledAppDetailsTop.java
index 63e0451..a1bd720 100644
--- a/src/com/android/settings/applications/InstalledAppDetailsTop.java
+++ b/src/com/android/settings/applications/InstalledAppDetailsTop.java
@@ -17,6 +17,7 @@
package com.android.settings.applications;
import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
@@ -30,12 +31,16 @@
@Override
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
- if (!FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_ENABLE_SPA)) {
+ if (isFinishing() ||
+ !FeatureFlagUtils.isEnabled(this, FeatureFlagUtils.SETTINGS_ENABLE_SPA)) {
return;
}
- String packageName = super.getIntent().getData().getSchemeSpecificPart();
- SpaActivity.startSpaActivity(
- this, AppInfoSettingsProvider.INSTANCE.getRoute(packageName, getUserId()));
+ Uri data = super.getIntent().getData();
+ if (data != null) {
+ String packageName = data.getSchemeSpecificPart();
+ String route = AppInfoSettingsProvider.INSTANCE.getRoute(packageName, getUserId());
+ SpaActivity.startSpaActivity(this, route);
+ }
finish();
}
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index f4a3cd4..eb0a5ec 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -29,13 +29,16 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
+import android.content.res.Resources;
import android.credentials.CredentialManager;
import android.credentials.CredentialProviderInfo;
import android.credentials.SetEnabledProvidersException;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
import android.os.Bundle;
import android.os.OutcomeReceiver;
import android.os.UserHandle;
+import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.IconDrawableFactory;
@@ -48,6 +51,7 @@
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.OnLifecycleEvent;
+import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
@@ -69,6 +73,7 @@
/** Queries available credential manager providers and adds preferences for them. */
public class CredentialManagerPreferenceController extends BasePreferenceController
implements LifecycleObserver {
+ public static final String ADD_SERVICE_DEVICE_CONFIG = "credential_manager_service_search_uri";
private static final String TAG = "CredentialManagerPreferenceController";
private static final String ALTERNATE_INTENT = "android.settings.SYNC_SETTINGS";
private static final String PRIMARY_INTENT = "android.settings.CREDENTIAL_PROVIDER";
@@ -85,6 +90,7 @@
private @Nullable FragmentManager mFragmentManager = null;
private @Nullable Delegate mDelegate = null;
+ private @Nullable String mFlagOverrideForTest = null;
public CredentialManagerPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -237,12 +243,16 @@
setAvailableServices(
lifecycleOwner,
mCredentialManager.getCredentialProviderServices(
- getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY));
+ getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
+ null);
}
@VisibleForTesting
void setAvailableServices(
- LifecycleOwner lifecycleOwner, List<CredentialProviderInfo> availableServices) {
+ LifecycleOwner lifecycleOwner,
+ List<CredentialProviderInfo> availableServices,
+ String flagOverrideForTest) {
+ mFlagOverrideForTest = flagOverrideForTest;
mServices.clear();
mServices.addAll(availableServices);
@@ -276,6 +286,65 @@
PreferenceGroup group = screen.findPreference(getPreferenceKey());
Context context = screen.getContext();
mPrefs.putAll(buildPreferenceList(context, group));
+
+ // Add the "add service" button only when there are no providers.
+ if (mPrefs.isEmpty()) {
+ String searchUri = getAddServiceUri(context);
+ if (!TextUtils.isEmpty(searchUri)) {
+ group.addPreference(newAddServicePreference(searchUri, context));
+ }
+ }
+ }
+
+ /**
+ * Returns the "add service" URI to show the play store. It will first try and use the
+ * credential manager specific search URI and if that is null it will fallback to the autofill
+ * one.
+ */
+ public @NonNull String getAddServiceUri(@NonNull Context context) {
+ // Check the credential manager gflag for a link.
+ String searchUri =
+ DeviceConfig.getString(
+ DeviceConfig.NAMESPACE_CREDENTIAL,
+ ADD_SERVICE_DEVICE_CONFIG,
+ mFlagOverrideForTest);
+ if (!TextUtils.isEmpty(searchUri)) {
+ return searchUri;
+ }
+
+ // If not fall back on autofill.
+ return Settings.Secure.getStringForUser(
+ context.getContentResolver(),
+ Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
+ getUser());
+ }
+
+ /**
+ * Gets the preference that allows to add a new cred man service.
+ *
+ * @return the pref to be added
+ */
+ @VisibleForTesting
+ public Preference newAddServicePreference(String searchUri, Context context) {
+ final Intent addNewServiceIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(searchUri));
+ final Preference preference = new Preference(context);
+ preference.setOnPreferenceClickListener(
+ p -> {
+ context.startActivityAsUser(addNewServiceIntent, UserHandle.of(getUser()));
+ return true;
+ });
+ preference.setTitle(R.string.print_menu_item_add_service);
+ preference.setOrder(Integer.MAX_VALUE - 1);
+ preference.setPersistent(false);
+
+ // Try to set the icon this should fail in a test environment but work
+ // in the actual app.
+ try {
+ preference.setIcon(R.drawable.ic_add_24dp);
+ } catch (Resources.NotFoundException e) {
+ Log.e(TAG, "Failed to find icon for add services link", e);
+ }
+ return preference;
}
/** Aggregates the list of services and builds a list of UI prefs to show. */
@@ -317,7 +386,9 @@
}
// Build the pref and add it to the output & group.
- SwitchPreference pref = addProviderPreference(context, title, icon, packageName, firstInfo.getSettingsSubtitle());
+ SwitchPreference pref =
+ addProviderPreference(
+ context, title, icon, packageName, firstInfo.getSettingsSubtitle());
output.put(packageName, pref);
group.addPreference(pref);
}
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index e63a754..af581b8 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -22,6 +22,8 @@
import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_CONSENT_DENIED;
import static com.android.settings.biometrics.BiometricEnrollBase.RESULT_CONSENT_GRANTED;
+import static com.google.android.setupdesign.transition.TransitionHelper.TRANSITION_FADE_THROUGH;
+
import android.annotation.NonNull;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
@@ -55,6 +57,7 @@
import com.android.settings.password.ChooseLockSettingsHelper;
import com.google.android.setupcompat.util.WizardManagerHelper;
+import com.google.android.setupdesign.transition.TransitionHelper;
import java.util.List;
@@ -457,6 +460,9 @@
final boolean isOk =
isSuccessfulConfirmOrChooseCredential(requestCode, resultCode);
if (isOk && (mHasFeatureFace || mHasFeatureFingerprint)) {
+ // Apply forward animation during the transition from ChooseLock/ConfirmLock to
+ // SetupFingerprintEnrollIntroduction/FingerprintEnrollmentActivity
+ TransitionHelper.applyForwardTransition(this, TRANSITION_FADE_THROUGH);
updateGatekeeperPasswordHandle(data);
if (mHasFeatureFingerprint) {
launchFingerprintOnlyEnroll();
@@ -473,6 +479,10 @@
mIsSingleEnrolling = false;
if ((resultCode == BiometricEnrollBase.RESULT_SKIP
|| resultCode == BiometricEnrollBase.RESULT_FINISHED) && mHasFeatureFace) {
+ // Apply forward animation during the transition from
+ // SetupFingerprintEnroll*/FingerprintEnrollmentActivity to
+ // SetupFaceEnrollIntroduction
+ TransitionHelper.applyForwardTransition(this, TRANSITION_FADE_THROUGH);
launchFaceOnlyEnroll();
} else {
finishOrLaunchHandToParent(resultCode);
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 2a1d049..7051b70 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -21,7 +21,6 @@
import android.os.UserHandle;
import android.view.View;
-import com.android.settings.R;
import com.android.settings.password.ChooseLockSettingsHelper;
/**
@@ -120,7 +119,6 @@
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
}
startActivity(intent);
- overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
finish();
}
diff --git a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
index 7f69b91..62928af 100644
--- a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
+++ b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollmentActivity.java
@@ -267,9 +267,11 @@
} else {
getSupportFragmentManager().beginTransaction()
.setReorderingAllowed(true)
+ .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+ R.anim.shared_x_axis_activity_open_exit,
+ R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+ R.anim.shared_x_axis_activity_close_exit)
.replace(R.id.fragment_container_view, fragmentClass, null, tag)
- .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
- R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
.addToBackStack(tag)
.commit();
}
@@ -373,20 +375,24 @@
// Replace enrolling page
getSupportFragmentManager().beginTransaction()
.setReorderingAllowed(true)
+ .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+ R.anim.shared_x_axis_activity_open_exit,
+ R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+ R.anim.shared_x_axis_activity_close_exit)
.replace(R.id.fragment_container_view, FingerprintEnrollFinishFragment.class,
null, FINISH_TAG)
- .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
- R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
.commit();
} else {
// Remove Enrolling page from backstack, and add Finish page. Latest backstack will
// be changed from Intro->FindSensor->Enrolling to Intro->FindSensor->Finish
getSupportFragmentManager().beginTransaction()
.setReorderingAllowed(true)
+ .setCustomAnimations(R.anim.shared_x_axis_activity_open_enter_dynamic_color,
+ R.anim.shared_x_axis_activity_open_exit,
+ R.anim.shared_x_axis_activity_close_enter_dynamic_color,
+ R.anim.shared_x_axis_activity_close_exit)
.replace(R.id.fragment_container_view, FingerprintEnrollFinishFragment.class,
null, FINISH_TAG)
- .setCustomAnimations(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out,
- R.anim.sud_slide_back_in, R.anim.sud_slide_back_out)
.addToBackStack(FINISH_TAG)
.commit();
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
index 3851753..182ada2 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceDetailsFragment.java
@@ -172,7 +172,7 @@
}
use(AdvancedBluetoothDetailsHeaderController.class).init(mCachedDevice);
use(LeAudioBluetoothDetailsHeaderController.class).init(mCachedDevice, mManager);
- use(KeyboardSettingsPreferenceController.class).init(mCachedDevice, getActivity());
+ use(KeyboardSettingsPreferenceController.class).init(mCachedDevice);
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(
context).getBluetoothFeatureProvider();
diff --git a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
index ac895df..c93a1c6 100644
--- a/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
+++ b/src/com/android/settings/connecteddevice/stylus/StylusDevicesController.java
@@ -127,8 +127,9 @@
pref.setTitle(mContext.getString(R.string.stylus_textfield_handwriting));
pref.setIcon(R.drawable.ic_text_fields_alt);
pref.setOnPreferenceClickListener(this);
- pref.setChecked(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, 0) == 1);
+ pref.setChecked(Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+ Secure.STYLUS_HANDWRITING_DEFAULT_VALUE) == 1);
pref.setVisible(currentInputMethodSupportsHandwriting());
return pref;
}
@@ -157,8 +158,8 @@
mContext.startActivity(intent);
break;
case KEY_HANDWRITING:
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED,
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED,
((SwitchPreference) preference).isChecked() ? 1 : 0);
if (((SwitchPreference) preference).isChecked()) {
diff --git a/src/com/android/settings/development/StylusHandwritingPreferenceController.java b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
index 69b5bad..12cd781 100644
--- a/src/com/android/settings/development/StylusHandwritingPreferenceController.java
+++ b/src/com/android/settings/development/StylusHandwritingPreferenceController.java
@@ -45,8 +45,8 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED,
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
return true;
@@ -54,16 +54,18 @@
@Override
public void updateState(Preference preference) {
- final int enable = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+ final int enable = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+ Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
((SwitchPreference) mPreference).setChecked(enable != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED,
+ Settings.Secure.STYLUS_HANDWRITING_DEFAULT_VALUE);
((SwitchPreference) mPreference).setChecked(false);
}
}
diff --git a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
index 85b67ea..03461af 100644
--- a/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
+++ b/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceController.java
@@ -16,16 +16,15 @@
package com.android.settings.inputmethod;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
import android.util.FeatureFlagUtils;
import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
-import com.android.settings.Settings.PhysicalKeyboardActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
@@ -34,18 +33,14 @@
public class KeyboardSettingsPreferenceController extends BasePreferenceController {
- private Context mContext;
private CachedBluetoothDevice mCachedDevice;
- private Activity mActivity;
public KeyboardSettingsPreferenceController(Context context, String key) {
super(context, key);
- mContext = context;
}
- public void init(@NonNull CachedBluetoothDevice cachedDevice, @NonNull Activity activity) {
+ public void init(@NonNull CachedBluetoothDevice cachedDevice) {
mCachedDevice = cachedDevice;
- mActivity = activity;
}
@Override
@@ -53,18 +48,26 @@
if (!getPreferenceKey().equals(preference.getKey())) {
return false;
}
-
- final Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
- intent.setClass(mContext, PhysicalKeyboardActivity.class);
- intent.putExtra(PhysicalKeyboardFragment.EXTRA_BT_ADDRESS, mCachedDevice.getAddress());
- mActivity.startActivityForResult(intent, 0);
+ List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboardList();
+ for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
+ if (mCachedDevice.getAddress().equals(hardKeyboardDeviceInfo.mBluetoothAddress)) {
+ Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+ intent.putExtra(
+ NewKeyboardSettingsUtils.EXTRA_INTENT_FROM,
+ "com.android.settings.inputmethod.KeyboardSettingsPreferenceController");
+ intent.putExtra(
+ Settings.EXTRA_INPUT_DEVICE_IDENTIFIER,
+ hardKeyboardDeviceInfo.mDeviceIdentifier);
+ mContext.startActivity(intent);
+ break;
+ }
+ }
return true;
}
@Override
public int getAvailabilityStatus() {
- final List<HardKeyboardDeviceInfo> newHardKeyboards =
- PhysicalKeyboardFragment.getHardKeyboards(mContext);
+ List<HardKeyboardDeviceInfo> newHardKeyboards = getHardKeyboardList();
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_UI)
&& !newHardKeyboards.isEmpty()) {
for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
@@ -78,4 +81,9 @@
}
return CONDITIONALLY_UNAVAILABLE;
}
+
+ @VisibleForTesting
+ List<HardKeyboardDeviceInfo> getHardKeyboardList() {
+ return PhysicalKeyboardFragment.getHardKeyboards(mContext);
+ }
}
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
index 0f49ee1..3344f4e 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java
@@ -23,6 +23,7 @@
import android.hardware.input.KeyboardLayout;
import android.os.Bundle;
import android.os.UserHandle;
+import android.util.Log;
import android.view.InputDevice;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
@@ -59,10 +60,19 @@
public void onActivityCreated(final Bundle icicle) {
super.onActivityCreated(icicle);
Bundle arguments = getArguments();
- final String title =
- arguments.getString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_DEVICE_NAME);
mInputDeviceIdentifier =
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER);
+ if (mInputDeviceIdentifier == null) {
+ Log.e(TAG, "The inputDeviceIdentifier should not be null");
+ return;
+ }
+ InputDevice inputDevice =
+ NewKeyboardSettingsUtils.getInputDevice(mIm, mInputDeviceIdentifier);
+ if (inputDevice == null) {
+ Log.e(TAG, "inputDevice is null");
+ return;
+ }
+ final String title = inputDevice.getName();
getActivity().setTitle(title);
updateCheckedState();
}
diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
index 761e95e..110147a 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerContent.java
@@ -47,6 +47,7 @@
arguments.getParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_METHOD_SUBTYPE);
if (identifier == null
|| NewKeyboardSettingsUtils.getInputDevice(inputManager, identifier) == null) {
+ getActivity().finish();
return;
}
getActivity().setTitle(title);
diff --git a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
index 506d1e7..fe0c9d4 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
@@ -32,7 +32,12 @@
*/
public class NewKeyboardSettingsUtils {
- static final String EXTRA_KEYBOARD_DEVICE_NAME = "extra_keyboard_device_name";
+ /**
+ * Record the class name of the intent sender for metrics.
+ */
+ public static final String EXTRA_INTENT_FROM =
+ "com.android.settings.inputmethod.EXTRA_INTENT_FROM";
+
static final String EXTRA_TITLE = "keyboard_layout_picker_title";
static final String EXTRA_KEYBOARD_LAYOUT = "keyboard_layout";
static final String EXTRA_USER_ID = "user_id";
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index e9dba57..22f5b65 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -87,7 +87,6 @@
@Override
public void onCreatePreferences(Bundle bundle, String s) {
Activity activity = Preconditions.checkNotNull(getActivity());
- mBluetoothAddress = activity.getIntent().getStringExtra(EXTRA_BT_ADDRESS);
addPreferencesFromResource(R.xml.physical_keyboard_settings);
mIm = Preconditions.checkNotNull(activity.getSystemService(InputManager.class));
mImm = Preconditions.checkNotNull(activity.getSystemService(InputMethodManager.class));
@@ -104,6 +103,19 @@
if (!isModifierKeySettingsEnabled) {
mKeyboardAssistanceCategory.removePreference(findPreference(MODIFIER_KEYS_SETTINGS));
}
+ InputDeviceIdentifier inputDeviceIdentifier = activity.getIntent().getParcelableExtra(
+ KeyboardLayoutPickerFragment.EXTRA_INPUT_DEVICE_IDENTIFIER);
+ // TODO (b/271391879): The EXTRA_INTENT_FROM is used for the future metrics.
+ if (inputDeviceIdentifier != null) {
+ Bundle arguments = new Bundle();
+ arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
+ inputDeviceIdentifier);
+ new SubSettingLauncher(getContext())
+ .setSourceMetricsCategory(getMetricsCategory())
+ .setDestination(NewKeyboardLayoutEnabledLocalesFragment.class.getName())
+ .setArguments(arguments)
+ .launch();
+ }
}
@Override
@@ -187,14 +199,6 @@
preferenceScreen.addPreference(category);
for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
-
- // if user go into this page from Connected devices entry, we should distinguish the
- // user-selected keyboard from all enabled keyboards.
- if (mBluetoothAddress != null
- && !mBluetoothAddress.equals(hardKeyboardDeviceInfo.mBluetoothAddress)) {
- continue;
- }
-
// TODO(yukawa): Consider using com.android.settings.widget.GearPreference
final Preference pref = new Preference(getPrefContext());
pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
@@ -247,7 +251,6 @@
Bundle arguments = new Bundle();
arguments.putParcelable(NewKeyboardSettingsUtils.EXTRA_INPUT_DEVICE_IDENTIFIER,
inputDeviceIdentifier);
- arguments.putString(NewKeyboardSettingsUtils.EXTRA_KEYBOARD_DEVICE_NAME, keyboardName);
new SubSettingLauncher(getContext())
.setSourceMetricsCategory(getMetricsCategory())
.setDestination(NewKeyboardLayoutEnabledLocalesFragment.class.getName())
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
index 3dcae09..1f01b98 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardPreferenceController.java
@@ -17,8 +17,10 @@
package com.android.settings.inputmethod;
import android.content.Context;
+import android.content.Intent;
import android.hardware.input.InputManager;
import android.icu.text.ListFormatter;
+import android.provider.Settings;
import androidx.preference.Preference;
@@ -59,6 +61,19 @@
}
@Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!getPreferenceKey().equals(preference.getKey())) {
+ return false;
+ }
+ Intent intent = new Intent(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+ intent.putExtra(
+ NewKeyboardSettingsUtils.EXTRA_INTENT_FROM,
+ "com.android.settings.inputmethod.PhysicalKeyboardPreferenceController");
+ mContext.startActivity(intent);
+ return true;
+ }
+
+ @Override
public void updateState(Preference preference) {
mPreference = preference;
updateEntry();
diff --git a/src/com/android/settings/network/DefaultSubscriptionReceiver.java b/src/com/android/settings/network/DefaultSubscriptionReceiver.java
new file mode 100644
index 0000000..cdaf48f
--- /dev/null
+++ b/src/com/android/settings/network/DefaultSubscriptionReceiver.java
@@ -0,0 +1,59 @@
+package com.android.settings.network;
+
+import static com.android.internal.telephony.TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+
+public class DefaultSubscriptionReceiver extends BroadcastReceiver {
+
+ private Context mContext;
+ private DefaultSubscriptionListener mListener;
+
+ public DefaultSubscriptionReceiver(Context context, DefaultSubscriptionListener listener) {
+ mContext = context;
+ mListener = listener;
+ }
+
+ public void registerReceiver() {
+ final IntentFilter filter = new IntentFilter();
+ filter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
+ filter.addAction(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
+ filter.addAction(ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED);
+ filter.addAction(SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED);
+ mContext.registerReceiver(this, filter);
+ }
+
+ public void unRegisterReceiver() {
+ mContext.unregisterReceiver(this);
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED.equals(action)) {
+ mListener.onDefaultDataChanged(SubscriptionManager.getDefaultDataSubscriptionId());
+ } else if (SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED.equals(action)) {
+ mListener.onDefaultSubInfoChanged(SubscriptionManager.getDefaultSubscriptionId());
+ } else if (TelephonyManager.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED.equals(action)) {
+ mListener.onDefaultVoiceChanged(SubscriptionManager.getDefaultVoiceSubscriptionId());
+ } else if (SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED.equals(action)) {
+ mListener.onDefaultSmsChanged(SubscriptionManager.getDefaultSmsSubscriptionId());
+ }
+ }
+
+ public interface DefaultSubscriptionListener {
+ default void onDefaultSubInfoChanged(int defaultSubId) {
+ }
+ default void onDefaultDataChanged(int defaultDataSubId) {
+ }
+ default void onDefaultVoiceChanged(int defaultVoiceSubId) {
+ }
+ default void onDefaultSmsChanged(int defaultSmsSubId) {
+ }
+ }
+}
diff --git a/src/com/android/settings/network/InternetPreferenceController.java b/src/com/android/settings/network/InternetPreferenceController.java
index 898585c..bc2e71e 100644
--- a/src/com/android/settings/network/InternetPreferenceController.java
+++ b/src/com/android/settings/network/InternetPreferenceController.java
@@ -27,9 +27,7 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
-import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.util.Log;
import androidx.annotation.IdRes;
import androidx.annotation.VisibleForTesting;
@@ -45,9 +43,7 @@
import com.android.settings.wifi.WifiSummaryUpdater;
import com.android.settingslib.Utils;
import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
import com.android.settingslib.utils.ThreadUtils;
import java.util.ArrayList;
@@ -60,7 +56,8 @@
*/
public class InternetPreferenceController extends AbstractPreferenceController implements
LifecycleObserver, SummaryUpdater.OnSummaryChangeListener,
- InternetUpdater.InternetChangeListener, MobileNetworkRepository.MobileNetworkCallback {
+ InternetUpdater.InternetChangeListener, MobileNetworkRepository.MobileNetworkCallback,
+ DefaultSubscriptionReceiver.DefaultSubscriptionListener {
public static final String KEY = "internet_settings";
@@ -71,6 +68,8 @@
private LifecycleOwner mLifecycleOwner;
private MobileNetworkRepository mMobileNetworkRepository;
private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
+ private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
@VisibleForTesting
static Map<Integer, Integer> sIconMap = new HashMap<>();
@@ -102,6 +101,7 @@
mInternetType = mInternetUpdater.getInternetType();
mLifecycleOwner = lifecycleOwner;
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+ mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
lifecycle.addObserver(this);
}
@@ -160,6 +160,8 @@
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mMobileNetworkRepository.updateEntity();
mSummaryHelper.register(true);
+ mDataSubscriptionChangedReceiver.registerReceiver();
+ mDefaultDataSubId = SubscriptionManager.getDefaultDataSubscriptionId();
}
/** @OnLifecycleEvent(ON_PAUSE) */
@@ -167,6 +169,7 @@
public void onPause() {
mMobileNetworkRepository.removeRegister(this);
mSummaryHelper.register(false);
+ mDataSubscriptionChangedReceiver.unRegisterReceiver();
}
/**
@@ -212,11 +215,11 @@
if (subInfo.isActiveDataSubscriptionId) {
activeSubInfo = subInfo;
}
- if (subInfo.isDefaultDataSubscription) {
+ if (subInfo.getSubId() == getDefaultDataSubscriptionId()) {
defaultSubInfo = subInfo;
}
}
- if (activeSubInfo == null) {
+ if (activeSubInfo == null || defaultSubInfo == null) {
return;
}
activeSubInfo = activeSubInfo.isSubscriptionVisible ? activeSubInfo : defaultSubInfo;
@@ -237,9 +240,20 @@
return mSubInfoEntityList;
}
+ @VisibleForTesting
+ protected int getDefaultDataSubscriptionId() {
+ return mDefaultDataSubId;
+ }
+
@Override
public void onAvailableSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
mSubInfoEntityList = subInfoEntityList;
updateState(mPreference);
}
+
+ @Override
+ public void onDefaultDataChanged(int defaultDataSubId) {
+ mDefaultDataSubId = defaultDataSubId;
+ updateState(mPreference);
+ }
}
diff --git a/src/com/android/settings/network/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index bec65e2..170d921 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -18,14 +18,9 @@
import static android.telephony.SubscriptionManager.PROFILE_CLASS_PROVISIONING;
import static android.telephony.UiccSlotInfo.CARD_STATE_INFO_PRESENT;
-import static com.android.internal.telephony.TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED;
-
import android.annotation.NonNull;
import android.app.settings.SettingsEnums;
-import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
@@ -39,6 +34,7 @@
import android.telephony.UiccPortInfo;
import android.telephony.UiccSlotInfo;
import android.util.ArrayMap;
+import android.util.IndentingPrintWriter;
import android.util.Log;
import com.android.settings.network.telephony.MobileNetworkUtils;
@@ -98,7 +94,6 @@
private AirplaneModeObserver mAirplaneModeObserver;
private Uri mAirplaneModeSettingUri;
private MetricsFeatureProvider mMetricsFeatureProvider;
- private IntentFilter mFilter = new IntentFilter();
private Map<Integer, MobileDataContentObserver> mDataContentObserverMap = new HashMap<>();
private int mPhysicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
private int mLogicalSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
@@ -111,12 +106,7 @@
private Map<Integer, SubscriptionInfo> mSubscriptionInfoMap = new ArrayMap<>();
private Map<Integer, TelephonyManager> mTelephonyManagerMap = new HashMap<>();
private Map<Integer, PhoneCallStateTelephonyCallback> mTelephonyCallbackMap = new HashMap<>();
- private BroadcastReceiver mDataSubscriptionChangedReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- onSubscriptionsChanged();
- }
- };
+
@NonNull
public static MobileNetworkRepository getInstance(Context context) {
synchronized (sInstanceLock) {
@@ -142,10 +132,6 @@
mMobileNetworkInfoDao = mMobileNetworkDatabase.mMobileNetworkInfoDao();
mAirplaneModeObserver = new AirplaneModeObserver(new Handler(Looper.getMainLooper()));
mAirplaneModeSettingUri = Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON);
- mFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
- mFilter.addAction(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
- mFilter.addAction(ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED);
- mFilter.addAction(SubscriptionManager.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED);
}
private class AirplaneModeObserver extends ContentObserver {
@@ -187,7 +173,6 @@
mSubscriptionManager.addOnSubscriptionsChangedListener(mContext.getMainExecutor(),
this);
mAirplaneModeObserver.register(mContext);
- mContext.registerReceiver(mDataSubscriptionChangedReceiver, mFilter);
if (DEBUG) {
Log.d(TAG, "addRegister done");
}
@@ -270,7 +255,6 @@
if (sCallbacks.isEmpty()) {
mSubscriptionManager.removeOnSubscriptionsChangedListener(this);
mAirplaneModeObserver.unRegister(mContext);
- mContext.unregisterReceiver(mDataSubscriptionChangedReceiver);
mDataContentObserverMap.forEach((id, observer) -> {
observer.unRegister(mContext);
});
@@ -523,16 +507,11 @@
SubscriptionUtil.getFormattedPhoneNumber(context, subInfo),
firstRemovableSubInfo == null ? false
: firstRemovableSubInfo.getSubscriptionId() == subId,
- String.valueOf(SubscriptionUtil.getDefaultSimConfig(context, subId)),
SubscriptionUtil.isDefaultSubscription(context, subId),
mSubscriptionManager.isValidSubscriptionId(subId),
mSubscriptionManager.isUsableSubscriptionId(subId),
mSubscriptionManager.isActiveSubscriptionId(subId),
true /*availableSubInfo*/,
- mSubscriptionManager.getDefaultVoiceSubscriptionId() == subId,
- mSubscriptionManager.getDefaultSmsSubscriptionId() == subId,
- mSubscriptionManager.getDefaultDataSubscriptionId() == subId,
- mSubscriptionManager.getDefaultSubscriptionId() == subId,
mSubscriptionManager.getActiveDataSubscriptionId() == subId);
}
}
@@ -736,4 +715,17 @@
default void onCallStateChanged(int state) {
}
}
+
+ public void dump(IndentingPrintWriter printwriter) {
+ printwriter.println(TAG + ": ");
+ printwriter.increaseIndent();
+ printwriter.println(" availableSubInfoEntityList= " + mAvailableSubInfoEntityList);
+ printwriter.println(" activeSubInfoEntityList=" + mActiveSubInfoEntityList);
+ printwriter.println(" mobileNetworkInfoEntityList= " + mMobileNetworkInfoEntityList);
+ printwriter.println(" uiccInfoEntityList= " + mUiccInfoEntityList);
+ printwriter.println(" CacheSubscriptionInfoEntityMap= " + sCacheSubscriptionInfoEntityMap);
+ printwriter.println(" SubscriptionInfoMap= " + mSubscriptionInfoMap);
+ printwriter.flush();
+ printwriter.decreaseIndent();
+ }
}
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 39cf136..4ea3464 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -30,6 +30,7 @@
import androidx.lifecycle.LifecycleOwner;
import com.android.settings.R;
+import com.android.settings.SettingsDumpService;
import com.android.settings.Utils;
import com.android.settings.core.OnActivityResultListener;
import com.android.settings.dashboard.DashboardFragment;
@@ -122,6 +123,11 @@
}
controllers.add(privateDnsPreferenceController);
controllers.add(new NetworkProviderCallsSmsController(context, lifecycle, lifecycleOwner));
+
+ // Start SettingsDumpService after the MobileNetworkRepository is created.
+ Intent intent = new Intent(context, SettingsDumpService.class);
+ intent.putExtra(SettingsDumpService.EXTRA_KEY_SHOW_NETWORK_DUMP, true);
+ context.startService(intent);
return controllers;
}
diff --git a/src/com/android/settings/network/NetworkProviderCallsSmsController.java b/src/com/android/settings/network/NetworkProviderCallsSmsController.java
index 0c71aa7..5eec3d9 100644
--- a/src/com/android/settings/network/NetworkProviderCallsSmsController.java
+++ b/src/com/android/settings/network/NetworkProviderCallsSmsController.java
@@ -38,14 +38,13 @@
import com.android.settingslib.Utils;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
import java.util.List;
public class NetworkProviderCallsSmsController extends AbstractPreferenceController implements
- LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback {
+ LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback,
+ DefaultSubscriptionReceiver.DefaultSubscriptionListener {
private static final String TAG = "NetworkProviderCallsSmsController";
private static final String KEY = "calls_and_sms";
@@ -58,6 +57,9 @@
private LifecycleOwner mLifecycleOwner;
private MobileNetworkRepository mMobileNetworkRepository;
private List<SubscriptionInfoEntity> mSubInfoEntityList;
+ private int mDefaultVoiceSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ private int mDefaultSmsSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
/**
* The summary text and click behavior of the "Calls & SMS" item on the
@@ -73,6 +75,7 @@
== View.LAYOUT_DIRECTION_RTL;
mLifecycleOwner = lifecycleOwner;
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+ mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
if (lifecycle != null) {
lifecycle.addObserver(this);
}
@@ -83,11 +86,15 @@
mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mMobileNetworkRepository.updateEntity();
+ mDataSubscriptionChangedReceiver.registerReceiver();
+ mDefaultVoiceSubId = SubscriptionManager.getDefaultVoiceSubscriptionId();
+ mDefaultSmsSubId = SubscriptionManager.getDefaultSmsSubscriptionId();
}
@OnLifecycleEvent(Event.ON_PAUSE)
public void onPause() {
mMobileNetworkRepository.removeRegister(this);
+ mDataSubscriptionChangedReceiver.unRegisterReceiver();
}
@Override
@@ -145,16 +152,16 @@
protected CharSequence getPreferredStatus(SubscriptionInfoEntity subInfo, int subsSize,
int subId) {
String status = "";
- boolean isDataPreferred = subInfo.isDefaultVoiceSubscription;
- boolean isSmsPreferred = subInfo.isDefaultSmsSubscription;
+ boolean isCallPreferred = subInfo.getSubId() == getDefaultVoiceSubscriptionId();
+ boolean isSmsPreferred = subInfo.getSubId() == getDefaultSmsSubscriptionId();
if (!subInfo.isValidSubscription || !isInService(subId)) {
status = setSummaryResId(subsSize > 1 ? R.string.calls_sms_unavailable :
R.string.calls_sms_temp_unavailable);
} else {
- if (isDataPreferred && isSmsPreferred) {
+ if (isCallPreferred && isSmsPreferred) {
status = setSummaryResId(R.string.calls_sms_preferred);
- } else if (isDataPreferred) {
+ } else if (isCallPreferred) {
status = setSummaryResId(R.string.calls_sms_calls_preferred);
} else if (isSmsPreferred) {
status = setSummaryResId(R.string.calls_sms_sms_preferred);
@@ -226,4 +233,26 @@
mSubInfoEntityList = activeSubInfoList;
update();
}
+
+ @VisibleForTesting
+ protected int getDefaultVoiceSubscriptionId() {
+ return mDefaultVoiceSubId;
+ }
+
+ @VisibleForTesting
+ protected int getDefaultSmsSubscriptionId() {
+ return mDefaultSmsSubId;
+ }
+
+ @Override
+ public void onDefaultVoiceChanged(int defaultVoiceSubId) {
+ mDefaultVoiceSubId = defaultVoiceSubId;
+ update();
+ }
+
+ @Override
+ public void onDefaultSmsChanged(int defaultSmsSubId) {
+ mDefaultSmsSubId = defaultSmsSubId;
+ update();
+ }
}
diff --git a/src/com/android/settings/network/NetworkProviderSimListController.java b/src/com/android/settings/network/NetworkProviderSimListController.java
index db27291..89cb73c 100644
--- a/src/com/android/settings/network/NetworkProviderSimListController.java
+++ b/src/com/android/settings/network/NetworkProviderSimListController.java
@@ -23,7 +23,6 @@
import android.graphics.drawable.Drawable;
import android.telephony.SubscriptionManager;
import android.util.ArrayMap;
-import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.LifecycleOwner;
@@ -38,16 +37,15 @@
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class NetworkProviderSimListController extends AbstractPreferenceController implements
- LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback {
+ LifecycleObserver, MobileNetworkRepository.MobileNetworkCallback,
+ DefaultSubscriptionReceiver.DefaultSubscriptionListener {
private static final String TAG = "NetworkProviderSimListCtrl";
private static final String KEY_PREFERENCE_CATEGORY_SIM = "provider_model_sim_category";
private static final String KEY_PREFERENCE_SIM = "provider_model_sim_list";
@@ -58,6 +56,7 @@
private LifecycleOwner mLifecycleOwner;
private MobileNetworkRepository mMobileNetworkRepository;
private List<SubscriptionInfoEntity> mSubInfoEntityList = new ArrayList<>();
+ private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
public NetworkProviderSimListController(Context context, Lifecycle lifecycle,
LifecycleOwner lifecycleOwner) {
@@ -66,6 +65,7 @@
mPreferences = new ArrayMap<>();
mLifecycleOwner = lifecycleOwner;
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+ mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
lifecycle.addObserver(this);
}
@@ -74,11 +74,13 @@
mMobileNetworkRepository.addRegister(mLifecycleOwner, this,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
mMobileNetworkRepository.updateEntity();
+ mDataSubscriptionChangedReceiver.registerReceiver();
}
@OnLifecycleEvent(ON_PAUSE)
public void onPause() {
mMobileNetworkRepository.removeRegister(this);
+ mDataSubscriptionChangedReceiver.unRegisterReceiver();
}
@Override
@@ -130,7 +132,8 @@
public CharSequence getSummary(SubscriptionInfoEntity subInfo, CharSequence displayName) {
if (subInfo.isActiveSubscriptionId) {
- CharSequence config = subInfo.defaultSimConfig;
+ CharSequence config = SubscriptionUtil.getDefaultSimConfig(mContext,
+ subInfo.getSubId());
CharSequence summary = mContext.getResources().getString(
R.string.sim_category_active_sim);
if (config == "") {
@@ -185,4 +188,22 @@
refreshSummary(mPreferenceCategory);
update();
}
+
+ @Override
+ public void onDefaultDataChanged(int defaultDataSubId) {
+ refreshSummary(mPreferenceCategory);
+ update();
+ }
+
+ @Override
+ public void onDefaultVoiceChanged(int defaultVoiceSubId) {
+ refreshSummary(mPreferenceCategory);
+ update();
+ }
+
+ @Override
+ public void onDefaultSmsChanged(int defaultSmsSubId) {
+ refreshSummary(mPreferenceCategory);
+ update();
+ }
}
diff --git a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
index de45e62..249c855 100644
--- a/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/CallsDefaultSubscriptionController.java
@@ -40,10 +40,12 @@
@Override
protected int getDefaultSubscriptionId() {
+ int defaultCallSubId = SubscriptionManager.getDefaultVoiceSubscriptionId();
for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) {
- if (subInfo.isActiveSubscriptionId && subInfo.isDefaultVoiceSubscription) {
+ int subId = subInfo.getSubId();
+ if (subInfo.isActiveSubscriptionId && subId == defaultCallSubId) {
mSubscriptionInfoEntity = subInfo;
- return Integer.parseInt(subInfo.subId);
+ return subId;
}
}
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
diff --git a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
index c8f7acf..cb18b33 100644
--- a/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/DefaultSubscriptionController.java
@@ -36,11 +36,10 @@
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
+import com.android.settings.network.DefaultSubscriptionReceiver;
import com.android.settings.network.MobileNetworkRepository;
import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
import java.util.ArrayList;
import java.util.List;
@@ -52,7 +51,8 @@
*/
public abstract class DefaultSubscriptionController extends TelephonyBasePreferenceController
implements LifecycleObserver, Preference.OnPreferenceChangeListener,
- MobileNetworkRepository.MobileNetworkCallback {
+ MobileNetworkRepository.MobileNetworkCallback,
+ DefaultSubscriptionReceiver.DefaultSubscriptionListener {
private static final String TAG = "DefaultSubController";
protected ListPreference mPreference;
@@ -60,6 +60,7 @@
protected TelecomManager mTelecomManager;
protected MobileNetworkRepository mMobileNetworkRepository;
protected LifecycleOwner mLifecycleOwner;
+ private DefaultSubscriptionReceiver mDataSubscriptionChangedReceiver;
private static final String EMERGENCY_ACCOUNT_HANDLE_ID = "E";
private static final ComponentName PSTN_CONNECTION_SERVICE_COMPONENT =
@@ -76,6 +77,7 @@
mIsRtlMode = context.getResources().getConfiguration().getLayoutDirection()
== View.LAYOUT_DIRECTION_RTL;
mMobileNetworkRepository = MobileNetworkRepository.getInstance(context);
+ mDataSubscriptionChangedReceiver = new DefaultSubscriptionReceiver(context, this);
mLifecycleOwner = lifecycleOwner;
if (lifecycle != null) {
lifecycle.addObserver(this);
@@ -110,12 +112,13 @@
// Can not get default subId from database until get the callback, add register by subId
// later.
mMobileNetworkRepository.addRegisterBySubId(getDefaultSubscriptionId());
-
+ mDataSubscriptionChangedReceiver.registerReceiver();
}
@OnLifecycleEvent(ON_PAUSE)
public void onPause() {
mMobileNetworkRepository.removeRegister(this);
+ mDataSubscriptionChangedReceiver.unRegisterReceiver();
}
@Override
@@ -308,4 +311,16 @@
updateEntries();
refreshSummary(mPreference);
}
+
+ @Override
+ public void onDefaultVoiceChanged(int defaultVoiceSubId) {
+ updateEntries();
+ refreshSummary(mPreference);
+ }
+
+ @Override
+ public void onDefaultSmsChanged(int defaultSmsSubId) {
+ updateEntries();
+ refreshSummary(mPreference);
+ }
}
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index cf78942..4b6a728 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -20,8 +20,6 @@
import static androidx.lifecycle.Lifecycle.Event.ON_STOP;
import android.content.Context;
-import android.os.Handler;
-import android.os.Looper;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@@ -36,13 +34,11 @@
import androidx.preference.SwitchPreference;
import com.android.settings.R;
-import com.android.settings.network.MobileDataContentObserver;
import com.android.settings.network.MobileNetworkRepository;
import com.android.settings.wifi.WifiPickerTrackerHelper;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.mobile.dataservice.MobileNetworkInfoEntity;
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
-import com.android.settingslib.mobile.dataservice.UiccInfoEntity;
import java.util.ArrayList;
import java.util.List;
@@ -234,13 +230,14 @@
public void onActiveSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
mSubscriptionInfoEntityList = subInfoEntityList;
mSubscriptionInfoEntityList.forEach(entity -> {
- if (Integer.parseInt(entity.subId) == mSubId) {
+ if (entity.getSubId() == mSubId) {
mSubscriptionInfoEntity = entity;
}
});
+ int subId = mSubscriptionInfoEntity.getSubId();
if (mSubscriptionInfoEntity != null
- && mSubscriptionInfoEntity.isDefaultDataSubscription) {
- mDefaultSubId = Integer.parseInt(mSubscriptionInfoEntity.subId);
+ && subId == SubscriptionManager.getDefaultDataSubscriptionId()) {
+ mDefaultSubId = subId;
}
update();
refreshSummary(mPreference);
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 265eb16..02455a1 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -1011,7 +1011,7 @@
private static CharSequence getPreferredCallStatus(Context context,
SubscriptionInfoEntity subInfo) {
String status = "";
- if (subInfo.isDefaultVoiceSubscription) {
+ if (subInfo.getSubId() == SubscriptionManager.getDefaultVoiceSubscriptionId()) {
status = setSummaryResId(context, R.string.calls_sms_preferred);
}
@@ -1021,7 +1021,7 @@
private static CharSequence getPreferredSmsStatus(Context context,
SubscriptionInfoEntity subInfo) {
String status = "";
- if (subInfo.isDefaultSmsSubscription) {
+ if (subInfo.getSubId() == SubscriptionManager.getDefaultSmsSubscriptionId()) {
status = setSummaryResId(context, R.string.calls_sms_preferred);
}
diff --git a/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java b/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java
index fddd358..be37513 100644
--- a/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java
+++ b/src/com/android/settings/network/telephony/SmsDefaultSubscriptionController.java
@@ -44,10 +44,12 @@
@Override
protected int getDefaultSubscriptionId() {
+ int defaultSmsSubId = SubscriptionManager.getDefaultSmsSubscriptionId();
for (SubscriptionInfoEntity subInfo : mSubInfoEntityList) {
- if (subInfo.isActiveSubscriptionId && subInfo.isDefaultSmsSubscription) {
+ int subId = subInfo.getSubId();
+ if (subInfo.isActiveSubscriptionId && subId == defaultSmsSubId) {
mSubscriptionInfoEntity = subInfo;
- return Integer.parseInt(subInfo.subId);
+ return subId;
}
}
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index edd9188..2a30b42 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -911,6 +911,10 @@
mIsManagedProfile));
setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE);
mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0));
+
+ // Hide the pin_confirm option when we are just asking user to confirm the pwd.
+ mAutoPinConfirmOption.setVisibility(View.GONE);
+ mAutoConfirmSecurityMessage.setVisibility(View.GONE);
}
final int stage = getStageType();
if (getStageType() != Stage.TYPE_NONE) {
@@ -1017,12 +1021,14 @@
profileCredential);
}
}
- mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
- mChosenPassword, mCurrentCredential, mUserId);
- // update the pin_auto_confirm setting accordingly.
+ // update the setting before triggering the password save workflow,
+ // so that pinLength information is stored accordingly when setting is turned on.
mLockPatternUtils.setAutoPinConfirm(
(mAutoPinConfirmOption != null && mAutoPinConfirmOption.isChecked()),
mUserId);
+
+ mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
+ mChosenPassword, mCurrentCredential, mUserId);
}
@Override
diff --git a/src/com/android/settings/search/SearchResultTrampoline.java b/src/com/android/settings/search/SearchResultTrampoline.java
index bcd8ee0..6ba0338 100644
--- a/src/com/android/settings/search/SearchResultTrampoline.java
+++ b/src/com/android/settings/search/SearchResultTrampoline.java
@@ -102,7 +102,8 @@
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
- if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
+ if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)
+ || ActivityEmbeddingUtils.isAlreadyEmbedded(this)) {
startActivity(intent);
} else if (isSettingsIntelligence(callingActivity)) {
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SETTINGS_SEARCH_ALWAYS_EXPAND)) {
diff --git a/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java b/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
index ff4a8b7..a41a0b2 100644
--- a/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
+++ b/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceController.java
@@ -16,14 +16,19 @@
package com.android.settings.security.screenlock;
+import static com.android.internal.widget.LockPatternUtils.MIN_AUTO_PIN_REQUIREMENT_LENGTH;
+
import android.content.Context;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
/**
* Preference controller for the pin_auto_confirm setting.
@@ -32,21 +37,23 @@
PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
private static final String PREF_KEY_PIN_AUTO_CONFIRM = "auto_pin_confirm";
- private static final long MIN_AUTO_PIN_REQUIREMENT_LENGTH = 6L;
private final int mUserId;
private final LockPatternUtils mLockPatternUtils;
+ private final ObservablePreferenceFragment mParentFragment;
public AutoPinConfirmPreferenceController(Context context, int userId,
- LockPatternUtils lockPatternUtils) {
+ LockPatternUtils lockPatternUtils,
+ ObservablePreferenceFragment parentFragment) {
super(context);
mUserId = userId;
mLockPatternUtils = lockPatternUtils;
+ mParentFragment = parentFragment;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- setPinAutoConfirmSettingState((boolean) newValue);
+ launchPinConfirmActivity((boolean) newValue);
return true;
}
@@ -82,4 +89,18 @@
private void setPinAutoConfirmSettingState(boolean state) {
mLockPatternUtils.setAutoPinConfirm(state, mUserId);
}
+
+ private void launchPinConfirmActivity(boolean newState) {
+ new ChooseLockSettingsHelper.Builder(mParentFragment.getActivity(), mParentFragment)
+ .setUserId(mUserId)
+ .setRequestCode(newState
+ ? ScreenLockSettings.AUTO_PIN_SETTING_ENABLING_REQUEST_CODE
+ : ScreenLockSettings.AUTO_PIN_SETTING_DISABLING_REQUEST_CODE)
+ .setTitle(mContext.getString(R.string.lock_screen_auto_pin_confirm_title))
+ .setDescription(newState
+ ? mContext.getString(R.string.auto_confirm_on_pin_verify_description)
+ : mContext.getString(R.string.auto_confirm_off_pin_verify_description))
+ .setReturnCredentials(true)
+ .show();
+ }
}
diff --git a/src/com/android/settings/security/screenlock/ScreenLockSettings.java b/src/com/android/settings/security/screenlock/ScreenLockSettings.java
index 78edb7f..b2ee76c 100644
--- a/src/com/android/settings/security/screenlock/ScreenLockSettings.java
+++ b/src/com/android/settings/security/screenlock/ScreenLockSettings.java
@@ -16,10 +16,14 @@
package com.android.settings.security.screenlock;
+import android.app.Activity;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.content.Intent;
import android.os.UserHandle;
+import androidx.annotation.Nullable;
+
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -38,6 +42,10 @@
private static final String TAG = "ScreenLockSettings";
private static final int MY_USER_ID = UserHandle.myUserId();
+
+ static final int AUTO_PIN_SETTING_ENABLING_REQUEST_CODE = 111;
+ static final int AUTO_PIN_SETTING_DISABLING_REQUEST_CODE = 112;
+
private LockPatternUtils mLockPatternUtils;
@Override
@@ -79,7 +87,7 @@
controllers.add(new LockAfterTimeoutPreferenceController(
context, MY_USER_ID, lockPatternUtils));
controllers.add(new AutoPinConfirmPreferenceController(
- context, MY_USER_ID, lockPatternUtils));
+ context, MY_USER_ID, lockPatternUtils, parent));
controllers.add(new OwnerInfoPreferenceController(context, parent));
return controllers;
}
@@ -94,4 +102,17 @@
new LockPatternUtils(context));
}
};
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ if (requestCode == AUTO_PIN_SETTING_ENABLING_REQUEST_CODE) {
+ if (resultCode == Activity.RESULT_OK) {
+ mLockPatternUtils.setAutoPinConfirm(/* enabled= */ true, MY_USER_ID);
+ }
+ } else if (requestCode == AUTO_PIN_SETTING_DISABLING_REQUEST_CODE) {
+ if (resultCode == Activity.RESULT_OK) {
+ mLockPatternUtils.setAutoPinConfirm(/* enabled= */ false, MY_USER_ID);
+ }
+ }
+ }
}
diff --git a/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt b/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt
index 450f984..a41a697 100644
--- a/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt
+++ b/src/com/android/settings/spa/app/appinfo/AppDisableButton.kt
@@ -112,11 +112,10 @@
@Composable
private fun confirmDialogPresenter() = rememberAlertDialogPresenter(
confirmButton = AlertDialogButton(
- text = stringResource(R.string.reset_app_preferences_button),
+ text = stringResource(R.string.app_disable_dlg_positive),
onClick = packageInfoPresenter::disable,
),
dismissButton = AlertDialogButton(stringResource(R.string.cancel)),
- title = stringResource(R.string.app_disable_dlg_positive),
text = { Text(stringResource(R.string.app_disable_dlg_text)) },
)
}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
index 56a8373..fc3e6c0 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/stylus/StylusDevicesControllerTest.java
@@ -286,8 +286,8 @@
@Test
public void handwritingPreference_checkedWhenFlagTrue() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
showScreen(mController);
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -297,8 +297,8 @@
@Test
public void handwritingPreference_uncheckedWhenFlagFalse() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
showScreen(mController);
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -308,22 +308,22 @@
@Test
public void handwritingPreference_updatesFlagOnClick() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
showScreen(mController);
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
handwritingPref.performClick();
assertThat(handwritingPref.isChecked()).isEqualTo(true);
- assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
+ assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1)).isEqualTo(1);
}
@Test
public void handwritingPreference_startsHandwritingSettingsOnClickIfChecked() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, 0);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, 0);
showScreen(mController);
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -335,8 +335,8 @@
@Test
public void handwritingPreference_doesNotStartHandwritingSettingsOnClickIfNotChecked() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
showScreen(mController);
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
@@ -350,8 +350,8 @@
public void handwritingPreference_doesNotStartHandwritingSettingsIfNoIntent() {
when(mInputMethodInfo.createStylusHandwritingSettingsActivityIntent())
.thenReturn(null);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, 1);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, 1);
showScreen(mController);
SwitchPreference handwritingPref = (SwitchPreference) mPreferenceContainer.getPreference(1);
diff --git a/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
index 12b5fe9..51b83b3 100644
--- a/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/StylusHandwritingPreferenceControllerTest.java
@@ -63,8 +63,8 @@
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOn() {
mController.onPreferenceChange(mPreference, true /* new value */);
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+ final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
assertThat(mode).isEqualTo(SETTING_VALUE_ON);
}
@@ -73,16 +73,16 @@
public void onPreferenceChange_settingEnabled_stylusHandwritingShouldBeOff() {
mController.onPreferenceChange(mPreference, false /* new value */);
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
+ final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
}
@Test
public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_OFF);
mController.updateState(mPreference);
verify(mPreference).setChecked(false);
@@ -90,22 +90,11 @@
@Test
public void updateState_settingEnabled_preferenceShouldBeChecked() {
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.STYLUS_HANDWRITING_ENABLED, SETTING_VALUE_ON);
mController.updateState(mPreference);
verify(mPreference).setChecked(true);
}
- @Test
- public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
- mController.onDeveloperOptionsSwitchDisabled();
-
- final int mode = Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.STYLUS_HANDWRITING_ENABLED, -1 /* default */);
-
- assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
- verify(mPreference).setChecked(false);
- verify(mPreference).setEnabled(false);
- }
}
diff --git a/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
index d1c21a4..1bf61a4 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/KeyboardSettingsPreferenceControllerTest.java
@@ -18,18 +18,21 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
-import android.app.Activity;
import android.content.Context;
import android.content.Intent;
+import android.hardware.input.InputDeviceIdentifier;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.test.core.app.ApplicationProvider;
+import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import org.junit.Before;
@@ -37,12 +40,14 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
+import java.util.ArrayList;
+import java.util.List;
+
/** Tests for {@link KeyboardSettingsPreferenceController} */
@RunWith(RobolectricTestRunner.class)
public class KeyboardSettingsPreferenceControllerTest {
@@ -53,31 +58,42 @@
private static final String PREFERENCE_KEY = "keyboard_settings";
@Mock
- private Activity mActivity;
- @Mock
private CachedBluetoothDevice mCachedBluetoothDevice;
- @Captor
- private ArgumentCaptor<Intent> mIntentArgumentCaptor;
+ @Mock
+ private InputDeviceIdentifier mInputDeviceIdentifier;
+
private Context mContext;
private KeyboardSettingsPreferenceController mController;
@Before
public void setUp() {
mContext = spy(ApplicationProvider.getApplicationContext());
- mController = new KeyboardSettingsPreferenceController(mContext, PREFERENCE_KEY);
- mController.init(mCachedBluetoothDevice, mActivity);
+ doNothing().when(mContext).startActivity(any());
+ mController = spy(new KeyboardSettingsPreferenceController(mContext, PREFERENCE_KEY));
+ mController.init(mCachedBluetoothDevice);
}
@Test
public void handlePreferenceTreeClick_expected() {
Preference mKeyboardPreference = new Preference(mContext);
mKeyboardPreference.setKey(PREFERENCE_KEY);
+ final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+ String address = "BT_ADDRESS";
+ HardKeyboardDeviceInfo deviceInfo =
+ new HardKeyboardDeviceInfo(
+ "TEST_DEVICE",
+ mInputDeviceIdentifier,
+ "TEST_DEVICE_LABEL",
+ address);
+ List<HardKeyboardDeviceInfo> keyboards = new ArrayList<>();
+ keyboards.add(deviceInfo);
+ when(mController.getHardKeyboardList()).thenReturn(keyboards);
+ when(mCachedBluetoothDevice.getAddress()).thenReturn(address);
mController.handlePreferenceTreeClick(mKeyboardPreference);
- verify(mActivity).startActivityForResult(mIntentArgumentCaptor.capture(), eq(0));
- Intent expectedIntent = mIntentArgumentCaptor.getValue();
- assertThat(expectedIntent.getAction()).isEqualTo(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
+ verify(mContext).startActivity(captor.capture());
+ assertThat(captor.getValue().getAction()).isEqualTo(Settings.ACTION_HARD_KEYBOARD_SETTINGS);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
index 15b2ae9..715913c 100644
--- a/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/screenlock/AutoPinConfirmPreferenceControllerTest.java
@@ -22,7 +22,6 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
@@ -33,6 +32,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
import org.junit.Before;
import org.junit.Test;
@@ -48,6 +48,8 @@
private static final Integer TEST_USER_ID = 1;
@Mock
private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private ObservablePreferenceFragment mParentFragment;
private AutoPinConfirmPreferenceController mController;
private SwitchPreference mPreference;
@@ -56,7 +58,8 @@
MockitoAnnotations.initMocks(this);
Context context = ApplicationProvider.getApplicationContext();
mController =
- new AutoPinConfirmPreferenceController(context, TEST_USER_ID, mLockPatternUtils);
+ new AutoPinConfirmPreferenceController(context, TEST_USER_ID, mLockPatternUtils,
+ mParentFragment);
mPreference = new SwitchPreference(context);
}
@@ -128,12 +131,4 @@
mController.updateState(mPreference);
assertThat(mPreference.isChecked()).isTrue();
}
-
- @Test
- public void onPreferenceChange_shouldUpdatePinAutoConfirmSetting() {
- DeviceConfig.setProperty(NAMESPACE_AUTO_PIN_CONFIRMATION, FLAG_ENABLE_AUTO_PIN_CONFIRMATION,
- "true", /* makeDefault */ false);
- mController.onPreferenceChange(mPreference, /* newValue= */ true);
- verify(mLockPatternUtils).setAutoPinConfirm(true, TEST_USER_ID);
- }
}
diff --git a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
index fb014ca..042c9b6 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
@@ -33,9 +33,11 @@
import android.credentials.CredentialProviderInfo;
import android.net.Uri;
import android.os.Looper;
+import android.os.UserHandle;
import android.provider.Settings;
import androidx.lifecycle.Lifecycle;
+import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
@@ -121,11 +123,42 @@
}
@Test
- public void displayPreference_noServices_noPreferencesAdded() {
+ public void displayPreference_noServices_noPreferencesAdded_useAutofillUri() {
+ Settings.Secure.putStringForUser(
+ mContext.getContentResolver(),
+ Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
+ "test",
+ UserHandle.myUserId());
+
CredentialManagerPreferenceController controller =
createControllerWithServices(Collections.emptyList());
controller.displayPreference(mScreen);
- assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(0);
+ assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+
+ Preference pref = mCredentialsPreferenceCategory.getPreference(0);
+ assertThat(pref.getTitle()).isEqualTo("Add service");
+
+ assertThat(controller.getAddServiceUri(mContext)).isEqualTo("test");
+ }
+
+ @Test
+ public void displayPreference_noServices_noPreferencesAdded_useCredManUri() {
+ Settings.Secure.putStringForUser(
+ mContext.getContentResolver(),
+ Settings.Secure.AUTOFILL_SERVICE_SEARCH_URI,
+ "test",
+ UserHandle.myUserId());
+
+ CredentialManagerPreferenceController controller =
+ createControllerWithServicesAndAddServiceOverride(
+ Collections.emptyList(), "credman");
+ controller.displayPreference(mScreen);
+ assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+
+ Preference pref = mCredentialsPreferenceCategory.getPreference(0);
+ assertThat(pref.getTitle()).isEqualTo("Add service");
+
+ assertThat(controller.getAddServiceUri(mContext)).isEqualTo("credman");
}
@Test
@@ -135,6 +168,9 @@
controller.displayPreference(mScreen);
assertThat(controller.isConnected()).isFalse();
assertThat(mCredentialsPreferenceCategory.getPreferenceCount()).isEqualTo(1);
+
+ Preference pref = mCredentialsPreferenceCategory.getPreference(0);
+ assertThat(pref.getTitle()).isNotEqualTo("Add account");
}
@Test
@@ -317,7 +353,8 @@
Map<String, SwitchPreference> prefs =
controller.buildPreferenceList(mContext, mCredentialsPreferenceCategory);
- assertThat(prefs.keySet()).containsExactly(TEST_PACKAGE_NAME_A, TEST_PACKAGE_NAME_B, TEST_PACKAGE_NAME_C);
+ assertThat(prefs.keySet())
+ .containsExactly(TEST_PACKAGE_NAME_A, TEST_PACKAGE_NAME_B, TEST_PACKAGE_NAME_C);
assertThat(prefs.size()).isEqualTo(3);
assertThat(prefs.containsKey(TEST_PACKAGE_NAME_A)).isTrue();
assertThat(prefs.get(TEST_PACKAGE_NAME_A).getTitle()).isEqualTo(TEST_TITLE_APP_A);
@@ -439,10 +476,15 @@
private CredentialManagerPreferenceController createControllerWithServices(
List<CredentialProviderInfo> availableServices) {
+ return createControllerWithServicesAndAddServiceOverride(availableServices, null);
+ }
+
+ private CredentialManagerPreferenceController createControllerWithServicesAndAddServiceOverride(
+ List<CredentialProviderInfo> availableServices, String addServiceOverride) {
CredentialManagerPreferenceController controller =
new CredentialManagerPreferenceController(
mContext, mCredentialsPreferenceCategory.getKey());
- controller.setAvailableServices(() -> mock(Lifecycle.class), availableServices);
+ controller.setAvailableServices(() -> mock(Lifecycle.class), availableServices, addServiceOverride);
controller.setDelegate(mDelegate);
return controller;
}
diff --git a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
index 8beeffb..4e9339f 100644
--- a/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetPreferenceControllerTest.java
@@ -129,6 +129,8 @@
private class MockInternetPreferenceController extends
com.android.settings.network.InternetPreferenceController {
+
+ private int mDefaultDataSubscriptionId;
public MockInternetPreferenceController(Context context, Lifecycle lifecycle,
LifecycleOwner lifecycleOwner) {
super(context, lifecycle, lifecycleOwner);
@@ -145,18 +147,26 @@
mSubscriptionInfoEntity = list;
}
+ @Override
+ protected int getDefaultDataSubscriptionId() {
+ return mDefaultDataSubscriptionId;
+ }
+
+ public void setDefaultDataSubscriptionId(int subscriptionId) {
+ mDefaultDataSubscriptionId = subscriptionId;
+ }
+
}
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
int carrierId, String displayName, String mcc, String mnc, String countryIso,
int cardId, boolean isVisible, boolean isValid, boolean isActive, boolean isAvailable,
- boolean isDefaultData, boolean isActiveData) {
+ boolean isActiveData) {
return new SubscriptionInfoEntity(subId, slotId, carrierId,
displayName, displayName, 0, mcc, mnc, countryIso, false, cardId,
TelephonyManager.DEFAULT_PORT_INDEX, false, null,
SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, isVisible,
- "1234567890", true, "default", false, isValid, true, isActive, isAvailable, false,
- false, isDefaultData, false, isActiveData);
+ "1234567890", true, false, isValid, true, isActive, isAvailable, isActiveData);
}
@Test
@@ -183,7 +193,7 @@
mController.onResume();
mController.onPause();
- verify(mContext).unregisterReceiver(any(BroadcastReceiver.class));
+ verify(mContext, times(2)).unregisterReceiver(any(BroadcastReceiver.class));
verify(mConnectivityManager, times(2)).unregisterNetworkCallback(
any(ConnectivityManager.NetworkCallback.class));
}
@@ -218,10 +228,11 @@
@Test
public void updateCellularSummary_getActiveSubscriptionInfo_cbrs() {
+ mController.setDefaultDataSubscriptionId(Integer.parseInt(SUB_ID_2));
mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, false, true, true, true, false, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, false, true, true, true, true);
mDefaultDataSubInfo = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, false, true, true, true, true, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, false, true, true, true, false);
mSubscriptionInfoEntityList.add(mActiveSubInfo);
mSubscriptionInfoEntityList.add(mDefaultDataSubInfo);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -231,7 +242,7 @@
assertThat(mPreference.getSummary()).isEqualTo(DISPLAY_NAME_2);
mActiveSubInfo = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, false, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
mSubscriptionInfoEntityList.add(mActiveSubInfo);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
mController.onAvailableSubInfoChanged(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java b/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java
index 007251a..51aecc5 100644
--- a/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkProviderCallsSmsControllerTest.java
@@ -100,6 +100,8 @@
private List<SubscriptionInfoEntity> mSubscriptionInfoEntity;
private boolean mIsInService;
+ private int mDefaultVoiceSubscriptionId;
+ private int mDefaultSmsSubscriptionId;
@Override
protected List<SubscriptionInfoEntity> getSubscriptionInfoList() {
@@ -118,6 +120,24 @@
public void setInService(boolean inService) {
mIsInService = inService;
}
+
+ @Override
+ protected int getDefaultVoiceSubscriptionId() {
+ return mDefaultVoiceSubscriptionId;
+ }
+
+ @Override
+ protected int getDefaultSmsSubscriptionId() {
+ return mDefaultSmsSubscriptionId;
+ }
+
+ public void setDefaultVoiceSubscriptionId(int subscriptionId) {
+ mDefaultVoiceSubscriptionId = subscriptionId;
+ }
+
+ public void setDefaultSmsSubscriptionId(int subscriptionId) {
+ mDefaultSmsSubscriptionId = subscriptionId;
+ }
}
@Before
@@ -163,15 +183,13 @@
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
int carrierId, String displayName, String mcc, String mnc, String countryIso,
- int cardId, boolean isValid, boolean isActive, boolean isAvailable,
- boolean isDefaultCall, boolean isDefaultSms) {
+ int cardId, boolean isValid, boolean isActive, boolean isAvailable) {
return new SubscriptionInfoEntity(subId, slotId, carrierId,
displayName, displayName, 0, mcc, mnc, countryIso, false, cardId,
TelephonyManager.DEFAULT_PORT_INDEX, false, null,
SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
- "1234567890", true, "default", false, isValid,
- true, isActive, isAvailable, isDefaultCall, isDefaultSms, false, false,
- false);
+ "1234567890", true, false, isValid,
+ true, isActive, isAvailable, false);
}
@Test
@@ -181,7 +199,7 @@
mSubInfo1 = setupSubscriptionInfoEntity(INVALID_SUB_ID,
SubscriptionManager.INVALID_SIM_SLOT_INDEX, TelephonyManager.UNKNOWN_CARRIER_ID,
DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1, SUB_COUNTRY_ISO_1,
- TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true, false, false);
+ TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
displayPreferenceWithLifecycle();
@@ -202,9 +220,9 @@
mSubInfo1 = setupSubscriptionInfoEntity(INVALID_SUB_ID,
SubscriptionManager.INVALID_SIM_SLOT_INDEX, TelephonyManager.UNKNOWN_CARRIER_ID,
DISPLAY_NAME_1, SUB_MCC_1, SUB_MNC_1, SUB_COUNTRY_ISO_1,
- TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true, false, false);
+ TelephonyManager.UNINITIALIZED_CARD_ID, false, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -226,7 +244,7 @@
public void getSummary_oneSubscription_returnDisplayName() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, false, false);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
displayPreferenceWithLifecycle();
@@ -239,9 +257,9 @@
public void getSummary_allSubscriptionsHaveNoPreferredStatus_returnDisplayName() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, false, false);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -257,10 +275,13 @@
@UiThreadTest
public void getSummary_oneSubscriptionsIsCallPreferredTwoIsSmsPreferred_returnStatus() {
+ mController.setDefaultVoiceSubscriptionId(Integer.parseInt(SUB_ID_1));
+ mController.setDefaultSmsSubscriptionId(Integer.parseInt(SUB_ID_2));
+
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, false);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, true);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -284,10 +305,13 @@
@UiThreadTest
public void getSummary_oneSubscriptionsIsSmsPreferredTwoIsCallPreferred_returnStatus() {
+ mController.setDefaultSmsSubscriptionId(Integer.parseInt(SUB_ID_1));
+ mController.setDefaultVoiceSubscriptionId(Integer.parseInt(SUB_ID_2));
+
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, false, true);
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, true, false);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 2, 2, DISPLAY_NAME_2, SUB_MCC_2,
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -311,10 +335,13 @@
@UiThreadTest
public void getSummary_oneSubscriptionsIsSmsPreferredAndIsCallPreferred_returnStatus() {
+ mController.setDefaultSmsSubscriptionId(Integer.parseInt(SUB_ID_1));
+ mController.setDefaultVoiceSubscriptionId(Integer.parseInt(SUB_ID_1));
+
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
index 1c4238a..c4e0f64 100644
--- a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
@@ -152,13 +152,11 @@
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
int carrierId, String displayName, String mcc, String mnc, String countryIso,
- int cardId, CharSequence defaultSimConfig, boolean isValid, boolean isActive,
- boolean isAvailable, boolean isDefaultCall, boolean isDefaultSms) {
+ int cardId, boolean isValid, boolean isActive, boolean isAvailable) {
return new SubscriptionInfoEntity(subId, slotId, carrierId, displayName, displayName, 0,
mcc, mnc, countryIso, false, cardId, TelephonyManager.DEFAULT_PORT_INDEX, false,
null, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
- "1234567890", true, defaultSimConfig.toString(), false, isValid, true, isActive,
- isAvailable, isDefaultCall, isDefaultSms, false, false, false);
+ "1234567890", true, false, isValid, true, isActive, isAvailable, false);
}
private String setSummaryResId(String resName, String value) {
@@ -173,7 +171,7 @@
@UiThreadTest
public void getSummary_tapToActivePSim() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, "", true, false, true, false, false);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, false, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
displayPreferenceWithLifecycle();
@@ -186,7 +184,7 @@
@UiThreadTest
public void getSummary_inactivePSim() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, "", true, false, true, false, false);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, false, true);
doReturn(true).when(mSubscriptionManager).canDisablePhysicalSubscription();
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -201,15 +199,13 @@
@UiThreadTest
public void getSummary_defaultCalls() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1,
- setSummaryResId("sim_category_default_active_sim",
- setSummaryResId("default_active_sim_calls")), true, true, true, true,
- false);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
displayPreferenceWithLifecycle();
- CharSequence defaultCall = mSubInfo1.defaultSimConfig;
+ CharSequence defaultCall = SubscriptionUtil.getDefaultSimConfig(mContext,
+ Integer.parseInt(SUB_ID_1));
final StringBuilder summary = new StringBuilder();
summary.append(setSummaryResId("sim_category_active_sim", null))
.append(defaultCall);
@@ -225,14 +221,13 @@
.append(", ")
.append(setSummaryResId("default_active_sim_sms"));
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1,
- setSummaryResId("sim_category_default_active_sim", defaultConfig.toString()), true,
- true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
displayPreferenceWithLifecycle();
- CharSequence defaultCall = mSubInfo1.defaultSimConfig;
+ CharSequence defaultCall = SubscriptionUtil.getDefaultSimConfig(mContext,
+ Integer.parseInt(SUB_ID_1));
final StringBuilder summary = new StringBuilder();
summary.append(setSummaryResId("sim_category_active_sim", null))
.append(defaultCall);
@@ -245,9 +240,9 @@
@UiThreadTest
public void getAvailablePhysicalSubscription_withTwoPhysicalSims_returnTwo() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, "", true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, "", true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
diff --git a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
index ffc9f9b..bbec5bb 100644
--- a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
@@ -135,15 +135,12 @@
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, int slotId,
int carrierId, String displayName, String mcc, String mnc, String countryIso,
- int cardId, boolean isValid, boolean isActive, boolean isAvailable,
- boolean isDefaultCall, boolean isDefaultSms) {
+ int cardId, boolean isValid, boolean isActive, boolean isAvailable) {
return new SubscriptionInfoEntity(subId, slotId, carrierId,
displayName, displayName, 0, mcc, mnc, countryIso, false, cardId,
TelephonyManager.DEFAULT_PORT_INDEX, false, null,
SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
- "1234567890", true, "default", false, isValid,
- true, isActive, isAvailable, isDefaultCall,
- isDefaultSms, false, false, false);
+ "1234567890", true, false, isValid, true, isActive, isAvailable, false);
}
@Test
@@ -164,9 +161,9 @@
@Test
public void onPreferenceChange_prefChangedToSub2_callbackCalledCorrectly() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -181,9 +178,9 @@
@Test
public void onPreferenceChange_prefChangedToAlwaysAsk_callbackCalledCorrectly() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -201,9 +198,9 @@
public void onPreferenceChange_prefBecomesAvailable_onPreferenceChangeCallbackNotNull() {
// Start with only one sub active, so the pref is not available
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
@@ -225,9 +222,9 @@
@Test
public void onSubscriptionsChanged_twoSubscriptionsDefaultChanges_selectedEntryGetsUpdated() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
@@ -246,9 +243,9 @@
@Test
public void onSubscriptionsChanged_goFromTwoSubscriptionsToOne_prefDisappears() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
@@ -273,9 +270,9 @@
@UiThreadTest
public void onSubscriptionsChanged_goFromOneSubscriptionToTwo_prefAppears() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubscriptionInfoEntityList.add(mSubInfo1);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mController.setSubscriptionInfoList(mSubscriptionInfoEntityList);
@@ -297,11 +294,11 @@
@Test
public void onSubscriptionsChanged_goFromTwoToThreeSubscriptions_listGetsUpdated() {
mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, 1, 1, DISPLAY_NAME_1, SUB_MCC_1,
- SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true, true, true);
+ SUB_MNC_1, SUB_COUNTRY_ISO_1, 1, true, true, true);
mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, 1, 1, DISPLAY_NAME_2, SUB_MCC_2,
- SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true, false, false);
+ SUB_MNC_2, SUB_COUNTRY_ISO_2, 1, true, true, true);
mSubInfo3 = setupSubscriptionInfoEntity(SUB_ID_3, 1, 1, DISPLAY_NAME_3, SUB_MCC_3,
- SUB_MNC_3, SUB_COUNTRY_ISO_3, 1, true, true, true, false, false);
+ SUB_MNC_3, SUB_COUNTRY_ISO_3, 1, true, true, true);
mController.setDefaultSubscription(Integer.parseInt(mSubInfo1.subId));
mSubscriptionInfoEntityList.add(mSubInfo1);
mSubscriptionInfoEntityList.add(mSubInfo2);
diff --git a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index 16e3963..0373396 100644
--- a/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -114,15 +114,13 @@
}
private SubscriptionInfoEntity setupSubscriptionInfoEntity(String subId, String displayName,
- boolean isOpportunistic, boolean isValid, boolean isActive, boolean isAvailable,
- boolean isDefaultData) {
+ boolean isOpportunistic, boolean isValid, boolean isActive, boolean isAvailable) {
int id = Integer.parseInt(subId);
return new SubscriptionInfoEntity(subId, id, id,
displayName, displayName, 0, "mcc", "mnc", "countryIso", false, id,
TelephonyManager.DEFAULT_PORT_INDEX, isOpportunistic, null,
SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, displayName, false,
- "1234567890", true, "default", false, isValid, true, isActive, isAvailable, false,
- false, isDefaultData, false, false);
+ "1234567890", true, false, isValid, true, isActive, isAvailable, false);
}
private MobileNetworkInfoEntity setupMobileNetworkInfoEntity(String subId,
@@ -141,8 +139,7 @@
@Test
public void isDialogNeeded_disableSingleSim_returnFalse() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true,
- true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
doReturn(1).when(mTelephonyManager).getActiveModemCount();
@@ -151,14 +148,12 @@
@Test
public void isDialogNeeded_enableNonDefaultSimInMultiSimMode_returnTrue() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true,
- false);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), false);
doReturn(1).when(mTelephonyManager).getActiveModemCount();
// Ideally, it would be better if we could set the default data subscription to
// SUB_ID_OTHER, and set that as an active subscription id.
- mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, false, true, true, true,
- true);
+ mSubInfo2 = setupSubscriptionInfoEntity(SUB_ID_2, DISPLAY_NAME_2, false, true, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
doReturn(2).when(mTelephonyManager).getActiveModemCount();
@@ -180,8 +175,7 @@
@Test
public void onPreferenceChange_singleSim_On_shouldEnableData() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true,
- true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
mController.setSubscriptionInfoEntity(mSubInfo1);
mController.setMobileNetworkInfoEntity(mNetworkInfo1);
@@ -194,8 +188,7 @@
@Test
public void onPreferenceChange_multiSim_On_shouldEnableData() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true,
- true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
mNetworkInfo1 = setupMobileNetworkInfoEntity(String.valueOf(SUB_ID), true);
mController.setSubscriptionInfoEntity(mSubInfo1);
mController.setMobileNetworkInfoEntity(mNetworkInfo1);
@@ -219,8 +212,7 @@
@Test
public void updateState_opportunistic_disabled() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true,
- true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, true, true, true, true);
mController.init(mFragmentManager, SUB_ID, mSubInfo1, mNetworkInfo1);
mController.updateState(mPreference);
@@ -232,8 +224,7 @@
@Test
public void updateState_notOpportunistic_enabled() {
- mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true,
- true);
+ mSubInfo1 = setupSubscriptionInfoEntity(SUB_ID_1, DISPLAY_NAME_1, false, true, true, true);
mController.init(mFragmentManager, SUB_ID, mSubInfo1, mNetworkInfo1);
mController.updateState(mPreference);