Merge "[Settings] Remove the intent receiver due to the register exception" 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/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/appinfo/AppLocaleDetails.java b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
index 1a7793e..6144a73 100644
--- a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
+++ b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
@@ -213,7 +213,7 @@
if (appLocale == null) {
return context.getString(R.string.preference_of_system_locale_summary);
} else {
- return LocaleHelper.getDisplayName(appLocale, appLocale, true);
+ return LocaleHelper.getDisplayName(appLocale.stripExtensions(), appLocale, true);
}
}
}
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/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
index e2045f8..563c010 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java
@@ -452,6 +452,7 @@
item.registerCallback(this);
}
mProfileManager.addServiceListener(this);
+ refresh();
}
@Override
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/MobileNetworkRepository.java b/src/com/android/settings/network/MobileNetworkRepository.java
index 8543056..170d921 100644
--- a/src/com/android/settings/network/MobileNetworkRepository.java
+++ b/src/com/android/settings/network/MobileNetworkRepository.java
@@ -34,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;
@@ -714,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/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/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;
}