Snap for 10035032 from 7b3df1c080 to udc-release
Change-Id: Ie382acdb1fd20bf40ebb52281c2cd577a2316f0d
This commit is contained in:
@@ -35,6 +35,7 @@ import android.hardware.biometrics.BiometricAuthenticator;
|
||||
import android.hardware.biometrics.BiometricManager;
|
||||
import android.hardware.biometrics.BiometricManager.Authenticators;
|
||||
import android.hardware.biometrics.BiometricManager.BiometricError;
|
||||
import android.hardware.biometrics.SensorProperties;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.face.FaceSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
@@ -198,7 +199,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
// Default behavior is to enroll BIOMETRIC_WEAK or above. See ACTION_BIOMETRIC_ENROLL.
|
||||
final int authenticators = getIntent().getIntExtra(
|
||||
EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK);
|
||||
Log.d(TAG, "Authenticators: " + authenticators);
|
||||
Log.d(TAG, "Authenticators: " + BiometricManager.authenticatorToStr(authenticators));
|
||||
|
||||
mParentalOptionsRequired = intent.getBooleanExtra(EXTRA_REQUIRE_PARENTAL_CONSENT, false);
|
||||
mSkipReturnToParent = intent.getBooleanExtra(EXTRA_SKIP_RETURN_TO_PARENT, false);
|
||||
@@ -222,9 +223,16 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
final FaceSensorPropertiesInternal props = faceProperties.get(0);
|
||||
final int maxEnrolls =
|
||||
isSetupWizard ? maxFacesEnrollableIfSUW : props.maxEnrollmentsPerUser;
|
||||
final boolean isFaceStrong =
|
||||
props.sensorStrength == SensorProperties.STRENGTH_STRONG;
|
||||
mIsFaceEnrollable =
|
||||
faceManager.getEnrolledFaces(mUserId).size() < maxEnrolls;
|
||||
|
||||
// If we expect strong bio only, check if face is strong
|
||||
if (authenticators == Authenticators.BIOMETRIC_STRONG && !isFaceStrong) {
|
||||
mIsFaceEnrollable = false;
|
||||
}
|
||||
|
||||
final boolean parentalConsent = isSetupWizard || (mParentalOptionsRequired
|
||||
&& !WizardManagerHelper.isUserSetupComplete(this));
|
||||
if (parentalConsent && isMultiSensor && mIsFaceEnrollable) {
|
||||
@@ -278,6 +286,9 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
|
||||
private void updateFingerprintEnrollable(boolean isSetupWizard) {
|
||||
if (mHasFeatureFingerprint) {
|
||||
final int authenticators = getIntent().getIntExtra(
|
||||
EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK);
|
||||
|
||||
final FingerprintManager fpManager = getSystemService(FingerprintManager.class);
|
||||
final List<FingerprintSensorPropertiesInternal> fpProperties =
|
||||
fpManager.getSensorPropertiesInternal();
|
||||
@@ -287,8 +298,15 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
final int maxEnrolls =
|
||||
isSetupWizard ? maxFingerprintsEnrollableIfSUW
|
||||
: fpProperties.get(0).maxEnrollmentsPerUser;
|
||||
final boolean isFingerprintStrong =
|
||||
fpProperties.get(0).sensorStrength == SensorProperties.STRENGTH_STRONG;
|
||||
mIsFingerprintEnrollable =
|
||||
fpManager.getEnrolledFingerprints(mUserId).size() < maxEnrolls;
|
||||
|
||||
// If we expect strong bio only, check if fingerprint is strong
|
||||
if (authenticators == Authenticators.BIOMETRIC_STRONG && !isFingerprintStrong) {
|
||||
mIsFingerprintEnrollable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,8 +326,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
}
|
||||
}
|
||||
|
||||
boolean canUseFace = mHasFeatureFace;
|
||||
boolean canUseFingerprint = mHasFeatureFingerprint;
|
||||
boolean canUseFace = mIsFaceEnrollable;
|
||||
boolean canUseFingerprint = mIsFingerprintEnrollable;
|
||||
if (mParentalOptionsRequired) {
|
||||
if (mParentalOptions == null) {
|
||||
throw new IllegalStateException("consent options required, but not set");
|
||||
@@ -612,11 +630,11 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
Intent intent = BiometricUtils.getChooseLockIntent(this, getIntent());
|
||||
intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
|
||||
if (mHasFeatureFingerprint && mHasFeatureFace) {
|
||||
if (mIsFingerprintEnrollable && mIsFaceEnrollable) {
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, true);
|
||||
} else if (mHasFeatureFace) {
|
||||
} else if (mIsFaceEnrollable) {
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, true);
|
||||
} else if (mHasFeatureFingerprint) {
|
||||
} else if (mIsFingerprintEnrollable) {
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,18 +16,17 @@
|
||||
|
||||
package com.android.settings.development;
|
||||
|
||||
import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.display.RefreshRateSettingsUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
@@ -35,6 +34,12 @@ import com.android.settingslib.development.DeveloperOptionsPreferenceController;
|
||||
public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPreferenceController
|
||||
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
|
||||
|
||||
@VisibleForTesting
|
||||
static float DEFAULT_REFRESH_RATE = 60f;
|
||||
|
||||
@VisibleForTesting
|
||||
static float NO_CONFIG = 0f;
|
||||
|
||||
@VisibleForTesting
|
||||
float mPeakRefreshRate;
|
||||
|
||||
@@ -43,8 +48,17 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
|
||||
|
||||
public ForcePeakRefreshRatePreferenceController(Context context) {
|
||||
super(context);
|
||||
mPeakRefreshRate =
|
||||
RefreshRateSettingsUtils.findHighestRefreshRateForDefaultDisplay(context);
|
||||
|
||||
final DisplayManager dm = context.getSystemService(DisplayManager.class);
|
||||
final Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);
|
||||
|
||||
if (display == null) {
|
||||
Log.w(TAG, "No valid default display device");
|
||||
mPeakRefreshRate = DEFAULT_REFRESH_RATE;
|
||||
} else {
|
||||
mPeakRefreshRate = findPeakRefreshRate(display.getSupportedModes());
|
||||
}
|
||||
|
||||
Log.d(TAG, "DEFAULT_REFRESH_RATE : " + DEFAULT_REFRESH_RATE
|
||||
+ " mPeakRefreshRate : " + mPeakRefreshRate);
|
||||
}
|
||||
@@ -85,20 +99,34 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchDisabled() {
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
Settings.System.putInt(mContext.getContentResolver(),
|
||||
Settings.System.FORCE_PEAK_REFRESH_RATE, 0);
|
||||
Settings.System.putFloat(mContext.getContentResolver(),
|
||||
Settings.System.MIN_REFRESH_RATE, NO_CONFIG);
|
||||
|
||||
((SwitchPreference) mPreference).setChecked(false);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void forcePeakRefreshRate(boolean enable) {
|
||||
Settings.System.putInt(mContext.getContentResolver(),
|
||||
Settings.System.FORCE_PEAK_REFRESH_RATE, enable ? 1 : 0);
|
||||
final float peakRefreshRate = enable ? mPeakRefreshRate : NO_CONFIG;
|
||||
Settings.System.putFloat(mContext.getContentResolver(),
|
||||
Settings.System.MIN_REFRESH_RATE, peakRefreshRate);
|
||||
}
|
||||
|
||||
boolean isForcePeakRefreshRateEnabled() {
|
||||
return Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.FORCE_PEAK_REFRESH_RATE, 0) == 1;
|
||||
final float peakRefreshRate = Settings.System.getFloat(mContext.getContentResolver(),
|
||||
Settings.System.MIN_REFRESH_RATE, NO_CONFIG);
|
||||
|
||||
return peakRefreshRate >= mPeakRefreshRate;
|
||||
}
|
||||
|
||||
private float findPeakRefreshRate(Display.Mode[] modes) {
|
||||
float peakRefreshRate = DEFAULT_REFRESH_RATE;
|
||||
for (Display.Mode mode : modes) {
|
||||
if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
|
||||
peakRefreshRate = mode.getRefreshRate();
|
||||
}
|
||||
}
|
||||
|
||||
return peakRefreshRate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,6 @@ public class ImeiInfoPreferenceController extends BasePreferenceController {
|
||||
|
||||
@VisibleForTesting
|
||||
protected void updatePreference(Preference preference, int simSlot) {
|
||||
SubscriptionInfo subInfo = getSubscriptionInfo(simSlot);
|
||||
preference.setTitle(getTitle(simSlot));
|
||||
preference.setSummary(getSummary());
|
||||
}
|
||||
|
||||
@@ -16,20 +16,18 @@
|
||||
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Handler;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.display.RefreshRateSettingsUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
@@ -41,6 +39,8 @@ import java.util.concurrent.Executor;
|
||||
public class PeakRefreshRatePreferenceController extends TogglePreferenceController
|
||||
implements LifecycleObserver, OnStart, OnStop {
|
||||
|
||||
@VisibleForTesting static float DEFAULT_REFRESH_RATE = 60f;
|
||||
|
||||
@VisibleForTesting float mPeakRefreshRate;
|
||||
|
||||
private static final String TAG = "RefreshRatePrefCtr";
|
||||
@@ -65,8 +65,17 @@ public class PeakRefreshRatePreferenceController extends TogglePreferenceControl
|
||||
updateState(mPreference);
|
||||
}
|
||||
};
|
||||
mPeakRefreshRate =
|
||||
RefreshRateSettingsUtils.findHighestRefreshRateForDefaultDisplay(context);
|
||||
|
||||
final DisplayManager dm = mContext.getSystemService(DisplayManager.class);
|
||||
final Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);
|
||||
|
||||
if (display == null) {
|
||||
Log.w(TAG, "No valid default display device");
|
||||
mPeakRefreshRate = DEFAULT_REFRESH_RATE;
|
||||
} else {
|
||||
mPeakRefreshRate = findPeakRefreshRate(display.getSupportedModes());
|
||||
}
|
||||
|
||||
Log.d(
|
||||
TAG,
|
||||
"DEFAULT_REFRESH_RATE : "
|
||||
@@ -97,15 +106,21 @@ public class PeakRefreshRatePreferenceController extends TogglePreferenceControl
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.System.getInt(mContext.getContentResolver(), Settings.System.SMOOTH_DISPLAY,
|
||||
0) == 1;
|
||||
final float peakRefreshRate =
|
||||
Settings.System.getFloat(
|
||||
mContext.getContentResolver(),
|
||||
Settings.System.PEAK_REFRESH_RATE,
|
||||
getDefaultPeakRefreshRate());
|
||||
return Math.round(peakRefreshRate) == Math.round(mPeakRefreshRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
Log.d(TAG, "setChecked to : " + isChecked);
|
||||
return Settings.System.putInt(
|
||||
mContext.getContentResolver(), Settings.System.SMOOTH_DISPLAY, isChecked ? 1 : 0);
|
||||
final float peakRefreshRate = isChecked ? mPeakRefreshRate : DEFAULT_REFRESH_RATE;
|
||||
Log.d(TAG, "setChecked to : " + peakRefreshRate);
|
||||
|
||||
return Settings.System.putFloat(
|
||||
mContext.getContentResolver(), Settings.System.PEAK_REFRESH_RATE, peakRefreshRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,6 +138,17 @@ public class PeakRefreshRatePreferenceController extends TogglePreferenceControl
|
||||
mDeviceConfigDisplaySettings.stopListening();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
float findPeakRefreshRate(Display.Mode[] modes) {
|
||||
float peakRefreshRate = DEFAULT_REFRESH_RATE;
|
||||
for (Display.Mode mode : modes) {
|
||||
if (Math.round(mode.getRefreshRate()) > peakRefreshRate) {
|
||||
peakRefreshRate = mode.getRefreshRate();
|
||||
}
|
||||
}
|
||||
return peakRefreshRate;
|
||||
}
|
||||
|
||||
private class DeviceConfigDisplaySettings
|
||||
implements DeviceConfig.OnPropertiesChangedListener, Executor {
|
||||
public void startListening() {
|
||||
@@ -165,4 +191,15 @@ public class PeakRefreshRatePreferenceController extends TogglePreferenceControl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float getDefaultPeakRefreshRate() {
|
||||
float defaultPeakRefreshRate = mDeviceConfigDisplaySettings.getDefaultPeakRefreshRate();
|
||||
if (defaultPeakRefreshRate == INVALIDATE_REFRESH_RATE) {
|
||||
defaultPeakRefreshRate = (float) mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_defaultPeakRefreshRate);
|
||||
}
|
||||
|
||||
Log.d(TAG, "DeviceConfig getDefaultPeakRefreshRate : " + defaultPeakRefreshRate);
|
||||
return defaultPeakRefreshRate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ import com.android.internal.app.LocaleStore;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.RestrictedSettingsFragment;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
/**
|
||||
* Create a dialog for system locale events.
|
||||
@@ -143,6 +145,7 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
|
||||
private final int mDialogType;
|
||||
private final LocaleStore.LocaleInfo mLocaleInfo;
|
||||
private final ResultReceiver mResultReceiver;
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
LocaleDialogController(
|
||||
@NonNull Context context, @NonNull LocaleDialogFragment dialogFragment) {
|
||||
@@ -152,6 +155,8 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
|
||||
mLocaleInfo = (LocaleStore.LocaleInfo) arguments.getSerializable(
|
||||
ARG_TARGET_LOCALE);
|
||||
mResultReceiver = (ResultReceiver) arguments.getParcelable(ARG_RESULT_RECEIVER);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(
|
||||
mContext).getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
LocaleDialogController(@NonNull LocaleDialogFragment dialogFragment) {
|
||||
@@ -163,11 +168,15 @@ public class LocaleDialogFragment extends InstrumentedDialogFragment {
|
||||
if (mResultReceiver != null && mDialogType == DIALOG_CONFIRM_SYSTEM_DEFAULT) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(ARG_DIALOG_TYPE, DIALOG_CONFIRM_SYSTEM_DEFAULT);
|
||||
boolean changed = false;
|
||||
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||
changed = true;
|
||||
mResultReceiver.send(Activity.RESULT_OK, bundle);
|
||||
} else if (which == DialogInterface.BUTTON_NEGATIVE) {
|
||||
mResultReceiver.send(Activity.RESULT_CANCELED, bundle);
|
||||
}
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_CHANGE_LANGUAGE, changed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.localepicker;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
@@ -24,8 +25,10 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
/**
|
||||
@@ -36,8 +39,11 @@ public class LocaleHelperPreferenceController extends AbstractPreferenceControll
|
||||
|
||||
private static final String KEY_FOOTER_LANGUAGE_PICKER = "footer_languages_picker";
|
||||
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
public LocaleHelperPreferenceController(Context context) {
|
||||
super(context);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,6 +78,7 @@ public class LocaleHelperPreferenceController extends AbstractPreferenceControll
|
||||
mContext.getString(R.string.link_locale_picker_footer_learn_more),
|
||||
mContext.getClass().getName());
|
||||
if (intent != null) {
|
||||
mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_LANGUAGES_LEARN_MORE);
|
||||
mContext.startActivity(intent);
|
||||
} else {
|
||||
Log.w(TAG, "HelpIntent is null");
|
||||
|
||||
@@ -18,18 +18,11 @@ package com.android.settings.notification.app;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -123,8 +123,8 @@ class SpaLogData(val id: String, val event: LogEvent,
|
||||
return ElapsedTimeUtils.getElapsedTime(System.currentTimeMillis())
|
||||
}
|
||||
|
||||
//TODO(b/253979024): Will be implemented in subsequent CLs.
|
||||
private fun getPageIdByEntryId(id: String): String {
|
||||
//TODO(b/253979024): Will be implemented in subsequent CLs. Remove @Suppress when done.
|
||||
private fun getPageIdByEntryId(@Suppress("UNUSED_PARAMETER") id: String): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ fun AirplaneModePreference() {
|
||||
}
|
||||
|
||||
private class AirplaneModeController(private val context: Context) : OnAirplaneModeChangedListener {
|
||||
private var airplaneModeEnabler = AirplaneModeEnabler(context, this)!!
|
||||
private var airplaneModeEnabler = AirplaneModeEnabler(context, this)
|
||||
private val _airplaneModeState = MutableLiveData<Boolean>()
|
||||
val airplaneModeState: LiveData<Boolean>
|
||||
get() = _airplaneModeState
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.biometrics;
|
||||
|
||||
import static android.hardware.biometrics.BiometricManager.Authenticators.BIOMETRIC_STRONG;
|
||||
import static android.provider.Settings.ACTION_BIOMETRIC_ENROLL;
|
||||
|
||||
import static androidx.test.espresso.intent.Intents.intended;
|
||||
@@ -33,7 +34,13 @@ import static org.junit.Assume.assumeTrue;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.biometrics.SensorProperties;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.face.FaceSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.test.core.app.ActivityScenario;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -56,6 +63,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@MediumTest
|
||||
public class BiometricEnrollActivityTest {
|
||||
@@ -67,6 +76,8 @@ public class BiometricEnrollActivityTest {
|
||||
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private boolean mHasFace;
|
||||
private boolean mHasFingerprint;
|
||||
private boolean mIsFaceStrong;
|
||||
private boolean mIsFingerprintStrong;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -74,6 +85,28 @@ public class BiometricEnrollActivityTest {
|
||||
final PackageManager pm = mContext.getPackageManager();
|
||||
mHasFingerprint = pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
|
||||
mHasFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE);
|
||||
|
||||
if (mHasFace) {
|
||||
final FaceManager faceManager = mContext.getSystemService(FaceManager.class);
|
||||
final List<FaceSensorPropertiesInternal> faceProperties =
|
||||
faceManager.getSensorPropertiesInternal();
|
||||
if (!faceProperties.isEmpty()) {
|
||||
final FaceSensorPropertiesInternal faceProp = faceProperties.get(0);
|
||||
mIsFaceStrong = faceProp.sensorStrength == SensorProperties.STRENGTH_STRONG;
|
||||
}
|
||||
}
|
||||
|
||||
if (mHasFingerprint) {
|
||||
final FingerprintManager fingerprintManager = mContext.getSystemService(
|
||||
FingerprintManager.class);
|
||||
final List<FingerprintSensorPropertiesInternal> fingerProperties =
|
||||
fingerprintManager.getSensorPropertiesInternal();
|
||||
if (!fingerProperties.isEmpty()) {
|
||||
final FingerprintSensorPropertiesInternal fingerProp = fingerProperties.get(0);
|
||||
mIsFingerprintStrong =
|
||||
fingerProp.sensorStrength == SensorProperties.STRENGTH_STRONG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -129,6 +162,27 @@ public class BiometricEnrollActivityTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchWithStrongBiometricAllowed_doNotEnrollWeak() throws Exception {
|
||||
assumeTrue(mHasFace || mHasFingerprint);
|
||||
|
||||
// Allow only strong biometrics
|
||||
Intent intent = getIntent();
|
||||
intent.putExtra(Settings.EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, BIOMETRIC_STRONG);
|
||||
|
||||
try (ActivityScenario<BiometricEnrollActivity> scenario =
|
||||
ActivityScenario.launch(intent)) {
|
||||
intended(hasComponent(ChooseLockGeneric.class.getName()));
|
||||
if (mIsFaceStrong && mIsFingerprintStrong) {
|
||||
intended(hasExtra(EXTRA_KEY_FOR_BIOMETRICS, true));
|
||||
} else if (mIsFaceStrong) {
|
||||
intended(hasExtra(EXTRA_KEY_FOR_FACE, true));
|
||||
} else if (mIsFingerprintStrong) {
|
||||
intended(hasExtra(EXTRA_KEY_FOR_FINGERPRINT, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Intent getIntent() {
|
||||
return getIntent(false /* useInternal */);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.settings.development;
|
||||
|
||||
import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
|
||||
|
||||
import static com.android.settings.development.ForcePeakRefreshRatePreferenceController.DEFAULT_REFRESH_RATE;
|
||||
import static com.android.settings.development.ForcePeakRefreshRatePreferenceController.NO_CONFIG;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -38,6 +38,8 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class ForcePeakRefreshRatePreferenceControllerTest {
|
||||
|
||||
@@ -61,18 +63,22 @@ public class ForcePeakRefreshRatePreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_preferenceChecked_shouldEnableForcePeak() {
|
||||
mController.mPeakRefreshRate = 88f;
|
||||
|
||||
mController.onPreferenceChange(mPreference, true);
|
||||
|
||||
assertThat(Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.FORCE_PEAK_REFRESH_RATE, -1)).isEqualTo(1);
|
||||
assertThat(Settings.System.getFloat(mContext.getContentResolver(),
|
||||
Settings.System.MIN_REFRESH_RATE, NO_CONFIG)).isEqualTo(88f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_preferenceUnchecked_shouldDisableForcePeak() {
|
||||
mController.mPeakRefreshRate = 88f;
|
||||
|
||||
mController.onPreferenceChange(mPreference, false);
|
||||
|
||||
assertThat(Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.FORCE_PEAK_REFRESH_RATE, -1)).isEqualTo(0);
|
||||
assertThat(Settings.System.getFloat(mContext.getContentResolver(),
|
||||
Settings.System.MIN_REFRESH_RATE, NO_CONFIG)).isEqualTo(NO_CONFIG);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,8 +125,8 @@ public class ForcePeakRefreshRatePreferenceControllerTest {
|
||||
public void onDeveloperOptionsDisabled_shouldDisablePreference() {
|
||||
mController.onDeveloperOptionsSwitchDisabled();
|
||||
|
||||
assertThat(Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.FORCE_PEAK_REFRESH_RATE, -1)).isEqualTo(0);
|
||||
assertThat(Settings.System.getFloat(mContext.getContentResolver(),
|
||||
Settings.System.MIN_REFRESH_RATE, -1f)).isEqualTo(NO_CONFIG);
|
||||
assertThat(mPreference.isChecked()).isFalse();
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package com.android.settings.development.qstile;
|
||||
|
||||
import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace
|
||||
.SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE;
|
||||
import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace
|
||||
.SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE;
|
||||
import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace.SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE;
|
||||
import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace.SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -37,6 +35,8 @@ import android.os.RemoteException;
|
||||
import android.view.IWindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.internal.inputmethod.ImeTracing;
|
||||
import com.android.settings.testutils.shadow.ShadowParcel;
|
||||
|
||||
@@ -68,6 +68,9 @@ public class WinscopeTraceTest {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mWinscopeTrace = spy(new DevelopmentTiles.WinscopeTrace());
|
||||
doReturn(ApplicationProvider.getApplicationContext()).when(
|
||||
mWinscopeTrace).getApplicationContext();
|
||||
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mWindowManager", mWindowManager);
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mImeTracing", mImeTracing);
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mSurfaceFlinger", mSurfaceFlinger);
|
||||
@@ -118,7 +121,7 @@ public class WinscopeTraceTest {
|
||||
assertThat(mWinscopeTrace.isEnabled()).isFalse();
|
||||
verify(mSurfaceFlinger)
|
||||
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
|
||||
eq(0 /* flags */));
|
||||
eq(0 /* flags */));
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
}
|
||||
|
||||
@@ -131,7 +134,7 @@ public class WinscopeTraceTest {
|
||||
assertThat(mWinscopeTrace.isEnabled()).isTrue();
|
||||
verify(mSurfaceFlinger)
|
||||
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
|
||||
eq(0 /* flags */));
|
||||
eq(0 /* flags */));
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,14 @@ package com.android.settings.deviceinfo.imei;
|
||||
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
|
||||
import static android.telephony.TelephonyManager.PHONE_TYPE_GSM;
|
||||
import static android.telephony.TelephonyManager.PHONE_TYPE_NONE;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -32,13 +35,16 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.deviceinfo.simstatus.SlotSimStatus;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -119,13 +125,13 @@ public class ImeiInfoPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updatePreference_simSlotWithoutSim_shouldBeEnabled() {
|
||||
public void updatePreference_simSlotWithoutSim_notSetEnabled() {
|
||||
mSecondController = createPreferenceController(null,
|
||||
"imei_info2", mSecondSimPreference, PHONE_TYPE_NONE);
|
||||
|
||||
mSecondController.updatePreference(mSecondSimPreference, -1);
|
||||
|
||||
assertThat(mSecondSimPreference.isEnabled()).isTrue();
|
||||
verify(mSecondSimPreference, never()).setEnabled(anyBoolean());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.settings.display;
|
||||
|
||||
import static android.provider.Settings.Secure.DEVICE_STATE_ROTATION_LOCK_LOCKED;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -39,6 +41,10 @@ import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class DeviceStateAutoRotateDetailsFragmentTest {
|
||||
private static final int FOLDED_STATE = 0;
|
||||
private static final int HALF_FOLDED_STATE = 1;
|
||||
private static final int UNFOLDED_STATE = 2;
|
||||
private static final int REAR_DISPLAY_STATE = 3;
|
||||
|
||||
private final DeviceStateAutoRotateDetailsFragment mFragment =
|
||||
spy(new DeviceStateAutoRotateDetailsFragment());
|
||||
@@ -51,6 +57,7 @@ public class DeviceStateAutoRotateDetailsFragmentTest {
|
||||
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||
when(mFragment.getContext()).thenReturn(mContext);
|
||||
when(mFragment.getResources()).thenReturn(mResources);
|
||||
setUpPostureMappings();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +74,9 @@ public class DeviceStateAutoRotateDetailsFragmentTest {
|
||||
|
||||
@Test
|
||||
public void createPreferenceControllers_settableDeviceStates_returnsDeviceStateControllers() {
|
||||
enableDeviceStateSettableRotationStates(new String[]{"0:1", "1:1"},
|
||||
enableDeviceStateSettableRotationStates(
|
||||
new String[]{FOLDED_STATE + ":" + DEVICE_STATE_ROTATION_LOCK_LOCKED,
|
||||
UNFOLDED_STATE + ":" + DEVICE_STATE_ROTATION_LOCK_LOCKED},
|
||||
new String[]{"Folded", "Unfolded"});
|
||||
|
||||
List<AbstractPreferenceController> preferenceControllers =
|
||||
@@ -102,4 +111,19 @@ public class DeviceStateAutoRotateDetailsFragmentTest {
|
||||
DeviceStateRotationLockSettingsManager.getInstance(mContext)
|
||||
.resetStateForTesting(mResources);
|
||||
}
|
||||
|
||||
private void setUpPostureMappings() {
|
||||
when(mResources.getIntArray(
|
||||
com.android.internal.R.array.config_foldedDeviceStates)).thenReturn(
|
||||
new int[]{FOLDED_STATE});
|
||||
when(mResources.getIntArray(
|
||||
com.android.internal.R.array.config_halfFoldedDeviceStates)).thenReturn(
|
||||
new int[]{HALF_FOLDED_STATE});
|
||||
when(mResources.getIntArray(
|
||||
com.android.internal.R.array.config_openDeviceStates)).thenReturn(
|
||||
new int[]{UNFOLDED_STATE});
|
||||
when(mResources.getIntArray(
|
||||
com.android.internal.R.array.config_rearDisplayDeviceStates)).thenReturn(
|
||||
new int[]{REAR_DISPLAY_STATE});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,15 @@
|
||||
|
||||
package com.android.settings.display;
|
||||
|
||||
import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
import static com.android.settings.display.PeakRefreshRatePreferenceController.DEFAULT_REFRESH_RATE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.view.Display;
|
||||
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
@@ -69,21 +70,23 @@ public class PeakRefreshRatePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_enableSmoothDisplay() {
|
||||
public void setChecked_enableSmoothDisplay_setCurrentRefreshRate() {
|
||||
mController.mPeakRefreshRate = 88f;
|
||||
mController.setChecked(true);
|
||||
|
||||
assertThat(Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.SMOOTH_DISPLAY, -1))
|
||||
.isEqualTo(1);
|
||||
assertThat(Settings.System.getFloat(mContext.getContentResolver(),
|
||||
Settings.System.PEAK_REFRESH_RATE, DEFAULT_REFRESH_RATE))
|
||||
.isEqualTo(88.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_disableSmoothDisplay() {
|
||||
public void setChecked_disableSmoothDisplay_setDefaultRefreshRate() {
|
||||
mController.mPeakRefreshRate = 88f;
|
||||
mController.setChecked(false);
|
||||
|
||||
assertThat(Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.SMOOTH_DISPLAY, -1))
|
||||
.isEqualTo(0);
|
||||
assertThat(Settings.System.getFloat(mContext.getContentResolver(),
|
||||
Settings.System.PEAK_REFRESH_RATE, DEFAULT_REFRESH_RATE))
|
||||
.isEqualTo(DEFAULT_REFRESH_RATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,21 +103,36 @@ public class PeakRefreshRatePreferenceControllerTest {
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findPeakRefreshRate_moreThanOneHigherThanDefault() {
|
||||
Display.Mode lower = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE - 1);
|
||||
Display.Mode def = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE);
|
||||
Display.Mode higher = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 1);
|
||||
Display.Mode higher1 = new Display.Mode(0, 0, 0, DEFAULT_REFRESH_RATE + 2);
|
||||
|
||||
assertThat(mController.findPeakRefreshRate(
|
||||
new Display.Mode[] {lower, def, higher, higher1}))
|
||||
.isEqualTo(DEFAULT_REFRESH_RATE + 2);
|
||||
assertThat(mController.findPeakRefreshRate(
|
||||
new Display.Mode[] {lower, def, higher1, higher}))
|
||||
.isEqualTo(DEFAULT_REFRESH_RATE + 2);
|
||||
}
|
||||
|
||||
private void enableSmoothDisplayPreference() {
|
||||
mController.mPeakRefreshRate = 88f;
|
||||
|
||||
Settings.System.putInt(
|
||||
Settings.System.putFloat(
|
||||
mContext.getContentResolver(),
|
||||
Settings.System.SMOOTH_DISPLAY,
|
||||
1);
|
||||
Settings.System.PEAK_REFRESH_RATE,
|
||||
mController.mPeakRefreshRate);
|
||||
}
|
||||
|
||||
private void disableSmoothDisplayPreference() {
|
||||
mController.mPeakRefreshRate = 88f;
|
||||
|
||||
Settings.System.putInt(
|
||||
Settings.System.putFloat(
|
||||
mContext.getContentResolver(),
|
||||
Settings.System.SMOOTH_DISPLAY,
|
||||
0);
|
||||
Settings.System.PEAK_REFRESH_RATE,
|
||||
DEFAULT_REFRESH_RATE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = ShadowSensorPrivacyManager.class)
|
||||
@@ -171,16 +172,14 @@ public class SmartAutoRotateControllerTest {
|
||||
}
|
||||
|
||||
private void lockDeviceStateRotation() {
|
||||
mDeviceStateAutoRotateSettingsManager.updateSetting(
|
||||
/* deviceState= */0, /* rotationLocked= */ true);
|
||||
mDeviceStateAutoRotateSettingsManager.updateSetting(
|
||||
/* deviceState= */1, /* rotationLocked= */ true);
|
||||
ShadowDeviceStateRotationLockSettingsManager shadowManager =
|
||||
Shadow.extract(mDeviceStateAutoRotateSettingsManager);
|
||||
shadowManager.setRotationLockedForAllStates(true);
|
||||
}
|
||||
|
||||
private void unlockDeviceStateRotation() {
|
||||
mDeviceStateAutoRotateSettingsManager.updateSetting(
|
||||
/* deviceState= */0, /* rotationLocked= */ false);
|
||||
mDeviceStateAutoRotateSettingsManager.updateSetting(
|
||||
/* deviceState= */1, /* rotationLocked= */ true);
|
||||
ShadowDeviceStateRotationLockSettingsManager shadowManager =
|
||||
Shadow.extract(mDeviceStateAutoRotateSettingsManager);
|
||||
shadowManager.setRotationLockedForAllStates(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.robolectric.annotation.Implements;
|
||||
public class ShadowDeviceStateRotationLockSettingsManager {
|
||||
|
||||
private static boolean sDeviceStateRotationLockEnabled;
|
||||
private boolean mIsRotationLockedForAllStates;
|
||||
|
||||
@Implementation
|
||||
public static boolean isDeviceStateRotationLockEnabled(Context context) {
|
||||
@@ -36,4 +37,13 @@ public class ShadowDeviceStateRotationLockSettingsManager {
|
||||
public static void setDeviceStateRotationLockEnabled(boolean enabled) {
|
||||
sDeviceStateRotationLockEnabled = enabled;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public boolean isRotationLockedForAllStates() {
|
||||
return mIsRotationLockedForAllStates;
|
||||
}
|
||||
|
||||
public void setRotationLockedForAllStates(boolean value) {
|
||||
mIsRotationLockedForAllStates = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import androidx.test.annotation.UiThreadTest;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.internal.app.LocaleStore;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.ResourcesUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -55,11 +56,13 @@ public class LocaleDialogFragmentTest {
|
||||
|
||||
private Context mContext;
|
||||
private LocaleDialogFragment mDialogFragment;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mDialogFragment = new LocaleDialogFragment();
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
}
|
||||
|
||||
private void setArgument(
|
||||
@@ -112,6 +115,8 @@ public class LocaleDialogFragmentTest {
|
||||
controller.onClick(null, DialogInterface.BUTTON_POSITIVE);
|
||||
|
||||
verify(resultReceiver).send(eq(Activity.RESULT_OK), any());
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(
|
||||
mContext, SettingsEnums.ACTION_CHANGE_LANGUAGE, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,6 +129,8 @@ public class LocaleDialogFragmentTest {
|
||||
controller.onClick(null, DialogInterface.BUTTON_NEGATIVE);
|
||||
|
||||
verify(resultReceiver).send(eq(Activity.RESULT_CANCELED), any());
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(
|
||||
mContext, SettingsEnums.ACTION_CHANGE_LANGUAGE, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,12 +19,14 @@ package com.android.settings.localepicker;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -37,6 +39,7 @@ import org.mockito.MockitoAnnotations;
|
||||
public class LocaleHelperPreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private LocaleHelperPreferenceController mLocaleHelperPreferenceController;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
|
||||
@Mock
|
||||
private FooterPreference mMockFooterPreference;
|
||||
@@ -49,11 +52,16 @@ public class LocaleHelperPreferenceControllerTest {
|
||||
}
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mLocaleHelperPreferenceController = new LocaleHelperPreferenceController(mContext);
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateFooterPreference_setFooterPreference_hasClickAction() {
|
||||
mLocaleHelperPreferenceController.updateFooterPreference(mMockFooterPreference);
|
||||
verify(mMockFooterPreference).setLearnMoreText(anyString());
|
||||
mMockFooterPreference.setLearnMoreAction(v -> {
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(
|
||||
mContext, SettingsEnums.ACTION_LANGUAGES_LEARN_MORE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user