Merge "Settings: use framework text colors for SwitchBar"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 55043b0..0766120 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4776,7 +4776,7 @@
<!-- Title for the 'Spell checker for work' preference. [CHAR LIMIT=45] -->
<string name="user_dict_settings_for_work_title">Personal dictionary for work</string>
<!-- User dictionary settings. The summary of the list item to go into the Personal dictionary settings screen. -->
- <string name="user_dict_settings_summary">""</string>
+ <string name="user_dict_settings_summary">Add words to be used in apps such as Spell checker</string>
<!-- User dictionary settings. The title of the menu item to add a new word to the user dictionary. -->
<string name="user_dict_settings_add_menu_title">Add</string>
<!-- User dictionary settings. The title of the dialog to add a new word to the user dictionary. [CHAR LIMIT=25] -->
@@ -12193,4 +12193,17 @@
<!-- Summary for see all preference when bluetooth is disable [CHAR LIMIT=none]-->
<string name="connected_device_see_all_summary">Bluetooth will turn on</string>
+
+ <!-- Bluetooth message permission alert for notification content [CHAR LIMIT=none] -->
+ <string name="bluetooth_message_access_notification_content">Untrusted device wants to access your messages. Tap for details.</string>
+ <!-- Bluetooth message permission alert for dialog title [CHAR LIMIT=none] -->
+ <string name="bluetooth_message_access_dialog_title">Allow access to messages?</string>
+ <!-- Bluetooth message permission alert for dialog content [CHAR LIMIT=none] -->
+ <string name="bluetooth_message_access_dialog_content">An untrusted Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access your messages.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
+ <!-- Bluetooth phonebook permission alert for notification content [CHAR LIMIT=none] -->
+ <string name="bluetooth_phonebook_access_notification_content">Untrusted device wants to access your contacts and call log. Tap for details.</string>
+ <!-- Bluetooth phonebook permission alert for dialog title [CHAR LIMIT=none] -->
+ <string name="bluetooth_phonebook_access_dialog_title">Allow access to contacts and call log?</string>
+ <!-- Bluetooth phonebook permission alert for dialog content [CHAR LIMIT=none] -->
+ <string name="bluetooth_phonebook_access_dialog_content">An untrusted Bluetooth device, <xliff:g id="device_name" example="My device">%1$s</xliff:g>, wants to access your contacts and call log. This includes data about incoming and outgoing calls.\n\nYou haven\u2019t connected to <xliff:g id="device_name" example="My device">%2$s</xliff:g> before.</string>
</resources>
diff --git a/res/xml/device_picker.xml b/res/xml/device_picker.xml
index fd043a2..6f8d267 100644
--- a/res/xml/device_picker.xml
+++ b/res/xml/device_picker.xml
@@ -19,7 +19,8 @@
<com.android.settings.bluetooth.BluetoothProgressCategory
android:key="bt_device_list"
- android:orderingFromXml="false" />
+ android:orderingFromXml="false"
+ android:title="@string/bluetooth_preference_found_media_devices" />
</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 50968d9..699d5f4 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -64,6 +64,7 @@
<Preference
android:key="key_user_dictionary_settings"
android:title="@string/user_dict_settings_title"
+ android:summary="@string/user_dict_settings_summary"
android:fragment="com.android.settings.inputmethod.UserDictionaryList"
settings:controller="com.android.settings.language.UserDictionaryPreferenceController" />
</PreferenceCategory>
diff --git a/src/com/android/settings/SettingsDumpService.java b/src/com/android/settings/SettingsDumpService.java
index a935c18..2a041f3 100644
--- a/src/com/android/settings/SettingsDumpService.java
+++ b/src/com/android/settings/SettingsDumpService.java
@@ -111,9 +111,9 @@
for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) {
telephonyManager = telephonyManager
.createForSubscriptionId(info.getSubscriptionId());
- NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
+ NetworkTemplate carrier = NetworkTemplate.buildTemplateCarrierMetered(
telephonyManager.getSubscriberId());
- final JSONObject usage = dumpDataUsage(mobileAll, controller);
+ final JSONObject usage = dumpDataUsage(carrier, controller);
usage.put("subId", info.getSubscriptionId());
array.put(usage);
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
index be383dc..e40e30d 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -99,9 +99,9 @@
if (mRequestType == BluetoothDevice.REQUEST_TYPE_PROFILE_CONNECTION) {
showDialog(getString(R.string.bluetooth_connection_permission_request), mRequestType);
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
- showDialog(getString(R.string.bluetooth_phonebook_request), mRequestType);
+ showDialog(getString(R.string.bluetooth_phonebook_access_dialog_title), mRequestType);
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
- showDialog(getString(R.string.bluetooth_map_request), mRequestType);
+ showDialog(getString(R.string.bluetooth_message_access_dialog_title), mRequestType);
} else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
showDialog(getString(R.string.bluetooth_sap_request), mRequestType);
}
@@ -136,9 +136,9 @@
p.mView = createSapDialogView();
break;
}
- p.mPositiveButtonText = getString(R.string.yes);
+ p.mPositiveButtonText = getString(R.string.allow);
p.mPositiveButtonListener = this;
- p.mNegativeButtonText = getString(R.string.no);
+ p.mNegativeButtonText = getString(R.string.deny);
p.mNegativeButtonListener = this;
mOkButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
setupAlert();
@@ -168,7 +168,7 @@
String mRemoteName = Utils.createRemoteName(this, mDevice);
mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
messageView = (TextView)mView.findViewById(R.id.message);
- messageView.setText(getString(R.string.bluetooth_pb_acceptance_dialog_text,
+ messageView.setText(getString(R.string.bluetooth_phonebook_access_dialog_content,
mRemoteName, mRemoteName));
return mView;
}
@@ -177,7 +177,7 @@
String mRemoteName = Utils.createRemoteName(this, mDevice);
mView = getLayoutInflater().inflate(R.layout.bluetooth_access, null);
messageView = (TextView)mView.findViewById(R.id.message);
- messageView.setText(getString(R.string.bluetooth_map_acceptance_dialog_text,
+ messageView.setText(getString(R.string.bluetooth_message_access_dialog_content,
mRemoteName, mRemoteName));
return mView;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
index 5fffa3a..177bd89 100644
--- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java
@@ -140,13 +140,13 @@
switch (mRequestType) {
case BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS:
title = context.getString(R.string.bluetooth_phonebook_request);
- message = context.getString(R.string.bluetooth_pb_acceptance_dialog_text,
- deviceAlias, deviceAlias);
+ message = context.getString(
+ R.string.bluetooth_phonebook_access_notification_content);
break;
case BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS:
title = context.getString(R.string.bluetooth_map_request);
- message = context.getString(R.string.bluetooth_map_acceptance_dialog_text,
- deviceAlias, deviceAlias);
+ message = context.getString(
+ R.string.bluetooth_message_access_notification_content);
break;
case BluetoothDevice.REQUEST_TYPE_SIM_ACCESS:
title = context.getString(R.string.bluetooth_sap_request);
@@ -172,6 +172,7 @@
.setContentTitle(title)
.setTicker(message)
.setContentText(message)
+ .setStyle(new Notification.BigTextStyle().bigText(message))
.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
.setAutoCancel(true)
.setPriority(Notification.PRIORITY_MAX)
diff --git a/src/com/android/settings/datausage/lib/DataUsageLib.java b/src/com/android/settings/datausage/lib/DataUsageLib.java
index 786f0ec..93907aa 100644
--- a/src/com/android/settings/datausage/lib/DataUsageLib.java
+++ b/src/com/android/settings/datausage/lib/DataUsageLib.java
@@ -73,7 +73,7 @@
private static NetworkTemplate getMobileTemplateForSubId(
TelephonyManager telephonyManager, int subId) {
- return NetworkTemplate.buildTemplateMobileAll(
+ return NetworkTemplate.buildTemplateCarrierMetered(
telephonyManager.getSubscriberId(subId));
}
}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index 10409fc..4d1fd49 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -538,8 +538,11 @@
voiceNetworkTypeName = getNetworkTypeName(actualVoiceNetworkType);
}
- if (overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE
- || overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA) {
+ final boolean isOverrideNwTypeNrAdvancedOrNsa =
+ overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED
+ || overrideNetworkType == TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA;
+ if (actualDataNetworkType == TelephonyManager.NETWORK_TYPE_LTE
+ && isOverrideNwTypeNrAdvancedOrNsa) {
dataNetworkTypeName = "NR NSA";
}
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 822aad0..442af38 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -15,9 +15,9 @@
*/
package com.android.settings.network;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
@@ -27,7 +27,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.net.ConnectivityManager;
+import android.net.ConnectivitySettingsManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -70,7 +70,7 @@
private static final String TAG = "PrivateDnsModeDialog";
// DNS_MODE -> RadioButton id
- private static final Map<String, Integer> PRIVATE_DNS_MAP;
+ private static final Map<Integer, Integer> PRIVATE_DNS_MAP;
static {
PRIVATE_DNS_MAP = new HashMap<>();
@@ -93,7 +93,7 @@
@VisibleForTesting
RadioGroup mRadioGroup;
@VisibleForTesting
- String mMode;
+ int mMode;
public PrivateDnsModeDialogPreference(Context context) {
super(context);
@@ -160,7 +160,7 @@
final Context context = getContext();
final ContentResolver contentResolver = context.getContentResolver();
- mMode = ConnectivityManager.getPrivateDnsMode(context);
+ mMode = ConnectivitySettingsManager.getPrivateDnsMode(context);
mEditText = view.findViewById(R.id.private_dns_mode_provider_hostname);
mEditText.addTextChangedListener(this);
@@ -189,6 +189,8 @@
if (linkInfo.isActionable()) {
helpTextView.setText(AnnotationSpan.linkify(
context.getText(R.string.private_dns_help_message), linkInfo));
+ } else {
+ helpTextView.setText("");
}
}
@@ -196,15 +198,15 @@
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
final Context context = getContext();
- if (mMode.equals(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME)) {
+ if (mMode == PRIVATE_DNS_MODE_PROVIDER_HOSTNAME) {
// Only clickable if hostname is valid, so we could save it safely
- Settings.Global.putString(context.getContentResolver(), HOSTNAME_KEY,
+ ConnectivitySettingsManager.setPrivateDnsHostname(context,
mEditText.getText().toString());
}
FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context,
SettingsEnums.ACTION_PRIVATE_DNS_MODE, mMode);
- Settings.Global.putString(context.getContentResolver(), MODE_KEY, mMode);
+ ConnectivitySettingsManager.setPrivateDnsMode(context, mMode);
}
}
@@ -264,7 +266,7 @@
}
private void updateDialogInfo() {
- final boolean modeProvider = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME.equals(mMode);
+ final boolean modeProvider = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME == mMode;
if (mEditText != null) {
mEditText.setEnabled(modeProvider);
}
diff --git a/src/com/android/settings/network/PrivateDnsPreferenceController.java b/src/com/android/settings/network/PrivateDnsPreferenceController.java
index 4aa92f4..07d5714 100644
--- a/src/com/android/settings/network/PrivateDnsPreferenceController.java
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -16,9 +16,9 @@
package com.android.settings.network;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.provider.Settings.Global.PRIVATE_DNS_DEFAULT_MODE;
import static android.provider.Settings.Global.PRIVATE_DNS_MODE;
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
@@ -29,6 +29,7 @@
import android.database.ContentObserver;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
+import android.net.ConnectivitySettingsManager;
import android.net.LinkProperties;
import android.net.Network;
import android.net.Uri;
@@ -118,7 +119,7 @@
public CharSequence getSummary() {
final Resources res = mContext.getResources();
final ContentResolver cr = mContext.getContentResolver();
- final String mode = ConnectivityManager.getPrivateDnsMode(mContext);
+ final int mode = ConnectivitySettingsManager.getPrivateDnsMode(mContext);
final LinkProperties lp = mLatestLinkProperties;
final List<InetAddress> dnses = (lp == null) ? null : lp.getValidatedPrivateDnsServers();
final boolean dnsesResolved = !ArrayUtils.isEmpty(dnses);
diff --git a/src/com/android/settings/security/OWNERS b/src/com/android/settings/security/OWNERS
index 6e4f553..701feb8 100644
--- a/src/com/android/settings/security/OWNERS
+++ b/src/com/android/settings/security/OWNERS
@@ -1,7 +1,9 @@
# Enterprise security reviewers
-eranm@google.com
pgrafov@google.com
rubinxu@google.com
# Emergency
sandness@google.com
+
+# Emeritus
+eranm@google.com
diff --git a/src/com/android/settings/security/ResetCredentialsPreferenceController.java b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
index 48e7f84..5234ba8 100644
--- a/src/com/android/settings/security/ResetCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
@@ -18,6 +18,8 @@
import android.content.Context;
import android.os.UserManager;
+import android.security.keystore.KeyProperties;
+import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
import androidx.preference.PreferenceScreen;
@@ -35,6 +37,7 @@
private static final String KEY_RESET_CREDENTIALS = "credentials_reset";
private final KeyStore mKeyStore;
+ private final KeyStore mWifiKeyStore;
private RestrictedPreference mPreference;
@@ -45,8 +48,19 @@
keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
} catch (Exception e) {
+ keyStore = null;
}
mKeyStore = keyStore;
+ keyStore = null;
+ if (context.getUser().isSystem()) {
+ try {
+ keyStore = KeyStore.getInstance("AndroidKeyStore");
+ keyStore.load(new AndroidKeyStoreLoadStoreParameter(KeyProperties.NAMESPACE_WIFI));
+ } catch (Exception e) {
+ keyStore = null;
+ }
+ }
+ mWifiKeyStore = keyStore;
if (lifecycle != null) {
lifecycle.addObserver(this);
}
@@ -68,9 +82,11 @@
if (mPreference != null && !mPreference.isDisabledByAdmin()) {
boolean isEnabled = false;
try {
- if (mKeyStore != null) {
- isEnabled = mKeyStore.aliases().hasMoreElements();
- }
+ isEnabled = (mKeyStore != null
+ && mKeyStore.aliases().hasMoreElements())
+ || (mWifiKeyStore != null
+ && mWifiKeyStore.aliases().hasMoreElements());
+
} catch (KeyStoreException e) {
// If access to keystore fails, treat as disabled.
}
diff --git a/src/com/android/settings/users/EditUserPhotoController.java b/src/com/android/settings/users/EditUserPhotoController.java
index a20513a..60f720e 100644
--- a/src/com/android/settings/users/EditUserPhotoController.java
+++ b/src/com/android/settings/users/EditUserPhotoController.java
@@ -36,6 +36,7 @@
import android.os.UserManager;
import android.provider.ContactsContract.DisplayPhoto;
import android.provider.MediaStore;
+import android.util.EventLog;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
@@ -116,6 +117,14 @@
}
final Uri pictureUri = data != null && data.getData() != null
? data.getData() : mTakePictureUri;
+
+ // Check if the result is a content uri
+ if (!ContentResolver.SCHEME_CONTENT.equals(pictureUri.getScheme())) {
+ Log.e(TAG, "Invalid pictureUri scheme: " + pictureUri.getScheme());
+ EventLog.writeEvent(0x534e4554, "172939189", -1, pictureUri.getPath());
+ return false;
+ }
+
switch (requestCode) {
case REQUEST_CODE_CROP_PHOTO:
onPhotoCropped(pictureUri, true);
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
index 5fd417d..85a67f6 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
@@ -16,10 +16,9 @@
package com.android.settings.network;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
-import static android.provider.Settings.Global.PRIVATE_DNS_MODE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
@@ -28,11 +27,9 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
-import android.net.ConnectivityManager;
-import android.provider.Settings;
+import android.net.ConnectivitySettingsManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@@ -118,10 +115,8 @@
public void testOnBindDialogView_containsCorrectData() {
// Don't set settings to the default value ("opportunistic") as that
// risks masking failure to read the mode from settings.
- Settings.Global.putString(mContext.getContentResolver(),
- PrivateDnsModeDialogPreference.MODE_KEY, PRIVATE_DNS_MODE_OFF);
- Settings.Global.putString(mContext.getContentResolver(),
- PrivateDnsModeDialogPreference.HOSTNAME_KEY, HOST_NAME);
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_OFF);
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, HOST_NAME);
final LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(R.layout.private_dns_mode_dialog,
@@ -159,29 +154,26 @@
@Test
public void testOnClick_positiveButtonClicked_saveData() {
// Set the default settings to OFF
- final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putString(contentResolver, PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_OFF);
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_OFF);
- mPreference.mMode = ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+ mPreference.mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
mPreference.onClick(null, DialogInterface.BUTTON_POSITIVE);
// Change to OPPORTUNISTIC
- assertThat(Settings.Global.getString(contentResolver, PRIVATE_DNS_MODE)).isEqualTo(
+ assertThat(ConnectivitySettingsManager.getPrivateDnsMode(mContext)).isEqualTo(
PRIVATE_DNS_MODE_OPPORTUNISTIC);
}
@Test
public void testOnClick_negativeButtonClicked_doNothing() {
// Set the default settings to OFF
- final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putString(contentResolver, PRIVATE_DNS_MODE, PRIVATE_DNS_MODE_OFF);
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_OFF);
- mPreference.mMode = ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+ mPreference.mMode = PRIVATE_DNS_MODE_OPPORTUNISTIC;
mPreference.onClick(null, DialogInterface.BUTTON_NEGATIVE);
// Still equal to OFF
- assertThat(Settings.Global.getString(contentResolver,
- Settings.Global.PRIVATE_DNS_MODE)).isEqualTo(
- ConnectivityManager.PRIVATE_DNS_MODE_OFF);
+ assertThat(ConnectivitySettingsManager.getPrivateDnsMode(mContext)).isEqualTo(
+ PRIVATE_DNS_MODE_OFF);
}
}
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
index 390a674..e31d959 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
@@ -16,10 +16,9 @@
package com.android.settings.network;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
-import static android.provider.Settings.Global.PRIVATE_DNS_DEFAULT_MODE;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+import static android.net.ConnectivitySettingsManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import static android.provider.Settings.Global.PRIVATE_DNS_MODE;
import static android.provider.Settings.Global.PRIVATE_DNS_SPECIFIER;
@@ -48,6 +47,7 @@
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
+import android.net.ConnectivitySettingsManager;
import android.net.LinkProperties;
import android.net.Network;
import android.os.Handler;
@@ -193,8 +193,8 @@
@Test
public void getSummary_PrivateDnsModeOff() {
- setPrivateDnsMode(PRIVATE_DNS_MODE_OFF);
- setPrivateDnsProviderHostname(HOSTNAME);
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_OFF);
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, HOSTNAME);
mController.updateState(mPreference);
verify(mController, atLeastOnce()).getSummary();
verify(mPreference).setSummary(getResourceString(R.string.private_dns_mode_off));
@@ -203,8 +203,8 @@
@Test
public void getSummary_PrivateDnsModeOpportunistic() {
mLifecycle.handleLifecycleEvent(ON_START);
- setPrivateDnsMode(PRIVATE_DNS_MODE_OPPORTUNISTIC);
- setPrivateDnsProviderHostname(HOSTNAME);
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_OPPORTUNISTIC);
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, HOSTNAME);
mController.updateState(mPreference);
verify(mController, atLeastOnce()).getSummary();
verify(mPreference).setSummary(getResourceString(R.string.private_dns_mode_opportunistic));
@@ -226,8 +226,8 @@
@Test
public void getSummary_PrivateDnsModeProviderHostname() {
mLifecycle.handleLifecycleEvent(ON_START);
- setPrivateDnsMode(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
- setPrivateDnsProviderHostname(HOSTNAME);
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, HOSTNAME);
mController.updateState(mPreference);
verify(mController, atLeastOnce()).getSummary();
verify(mPreference).setSummary(
@@ -252,7 +252,7 @@
public void getSummary_PrivateDnsDefaultMode() {
// Default mode is opportunistic, unless overridden by a Settings push.
setPrivateDnsMode("");
- setPrivateDnsProviderHostname("");
+ ConnectivitySettingsManager.setPrivateDnsHostname(mContext, "");
mController.updateState(mPreference);
verify(mController, atLeastOnce()).getSummary();
verify(mPreference).setSummary(getResourceString(R.string.private_dns_mode_opportunistic));
@@ -260,7 +260,7 @@
reset(mController);
reset(mPreference);
// Pretend an emergency gservices setting has disabled default-opportunistic.
- Settings.Global.putString(mContentResolver, PRIVATE_DNS_DEFAULT_MODE, PRIVATE_DNS_MODE_OFF);
+ ConnectivitySettingsManager.setPrivateDnsDefaultMode(mContext, PRIVATE_DNS_MODE_OFF);
mController.updateState(mPreference);
verify(mController, atLeastOnce()).getSummary();
verify(mPreference).setSummary(getResourceString(R.string.private_dns_mode_off));
@@ -270,7 +270,7 @@
// The user interacting with the Private DNS menu, explicitly choosing
// opportunistic mode, will be able to use despite the change to the
// default setting above.
- setPrivateDnsMode(PRIVATE_DNS_MODE_OPPORTUNISTIC);
+ ConnectivitySettingsManager.setPrivateDnsMode(mContext, PRIVATE_DNS_MODE_OPPORTUNISTIC);
mController.updateState(mPreference);
verify(mController, atLeastOnce()).getSummary();
verify(mPreference).setSummary(getResourceString(R.string.private_dns_mode_opportunistic));
@@ -305,10 +305,6 @@
Settings.Global.putString(mContentResolver, PRIVATE_DNS_MODE, mode);
}
- private void setPrivateDnsProviderHostname(String name) {
- Settings.Global.putString(mContentResolver, PRIVATE_DNS_SPECIFIER, name);
- }
-
private String getResourceString(int which) {
return mContext.getResources().getString(which);
}