Merge "Fix Data Saver page crashed when rotate" into udc-dev
diff --git a/res/layout-land/confirm_lock_pattern_normal_base.xml b/res/layout-land/confirm_lock_pattern_normal_base.xml
index 18fb142..812aecd 100644
--- a/res/layout-land/confirm_lock_pattern_normal_base.xml
+++ b/res/layout-land/confirm_lock_pattern_normal_base.xml
@@ -66,6 +66,7 @@
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:minHeight="48dp"
android:layout_marginStart="?attr/sudMarginStart"
android:layout_marginEnd="?attr/sudMarginEnd"
android:layout_marginTop="12dp"
diff --git a/res/layout/accessibility_launch_activity_preference.xml b/res/layout/accessibility_launch_activity_preference.xml
index 5ec6bea..6791206 100644
--- a/res/layout/accessibility_launch_activity_preference.xml
+++ b/res/layout/accessibility_launch_activity_preference.xml
@@ -34,7 +34,7 @@
<TextView
android:id="@android:id/title"
android:layout_height="wrap_content"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:paddingVertical="@dimen/settingslib_switch_title_margin"
android:ellipsize="end"
diff --git a/res/layout/confirm_lock_password_normal.xml b/res/layout/confirm_lock_password_normal.xml
index d4cc332..a0ad47e 100644
--- a/res/layout/confirm_lock_password_normal.xml
+++ b/res/layout/confirm_lock_password_normal.xml
@@ -71,6 +71,7 @@
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:minHeight="48dp"
android:layout_marginStart="?attr/sudMarginStart"
android:layout_marginEnd="?attr/sudMarginEnd"
android:layout_marginTop="12dp"
diff --git a/res/layout/confirm_lock_pattern_normal_base.xml b/res/layout/confirm_lock_pattern_normal_base.xml
index 51bab67..7997ca7 100644
--- a/res/layout/confirm_lock_pattern_normal_base.xml
+++ b/res/layout/confirm_lock_pattern_normal_base.xml
@@ -67,6 +67,7 @@
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:minHeight="48dp"
android:layout_marginStart="?attr/sudMarginStart"
android:layout_marginEnd="?attr/sudMarginEnd"
android:layout_marginTop="12dp"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b38552f..5d4487c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -361,7 +361,7 @@
<string name="desc_app_locale_disclaimer">Language may differ from languages available in the app. Some apps may not support this setting.</string>
<!-- Description for introduction of the locale selection supported of app list [CHAR LIMIT=NONE]-->
- <string name="desc_app_locale_selection_supported">Only apps that support language selection are shown here.</string>
+ <string name="desc_app_locale_selection_supported">Set the language for each app.</string>
<!-- Description for the introduction to language picker activity. [CHAR LIMIT=NONE]-->
<string name="desc_introduction_of_language_picker">Your system, apps, and websites use the first supported language from your preferred languages.</string>
@@ -5164,7 +5164,7 @@
<!-- Title when early heads up is solved [CHAR LIMIT=NONE] -->
<string name="battery_tip_early_heads_up_done_title">Battery Saver on</string>
<!-- Accessibility description for battery saver learn more link [CHAR LIMIT=NONE] -->
- <string name="battery_saver_link_a11y">Learn more about Battery saver</string>
+ <string name="battery_saver_link_a11y">Learn more about Battery Saver</string>
<!-- Summary when early heads up is solved [CHAR LIMIT=NONE] -->
<string name="battery_tip_early_heads_up_done_summary">Some features may be limited</string>
<!-- Title for the battery high usage tip [CHAR LIMIT=NONE] -->
@@ -5472,9 +5472,9 @@
<!-- [CHAR_LIMIT=NONE] Device screen on time category for a selected slot -->
<string name="screen_time_category_for_slot">Screen time for <xliff:g id="slot">%s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] The spinner item text in the battery usage breakdown. -->
- <string name="battery_usage_spinner_by_apps">By apps</string>
+ <string name="battery_usage_spinner_view_by_apps">View by apps</string>
<!-- [CHAR_LIMIT=NONE] The spinner item text in the battery usage breakdown. -->
- <string name="battery_usage_spinner_by_systems">By systems</string>
+ <string name="battery_usage_spinner_view_by_systems">View by systems</string>
<!-- [CHAR_LIMIT=NONE] Less than some percentage, e.g. < 1% -->
<string name="battery_usage_less_than_percent">< <xliff:g id="percentage">%1$s</xliff:g></string>
<!-- Process Stats strings -->
@@ -9139,13 +9139,13 @@
<string name="filter_manage_external_storage">Can access all files</string>
<!-- Manage full screen intent permission title [CHAR LIMIT=40] -->
- <string name="full_screen_intent_title">Show full screen notifications</string>
+ <string name="full_screen_intent_title">Full screen notifications</string>
<!-- Label for setting that allows apps to send full screen intents. [CHAR LIMIT=NONE] -->
- <string name="permit_full_screen_intent">Allow app to show full screen notifications when the device is locked</string>
+ <string name="permit_full_screen_intent">Allow full screen notifications from this app</string>
<!-- Description for setting that allows apps to send full screen intents. [CHAR LIMIT=NONE] -->
- <string name="footer_description_full_screen_intent">Allow the app to show notifications that take up the full screen when the device is locked. Apps may use these to highlight alarms, incoming calls, or other urgent notifications.</string>
+ <string name="footer_description_full_screen_intent">Allow this app to show notifications that take up the full screen when the device is locked. Apps may use these to highlight alarms, incoming calls, or other urgent notifications.</string>
<!-- Media management apps settings title [CHAR LIMIT=40] -->
<string name="media_management_apps_title">Media management apps</string>
@@ -10440,6 +10440,13 @@
<item>@string/graphics_driver_app_preference_system</item>
</string-array>
+ <!-- Debugging developer settings: enable angle as system driver? [CHAR LIMIT=50] -->
+ <string name="enable_angle_as_system_driver">Enable ANGLE</string>
+ <!-- Debugging developer settings: enable angle as system driver summary [CHAR LIMIT=NONE] -->
+ <string name="enable_angle_as_system_driver_summary">Enable ANGLE as system OpenGL ES driver</string>
+ <!--Dialog body text used to explain a reboot is required after changing ANGLE as system GLES driver setting-->
+ <string name="reboot_dialog_enable_angle_as_system_driver">A reboot is required to change the system OpenGL ES driver</string>
+
<!-- Title for App Compatibility Changes dashboard where developers can configure per-app overrides for compatibility changes [CHAR LIMIT=50] -->
<string name="platform_compat_dashboard_title">App Compatibility Changes</string>
<!-- Summary for App Compatibility Changes dashboard [CHAR LIMIT=NONE] -->
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index b5ce57e..eb17fbf 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -243,6 +243,11 @@
android:title="@string/enable_gpu_debug_layers"
android:summary="@string/enable_gpu_debug_layers_summary" />
+ <SwitchPreference
+ android:key="enable_angle_as_system_driver"
+ android:title="@string/enable_angle_as_system_driver"
+ android:summary="@string/enable_angle_as_system_driver_summary" />
+
<Preference
android:key="graphics_driver_dashboard"
android:title="@string/graphics_driver_dashboard_title"
diff --git a/src/com/android/settings/applications/AppStateLocaleBridge.java b/src/com/android/settings/applications/AppStateLocaleBridge.java
index 2fea004..a50d617 100644
--- a/src/com/android/settings/applications/AppStateLocaleBridge.java
+++ b/src/com/android/settings/applications/AppStateLocaleBridge.java
@@ -83,7 +83,7 @@
Log.d(TAG, "[" + entry.info.packageName + "]" + " has No extra info.");
return false;
}
- return (Boolean) entry.extraInfo;
+ return entry.extraInfo == Boolean.TRUE;
}
};
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index c627df3..f19fb91 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -23,6 +23,7 @@
import android.app.Activity;
import android.app.Dialog;
import android.content.ComponentName;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -33,9 +34,11 @@
import android.credentials.CredentialManager;
import android.credentials.CredentialProviderInfo;
import android.credentials.SetEnabledProvidersException;
+import android.database.ContentObserver;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
import android.os.OutcomeReceiver;
import android.os.UserHandle;
import android.provider.DeviceConfig;
@@ -59,10 +62,12 @@
import androidx.preference.SwitchPreference;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.content.PackageMonitor;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settingslib.utils.ThreadUtils;
import java.util.ArrayList;
import java.util.HashMap;
@@ -89,10 +94,12 @@
private final Executor mExecutor;
private final Map<String, SwitchPreference> mPrefs = new HashMap<>(); // key is package name
private final List<ServiceInfo> mPendingServiceInfos = new ArrayList<>();
+ private final Handler mHandler = new Handler();
private @Nullable FragmentManager mFragmentManager = null;
private @Nullable Delegate mDelegate = null;
private @Nullable String mFlagOverrideForTest = null;
+ private @Nullable PreferenceScreen mPreferenceScreen = null;
public CredentialManagerPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
@@ -103,6 +110,7 @@
mExecutor = ContextCompat.getMainExecutor(mContext);
mCredentialManager =
getCredentialManager(context, preferenceKey.equals("credentials_test"));
+ new SettingContentObserver(mHandler).register(context.getContentResolver());
}
private @Nullable CredentialManager getCredentialManager(Context context, boolean isTest) {
@@ -241,6 +249,25 @@
update();
}
+ private void update() {
+ if (mCredentialManager == null) {
+ return;
+ }
+
+ setAvailableServices(
+ mCredentialManager.getCredentialProviderServices(
+ getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
+ null);
+ }
+
+ private void updateFromExternal() {
+ update();
+
+ if (mPreferenceScreen != null) {
+ displayPreference(mPreferenceScreen);
+ }
+ }
+
@VisibleForTesting
void setAvailableServices(
List<CredentialProviderInfo> availableServices,
@@ -276,6 +303,7 @@
// Since the UI is being cleared, clear any refs.
mPrefs.clear();
+ mPreferenceScreen = screen;
PreferenceGroup group = screen.findPreference(getPreferenceKey());
Context context = screen.getContext();
mPrefs.putAll(buildPreferenceList(context, group));
@@ -348,6 +376,10 @@
Map<String, List<CredentialProviderInfo>> groupedInfos = new HashMap<>();
for (CredentialProviderInfo cpi : mServices) {
String packageName = cpi.getServiceInfo().packageName;
+ if (isProviderHiddenBecauseOfAutofill(packageName)) {
+ continue;
+ }
+
if (!groupedInfos.containsKey(packageName)) {
groupedInfos.put(packageName, new ArrayList<>());
}
@@ -551,6 +583,23 @@
return new NewProviderConfirmationDialogFragment(host, packageName, appName);
}
+ /** If the provider is also the autofill provider then hide it. */
+ @VisibleForTesting
+ public boolean isProviderHiddenBecauseOfAutofill(String packageName) {
+ final String autofillService = Settings.Secure.getStringForUser(
+ mContext.getContentResolver(),
+ Settings.Secure.AUTOFILL_SERVICE,
+ getUser());
+ if (autofillService == null || TextUtils.isEmpty(autofillService)) {
+ return false;
+ }
+ if (packageName == null || TextUtils.isEmpty(packageName)) {
+ return false;
+ }
+
+ return autofillService.startsWith(packageName);
+ }
+
@VisibleForTesting
void completeEnableProviderDialogBox(
int whichButton, String packageName, boolean setActivityResult) {
@@ -655,20 +704,6 @@
}
};
- /**
- * Update the data in this UI.
- */
- private void update() {
- if (mCredentialManager == null) {
- return;
- }
-
- setAvailableServices(
- mCredentialManager.getCredentialProviderServices(
- getUser(), CredentialManager.PROVIDER_FILTER_USER_PROVIDERS_ONLY),
- null);
- }
-
/** Dialog fragment parent class. */
private abstract static class CredentialManagerDialogFragment extends DialogFragment
implements DialogInterface.OnClickListener {
@@ -790,4 +825,28 @@
getDialogHost().onDialogClick(which);
}
}
+
+ /** Updates the list if setting content changes. */
+ private final class SettingContentObserver extends ContentObserver {
+
+ private final Uri mAutofillService =
+ Settings.Secure.getUriFor(Settings.Secure.AUTOFILL_SERVICE);
+
+ private final Uri mCredentialService =
+ Settings.Secure.getUriFor(Settings.Secure.CREDENTIAL_SERVICE);
+
+ public SettingContentObserver(Handler handler) {
+ super(handler);
+ }
+
+ public void register(ContentResolver contentResolver) {
+ contentResolver.registerContentObserver(mAutofillService, false, this, getUser());
+ contentResolver.registerContentObserver(mCredentialService, false, this, getUser());
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ updateFromExternal();
+ }
+ }
}
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index f0c1ed1..4d05946 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -35,6 +35,7 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
}
}
- 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 @@
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);
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index a5e5f57..e0f402b 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -283,7 +283,9 @@
case MSG_REFRESH_FINGERPRINT_TEMPLATES:
removeFingerprintPreference(msg.arg1);
updateAddPreference();
- updateFingerprintUnlockCategoryVisibility();
+ if (isSfps()) {
+ updateFingerprintUnlockCategoryVisibility();
+ }
updatePreferences();
break;
case MSG_FINGER_AUTH_SUCCESS:
@@ -494,9 +496,13 @@
}
private boolean isSfps() {
- for (FingerprintSensorPropertiesInternal prop : mSensorProperties) {
- if (prop.isAnySidefpsType()) {
- return true;
+ mFingerprintManager = Utils.getFingerprintManagerOrNull(getActivity());
+ if (mFingerprintManager != null) {
+ mSensorProperties = mFingerprintManager.getSensorPropertiesInternal();
+ for (FingerprintSensorPropertiesInternal prop : mSensorProperties) {
+ if (prop.isAnySidefpsType()) {
+ return true;
+ }
}
}
return false;
@@ -838,18 +844,20 @@
private List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
- mFingerprintUnlockCategoryPreferenceController =
+ if (isSfps()) {
+ mFingerprintUnlockCategoryPreferenceController =
new FingerprintUnlockCategoryController(
- context,
- KEY_FINGERPRINT_UNLOCK_CATEGORY
+ context,
+ KEY_FINGERPRINT_UNLOCK_CATEGORY
);
- mRequireScreenOnToAuthPreferenceController =
- new FingerprintSettingsRequireScreenOnToAuthPreferenceController(
- context,
- KEY_REQUIRE_SCREEN_ON_TO_AUTH
- );
- controllers.add(mFingerprintUnlockCategoryPreferenceController);
- controllers.add(mRequireScreenOnToAuthPreferenceController);
+ mRequireScreenOnToAuthPreferenceController =
+ new FingerprintSettingsRequireScreenOnToAuthPreferenceController(
+ context,
+ KEY_REQUIRE_SCREEN_ON_TO_AUTH
+ );
+ controllers.add(mFingerprintUnlockCategoryPreferenceController);
+ controllers.add(mRequireScreenOnToAuthPreferenceController);
+ }
return controllers;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index 483e46a..de49ce1 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -223,7 +223,6 @@
mSwitchController.setDisabledByAdmin(admin);
if (admin != null) {
mSwitchController.setChecked(false);
- mSwitchController.setEnabled(false);
}
return admin != null;
}
diff --git a/src/com/android/settings/development/DesktopModePreferenceController.java b/src/com/android/settings/development/DesktopModePreferenceController.java
index 912809c..0e257f6 100644
--- a/src/com/android/settings/development/DesktopModePreferenceController.java
+++ b/src/com/android/settings/development/DesktopModePreferenceController.java
@@ -19,7 +19,6 @@
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
import android.content.Context;
-import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
@@ -83,12 +82,6 @@
((SwitchPreference) mPreference).setChecked(false);
}
- @Override
- public void onRebootConfirmed() {
- final Intent intent = new Intent(Intent.ACTION_REBOOT);
- mContext.startActivity(intent);
- }
-
@VisibleForTesting
String getBuildType() {
return Build.TYPE;
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 194a13a..f8ce975 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -66,6 +66,7 @@
import com.android.settings.development.bluetooth.BluetoothHDAudioPreferenceController;
import com.android.settings.development.bluetooth.BluetoothQualityDialogPreferenceController;
import com.android.settings.development.bluetooth.BluetoothSampleRateDialogPreferenceController;
+import com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController;
import com.android.settings.development.qstile.DevelopmentTiles;
import com.android.settings.development.storage.SharedDataPreferenceController;
import com.android.settings.overlay.FeatureFactory;
@@ -640,6 +641,7 @@
controllers.add(new SelectDebugAppPreferenceController(context, fragment));
controllers.add(new WaitForDebuggerPreferenceController(context));
controllers.add(new EnableGpuDebugLayersPreferenceController(context));
+ controllers.add(new GraphicsDriverEnableAngleAsSystemDriverController(context, fragment));
controllers.add(new ForcePeakRefreshRatePreferenceController(context));
controllers.add(new EnableVerboseVendorLoggingPreferenceController(context));
controllers.add(new VerifyAppsOverUsbPreferenceController(context));
diff --git a/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
index 2e0a6b4..d5d4025 100644
--- a/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
+++ b/src/com/android/settings/development/ForcePeakRefreshRatePreferenceController.java
@@ -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;
@@ -36,6 +35,12 @@
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
@VisibleForTesting
+ static float DEFAULT_REFRESH_RATE = 60f;
+
+ @VisibleForTesting
+ static float NO_CONFIG = 0f;
+
+ @VisibleForTesting
float mPeakRefreshRate;
private static final String TAG = "ForcePeakRefreshRateCtr";
@@ -43,8 +48,17 @@
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 @@
@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;
}
}
diff --git a/src/com/android/settings/development/FreeformWindowsPreferenceController.java b/src/com/android/settings/development/FreeformWindowsPreferenceController.java
index 47b6485..8bb2b1c 100644
--- a/src/com/android/settings/development/FreeformWindowsPreferenceController.java
+++ b/src/com/android/settings/development/FreeformWindowsPreferenceController.java
@@ -17,7 +17,6 @@
package com.android.settings.development;
import android.content.Context;
-import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
@@ -81,12 +80,6 @@
((SwitchPreference) mPreference).setChecked(false);
}
- @Override
- public void onRebootConfirmed() {
- final Intent intent = new Intent(Intent.ACTION_REBOOT);
- mContext.startActivity(intent);
- }
-
@VisibleForTesting
String getBuildType() {
return Build.TYPE;
diff --git a/src/com/android/settings/development/RebootConfirmationDialogFragment.java b/src/com/android/settings/development/RebootConfirmationDialogFragment.java
index 84409d1..2fa0747 100644
--- a/src/com/android/settings/development/RebootConfirmationDialogFragment.java
+++ b/src/com/android/settings/development/RebootConfirmationDialogFragment.java
@@ -37,22 +37,33 @@
private static final String TAG = "FreeformPrefRebootDlg";
private final int mMessageId;
+ private final int mCancelButtonId;
private final RebootConfirmationDialogHost mHost;
/**
* Show an instance of this dialog.
*/
public static void show(Fragment fragment, int messageId, RebootConfirmationDialogHost host) {
+ show(fragment, messageId, R.string.reboot_dialog_reboot_later, host);
+ }
+
+ /**
+ * Show an instance of this dialog with cancel button string set as cancelButtonId
+ */
+ public static void show(Fragment fragment, int messageId,
+ int cancelButtonId, RebootConfirmationDialogHost host) {
final FragmentManager manager = fragment.getActivity().getSupportFragmentManager();
if (manager.findFragmentByTag(TAG) == null) {
final RebootConfirmationDialogFragment dialog =
- new RebootConfirmationDialogFragment(messageId, host);
+ new RebootConfirmationDialogFragment(messageId, cancelButtonId, host);
dialog.show(manager, TAG);
}
}
- private RebootConfirmationDialogFragment(int messageId, RebootConfirmationDialogHost host) {
+ private RebootConfirmationDialogFragment(int messageId,
+ int cancelButtonId, RebootConfirmationDialogHost host) {
mMessageId = messageId;
+ mCancelButtonId = cancelButtonId;
mHost = host;
}
@@ -66,12 +77,16 @@
return new AlertDialog.Builder(getActivity())
.setMessage(mMessageId)
.setPositiveButton(R.string.reboot_dialog_reboot_now, this)
- .setNegativeButton(R.string.reboot_dialog_reboot_later, null)
+ .setNegativeButton(mCancelButtonId, this)
.create();
}
@Override
public void onClick(DialogInterface dialog, int which) {
- mHost.onRebootConfirmed();
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ mHost.onRebootConfirmed(getContext());
+ } else {
+ mHost.onRebootCancelled();
+ }
}
}
diff --git a/src/com/android/settings/development/RebootConfirmationDialogHost.java b/src/com/android/settings/development/RebootConfirmationDialogHost.java
index 6eb9f2f..65ffbed 100644
--- a/src/com/android/settings/development/RebootConfirmationDialogHost.java
+++ b/src/com/android/settings/development/RebootConfirmationDialogHost.java
@@ -16,13 +16,26 @@
package com.android.settings.development;
+import android.content.Context;
+import android.content.Intent;
+
/**
* Host of {@link RebootConfirmationDialogFragment} that provides callback when user
* interacts with the UI.
*/
public interface RebootConfirmationDialogHost {
/**
- * Called when user made a decision on whether to reboot the device.
+ * Called when user made a decision to reboot the device.
*/
- void onRebootConfirmed();
+ default void onRebootConfirmed(Context context) {
+ // user presses button "Reboot now", reboot the device
+ final Intent intent = new Intent(Intent.ACTION_REBOOT);
+ context.startActivity(intent);
+ }
+
+ /**
+ * Called when user made a decision to cancel the reboot
+ * Default to do nothing
+ */
+ default void onRebootCancelled() {}
}
diff --git a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
new file mode 100644
index 0000000..b9f3413
--- /dev/null
+++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development.graphicsdriver;
+
+import android.content.Context;
+import android.os.GraphicsEnvironment;
+import android.os.SystemProperties;
+import android.text.TextUtils;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.development.DevelopmentSettingsDashboardFragment;
+import com.android.settings.development.RebootConfirmationDialogFragment;
+import com.android.settings.development.RebootConfirmationDialogHost;
+import com.android.settingslib.development.DeveloperOptionsPreferenceController;
+
+/**
+ * Controller to handle the events when user toggles this developer option switch: Enable ANGLE
+ */
+public class GraphicsDriverEnableAngleAsSystemDriverController
+ extends DeveloperOptionsPreferenceController
+ implements Preference.OnPreferenceChangeListener,
+ PreferenceControllerMixin,
+ RebootConfirmationDialogHost {
+
+ private static final String TAG = "GraphicsEnableAngleCtrl";
+
+ private static final String ENABLE_ANELE_AS_SYSTEM_DRIVER_KEY = "enable_angle_as_system_driver";
+
+ private final DevelopmentSettingsDashboardFragment mFragment;
+
+ @VisibleForTesting
+ static final String PROPERTY_RO_GFX_ANGLE_SUPPORTED = "ro.gfx.angle.supported";
+
+ @VisibleForTesting
+ static final String PROPERTY_PERSISTENT_GRAPHICS_EGL = "persist.graphics.egl";
+
+ @VisibleForTesting
+ static final String ANGLE_DRIVER_SUFFIX = "angle";
+
+
+ public GraphicsDriverEnableAngleAsSystemDriverController(
+ Context context, DevelopmentSettingsDashboardFragment fragment) {
+ super(context);
+ mFragment = fragment;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return ENABLE_ANELE_AS_SYSTEM_DRIVER_KEY;
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean enableAngleAsSystemDriver = (Boolean) newValue;
+ // set "persist.graphics.egl" to "angle" if enableAngleAsSystemDriver is true
+ // set "persist.graphics.egl" to "" if enableAngleAsSystemDriver is false
+ GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(enableAngleAsSystemDriver);
+ // pop up a window asking user to reboot to make the new "persist.graphics.egl" take effect
+ RebootConfirmationDialogFragment.show(
+ mFragment, R.string.reboot_dialog_enable_angle_as_system_driver,
+ R.string.cancel, this);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ // set switch on if "persist.graphics.egl" is "angle" and angle is built in /vendor
+ // set switch off otherwise.
+ final String currentGlesDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
+ final boolean isAngle = TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver);
+ final boolean isAngleSupported =
+ TextUtils.equals(SystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED), "true");
+ ((SwitchPreference) mPreference).setChecked(isAngle && isAngleSupported);
+ ((SwitchPreference) mPreference).setEnabled(isAngleSupported);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchEnabled() {
+ // only enable the switch if ro.gfx.angle.supported is true
+ // we use ro.gfx.angle.supported to indicate if ANGLE libs are installed under /vendor
+ final boolean isAngleSupported =
+ TextUtils.equals(SystemProperties.get(PROPERTY_RO_GFX_ANGLE_SUPPORTED), "true");
+ ((SwitchPreference) mPreference).setEnabled(isAngleSupported);
+ }
+
+ @Override
+ protected void onDeveloperOptionsSwitchDisabled() {
+ // 1) set the persist.graphics.egl empty string
+ GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false);
+ // 2) reset the switch
+ ((SwitchPreference) mPreference).setChecked(false);
+ // 3) disable switch
+ ((SwitchPreference) mPreference).setEnabled(false);
+ }
+
+ @Override
+ public void onRebootCancelled() {
+ // if user presses button "Cancel", do not reboot the device, and toggles switch back
+ final String currentGlesDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
+ if (TextUtils.equals(ANGLE_DRIVER_SUFFIX, currentGlesDriver)) {
+ // if persist.graphics.egl = "angle", set the property value back to ""
+ GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(false);
+ // toggle switch off
+ ((SwitchPreference) mPreference).setChecked(false);
+ return;
+ }
+
+ if (TextUtils.isEmpty(currentGlesDriver)) {
+ // if persist.graphicx.egl = "", set the persist.graphics.egl back to "angle"
+ GraphicsEnvironment.getInstance().toggleAngleAsSystemDriver(true);
+ // toggle switch on
+ ((SwitchPreference) mPreference).setChecked(true);
+ return;
+ }
+
+ // if persist.graphics.egl holds values other than the above two, log error message
+ Log.e(TAG, "Invalid persist.graphics.egl property value");
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index 2c7b5f4..2045b96 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -150,7 +150,6 @@
@VisibleForTesting
protected void updatePreference(Preference preference, int simSlot) {
- SubscriptionInfo subInfo = getSubscriptionInfo(simSlot);
preference.setTitle(getTitle(simSlot));
preference.setSummary(getSummary());
}
diff --git a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
index 72eca5b..dfcc601 100644
--- a/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
+++ b/src/com/android/settings/display/PeakRefreshRatePreferenceController.java
@@ -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 @@
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 @@
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 @@
@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 @@
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 @@
}
}
}
+
+ 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;
+ }
}
diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
index 5bec7bd..d686594 100644
--- a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
@@ -30,6 +30,7 @@
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
+import com.android.settingslib.Utils;
import com.android.settingslib.utils.ThreadUtils;
public class TopLevelBatteryPreferenceController extends BasePreferenceController implements
@@ -38,10 +39,12 @@
private static final String TAG = "TopLvBatteryPrefControl";
@VisibleForTesting
- protected boolean mIsBatteryPresent = true;
- @VisibleForTesting
Preference mPreference;
+ @VisibleForTesting
+ protected boolean mIsBatteryPresent = true;
+
private final BatteryBroadcastReceiver mBatteryBroadcastReceiver;
+
private BatteryInfo mBatteryInfo;
private BatteryStatusFeatureProvider mBatteryStatusFeatureProvider;
private String mBatteryStatusLabel;
@@ -55,8 +58,11 @@
mIsBatteryPresent = false;
}
BatteryInfo.getBatteryInfo(mContext, info -> {
+ Log.d(TAG, "getBatteryInfo: " + info);
mBatteryInfo = info;
updateState(mPreference);
+ // Update the preference summary text to the latest state.
+ setSummaryAsync(info);
}, true /* shortString */);
});
@@ -104,18 +110,19 @@
if (info == null || context == null) {
return null;
}
-
- Log.d(TAG, "getDashboardLabel: batteryStatusUpdate=" + batteryStatusUpdate);
+ Log.d(TAG, "getDashboardLabel: " + mBatteryStatusLabel + " batteryStatusUpdate="
+ + batteryStatusUpdate);
if (batteryStatusUpdate) {
setSummaryAsync(info);
}
-
- return (mBatteryStatusLabel == null) ? generateLabel(info) : mBatteryStatusLabel;
+ return mBatteryStatusLabel == null ? generateLabel(info) : mBatteryStatusLabel;
}
private void setSummaryAsync(BatteryInfo info) {
ThreadUtils.postOnBackgroundThread(() -> {
+ // Return false if built-in status should be used, will use updateBatteryStatus()
+ // method to inject the customized battery status label.
final boolean triggerBatteryStatusUpdate =
mBatteryStatusFeatureProvider.triggerBatteryStatusUpdate(this, info);
ThreadUtils.postOnMainThread(() -> {
@@ -123,12 +130,15 @@
mBatteryStatusLabel = null; // will generateLabel()
}
mPreference.setSummary(
- (mBatteryStatusLabel == null) ? generateLabel(info) : mBatteryStatusLabel);
+ mBatteryStatusLabel == null ? generateLabel(info) : mBatteryStatusLabel);
});
});
}
private CharSequence generateLabel(BatteryInfo info) {
+ if (Utils.containsIncompatibleChargers(mContext, TAG)) {
+ return mContext.getString(R.string.battery_info_status_not_charging);
+ }
if (!info.discharging && info.chargeLabel != null) {
return info.chargeLabel;
} else if (info.remainingLabel == null) {
@@ -146,13 +156,13 @@
@Override
public void updateBatteryStatus(String label, BatteryInfo info) {
mBatteryStatusLabel = label; // Null if adaptive charging is not active
-
- if (mPreference != null) {
- // Do not triggerBatteryStatusUpdate(), otherwise there will be an infinite loop
- final CharSequence summary = getSummary(false /* batteryStatusUpdate */);
- if (summary != null) {
- mPreference.setSummary(summary);
- }
+ if (mPreference == null) {
+ return;
+ }
+ // Do not triggerBatteryStatusUpdate() here to cause infinite loop
+ final CharSequence summary = getSummary(false /* batteryStatusUpdate */);
+ if (summary != null) {
+ mPreference.setSummary(summary);
}
}
@@ -170,4 +180,4 @@
String pkgName = lastPkgIndex > 0 ? classPath.substring(0, lastPkgIndex) : "";
return new ComponentName(pkgName, split[classNameIndex]);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
index c272a49..b262dee 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryUsageBreakdownController.java
@@ -177,8 +177,8 @@
mAppListPreferenceGroup.setOrderingAsAdded(false);
mSpinnerPreference.initializeSpinner(
new String[]{
- mPrefContext.getString(R.string.battery_usage_spinner_by_apps),
- mPrefContext.getString(R.string.battery_usage_spinner_by_systems)
+ mPrefContext.getString(R.string.battery_usage_spinner_view_by_apps),
+ mPrefContext.getString(R.string.battery_usage_spinner_view_by_systems)
},
new AdapterView.OnItemSelectedListener() {
@Override
diff --git a/src/com/android/settings/localepicker/LocaleDialogFragment.java b/src/com/android/settings/localepicker/LocaleDialogFragment.java
index 2ee2e8b..9e274d6 100644
--- a/src/com/android/settings/localepicker/LocaleDialogFragment.java
+++ b/src/com/android/settings/localepicker/LocaleDialogFragment.java
@@ -37,6 +37,8 @@
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 @@
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 @@
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 @@
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);
}
}
diff --git a/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java b/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java
index a639c9d..1227683 100644
--- a/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java
+++ b/src/com/android/settings/localepicker/LocaleHelperPreferenceController.java
@@ -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.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 @@
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 @@
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");
diff --git a/src/com/android/settings/location/LocationSwitchBarController.java b/src/com/android/settings/location/LocationSwitchBarController.java
index c84014f..b150b1d 100644
--- a/src/com/android/settings/location/LocationSwitchBarController.java
+++ b/src/com/android/settings/location/LocationSwitchBarController.java
@@ -15,6 +15,7 @@
import android.content.Context;
import android.os.UserHandle;
+import android.os.UserManager;
import android.widget.Switch;
import com.android.settings.widget.SettingsMainSwitchBar;
@@ -75,8 +76,12 @@
// only, it would be re-enabled again if the switch bar is not disabled.
if (!hasBaseUserRestriction && admin != null) {
mSwitchBar.setDisabledByAdmin(admin);
+ } else if (restricted) {
+ RestrictedLockUtils.EnforcedAdmin enforcedAdmin = RestrictedLockUtils.EnforcedAdmin
+ .createDefaultEnforcedAdminWithRestriction(UserManager.DISALLOW_SHARE_LOCATION);
+ mSwitchBar.setDisabledByAdmin(enforcedAdmin);
} else {
- mSwitchBar.setEnabled(!restricted);
+ mSwitchBar.setEnabled(true);
}
if (enabled != mSwitchBar.isChecked()) {
diff --git a/src/com/android/settings/notification/app/AppNotificationSettings.java b/src/com/android/settings/notification/app/AppNotificationSettings.java
index 5a14bc9..4ebac0f 100644
--- a/src/com/android/settings/notification/app/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/app/AppNotificationSettings.java
@@ -18,18 +18,11 @@
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;
diff --git a/src/com/android/settings/security/MemtagHelper.java b/src/com/android/settings/security/MemtagHelper.java
index a09a219..69639c2 100644
--- a/src/com/android/settings/security/MemtagHelper.java
+++ b/src/com/android/settings/security/MemtagHelper.java
@@ -30,7 +30,7 @@
"persist.device_config.runtime_native_boot.bootloader_override";
public static boolean isForcedOff() {
- return TextUtils.equals("force_on", SystemProperties.get(DEVICE_CONFIG_PROP));
+ return TextUtils.equals("force_off", SystemProperties.get(DEVICE_CONFIG_PROP));
}
public static boolean isForcedOn() {
diff --git a/src/com/android/settings/spa/core/instrumentation/SpaLogProvider.kt b/src/com/android/settings/spa/core/instrumentation/SpaLogProvider.kt
index 31d5797..600a2e6 100644
--- a/src/com/android/settings/spa/core/instrumentation/SpaLogProvider.kt
+++ b/src/com/android/settings/spa/core/instrumentation/SpaLogProvider.kt
@@ -123,8 +123,8 @@
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 ""
}
}
diff --git a/src/com/android/settings/spa/network/AirplaneModePreference.kt b/src/com/android/settings/spa/network/AirplaneModePreference.kt
index 4af3221..462c121 100644
--- a/src/com/android/settings/spa/network/AirplaneModePreference.kt
+++ b/src/com/android/settings/spa/network/AirplaneModePreference.kt
@@ -52,7 +52,7 @@
}
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
diff --git a/src/com/android/settings/spa/notification/AppNotificationRepository.kt b/src/com/android/settings/spa/notification/AppNotificationRepository.kt
index 8dc4f20..f35d308 100644
--- a/src/com/android/settings/spa/notification/AppNotificationRepository.kt
+++ b/src/com/android/settings/spa/notification/AppNotificationRepository.kt
@@ -123,13 +123,15 @@
}
override fun getNotificationSummary(app: ApplicationInfo): String {
- if (!isEnabled(app)) return context.getString(R.string.off)
+ if (!isEnabled(app)) return context.getString(R.string.notifications_disabled)
val channelCount = getChannelCount(app)
if (channelCount == 0) {
return calculateFrequencySummary(getSentCount(app))
}
val blockedChannelCount = getBlockedChannelCount(app)
- if (channelCount == blockedChannelCount) return context.getString(R.string.off)
+ if (channelCount == blockedChannelCount) {
+ return context.getString(R.string.notifications_disabled)
+ }
val frequencySummary = calculateFrequencySummary(getSentCount(app))
if (blockedChannelCount == 0) return frequencySummary
return context.getString(
diff --git a/src/com/android/settings/widget/SettingsMainSwitchBar.java b/src/com/android/settings/widget/SettingsMainSwitchBar.java
index 5ad16d7..8b8a9ba 100644
--- a/src/com/android/settings/widget/SettingsMainSwitchBar.java
+++ b/src/com/android/settings/widget/SettingsMainSwitchBar.java
@@ -21,14 +21,12 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
-import android.widget.ImageView;
import android.widget.Switch;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.widget.MainSwitchBar;
-import com.android.settingslib.widget.R;
/**
* A {@link MainSwitchBar} with a customized Switch and provides the metrics feature.
@@ -47,7 +45,6 @@
boolean onBeforeCheckedChanged(Switch switchView, boolean isChecked);
}
- private ImageView mRestrictedIcon;
private EnforcedAdmin mEnforcedAdmin;
private boolean mDisabledByAdmin;
@@ -74,14 +71,6 @@
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
addOnSwitchChangeListener((switchView, isChecked) -> logMetrics(isChecked));
-
- mRestrictedIcon = findViewById(R.id.restricted_icon);
- mRestrictedIcon.setOnClickListener((View v) -> {
- if (mDisabledByAdmin) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(context, mEnforcedAdmin);
- onRestrictedIconClick();
- }
- });
}
/**
@@ -95,12 +84,9 @@
mDisabledByAdmin = true;
mTextView.setEnabled(false);
mSwitch.setEnabled(false);
- mSwitch.setVisibility(View.GONE);
- mRestrictedIcon.setVisibility(View.VISIBLE);
} else {
mDisabledByAdmin = false;
mSwitch.setVisibility(View.VISIBLE);
- mRestrictedIcon.setVisibility(View.GONE);
setEnabled(isEnabled());
}
}
@@ -120,11 +106,12 @@
@Override
public boolean performClick() {
- return getDelegatingView().performClick();
- }
+ if (mDisabledByAdmin) {
+ performRestrictedClick();
+ return true;
+ }
- protected void onRestrictedIconClick() {
- mMetricsFeatureProvider.clicked(mMetricsCategory, "switch_bar|restricted");
+ return mSwitch.performClick();
}
@Override
@@ -157,11 +144,12 @@
mMetricsCategory = category;
}
- private View getDelegatingView() {
- return mDisabledByAdmin ? mRestrictedIcon : mSwitch;
- }
-
private void logMetrics(boolean isChecked) {
mMetricsFeatureProvider.changed(mMetricsCategory, "switch_bar", isChecked ? 1 : 0);
}
+
+ private void performRestrictedClick() {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getContext(), mEnforcedAdmin);
+ mMetricsFeatureProvider.clicked(mMetricsCategory, "switch_bar|restricted");
+ }
}
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index 2774be6..4ce59b9 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -80,11 +80,14 @@
@VisibleForTesting
SettingsMainSwitchBar mMainSwitchBar;
private WifiTetherSwitchBarController mSwitchBarController;
- private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
- private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
+ @VisibleForTesting
+ WifiTetherSSIDPreferenceController mSSIDPreferenceController;
+ @VisibleForTesting
+ WifiTetherPasswordPreferenceController mPasswordPreferenceController;
private WifiTetherSecurityPreferenceController mSecurityPreferenceController;
private WifiTetherMaximizeCompatibilityPreferenceController mMaxCompatibilityPrefController;
- private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
+ @VisibleForTesting
+ WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
private boolean mUnavailable;
private WifiRestriction mWifiRestriction;
@@ -269,10 +272,12 @@
setLoading(restarting, false);
}
- private SoftApConfiguration buildNewConfig() {
- SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder();
+ @VisibleForTesting
+ SoftApConfiguration buildNewConfig() {
+ SoftApConfiguration currentConfig = mWifiTetherViewModel.getSoftApConfiguration();
+ SoftApConfiguration.Builder configBuilder = new SoftApConfiguration.Builder(currentConfig);
int securityType = (mWifiTetherViewModel.isSpeedFeatureAvailable())
- ? mWifiTetherViewModel.getSoftApConfiguration().getSecurityType()
+ ? currentConfig.getSecurityType()
: mSecurityPreferenceController.getSecurityType();
configBuilder.setSsid(mSSIDPreferenceController.getSSID());
if (securityType != SoftApConfiguration.SECURITY_TYPE_OPEN) {
diff --git a/tests/componenttests/src/com/android/settings/biometrics/BiometricEnrollActivityTest.java b/tests/componenttests/src/com/android/settings/biometrics/BiometricEnrollActivityTest.java
index c5e3a19..0cb73c1 100644
--- a/tests/componenttests/src/com/android/settings/biometrics/BiometricEnrollActivityTest.java
+++ b/tests/componenttests/src/com/android/settings/biometrics/BiometricEnrollActivityTest.java
@@ -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 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.Test;
import org.junit.runner.RunWith;
+import java.util.List;
+
@RunWith(AndroidJUnit4.class)
@MediumTest
public class BiometricEnrollActivityTest {
@@ -67,6 +76,8 @@
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 @@
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 @@
}
}
+ @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 */);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/SystemControlsFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/SystemControlsFragmentTest.java
index 1d8fb32..506882b 100644
--- a/tests/robotests/src/com/android/settings/accessibility/SystemControlsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/SystemControlsFragmentTest.java
@@ -25,16 +25,19 @@
import com.android.settings.R;
import com.android.settings.testutils.XmlTestUtils;
+import com.android.settings.testutils.shadow.ShadowKeyCharacterMap;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
import java.util.List;
/** Tests for {@link SystemControlsFragment}. */
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowKeyCharacterMap.class})
public class SystemControlsFragmentTest {
private final Context mContext = ApplicationProvider.getApplicationContext();
diff --git a/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java
index 7dfde38..2e93d5e 100644
--- a/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/ForcePeakRefreshRatePreferenceControllerTest.java
@@ -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.RuntimeEnvironment;
import org.robolectric.annotation.Config;
+import android.util.Log;
+
@RunWith(RobolectricTestRunner.class)
public class ForcePeakRefreshRatePreferenceControllerTest {
@@ -61,18 +63,22 @@
@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 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();
}
diff --git a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java
new file mode 100644
index 0000000..314f8c3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerTest.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.development.graphicsdriver;
+
+import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.ANGLE_DRIVER_SUFFIX;
+import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_PERSISTENT_GRAPHICS_EGL;
+import static com.android.settings.development.graphicsdriver.GraphicsDriverEnableAngleAsSystemDriverController.PROPERTY_RO_GFX_ANGLE_SUPPORTED;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.SystemProperties;
+
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.settings.development.DevelopmentSettingsDashboardFragment;
+import com.android.settings.development.RebootConfirmationDialogFragment;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowSystemProperties;
+
+@RunWith(RobolectricTestRunner.class)
+public class GraphicsDriverEnableAngleAsSystemDriverControllerTest {
+ private static final String TAG = "GraphicsDriverEnableAngleAsSystemDriverControllerTest";
+ @Mock private PreferenceScreen mScreen;
+ @Mock private SwitchPreference mPreference;
+ @Mock private DevelopmentSettingsDashboardFragment mFragment;
+ @Mock private FragmentActivity mActivity;
+ @Mock private FragmentManager mFragmentManager;
+ @Mock private FragmentTransaction mTransaction;
+
+ private GraphicsDriverEnableAngleAsSystemDriverController mController;
+
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ doReturn(mTransaction).when(mFragmentManager).beginTransaction();
+ doReturn(mFragmentManager).when(mActivity).getSupportFragmentManager();
+ doReturn(mActivity).when(mFragment).getActivity();
+ mController = new GraphicsDriverEnableAngleAsSystemDriverController(mContext, mFragment);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ mController.displayPreference(mScreen);
+ }
+
+ @Test
+ public void onPreferenceChange_switchOn_shouldEnableAngleAsSystemDriver() {
+ ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
+ // since GraphicsEnvironment is mocked in Robolectric test environment,
+ // we will override the system property persist.graphics.egl as if it is changed by
+ // mGraphicsEnvironment.toggleAngleAsSystemDriver(true).
+ // TODO: b/270994705 yuxinhu:
+ // add test coverage to test mGraphicsEnvironment.toggleAngleAsSystemDriver()
+ // works properly on Android devices / emulators.
+ ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ANGLE_DRIVER_SUFFIX);
+ mController.onPreferenceChange(mPreference, true);
+ final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
+ assertThat(systemEGLDriver).isEqualTo(ANGLE_DRIVER_SUFFIX); // empty
+ verify(mTransaction).add(any(RebootConfirmationDialogFragment.class), any());
+ }
+
+ @Test
+ public void onPreferenceChange_switchOff_shouldDisableAngleAsSystemDriver() {
+ ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
+ // since GraphicsEnvironment is mocked in Robolectric test environment,
+ // we will override the system property persist.graphics.egl as if it is changed by
+ // mGraphicsEnvironment.toggleAngleAsSystemDriver(false).
+ // TODO: b/270994705 yuxinhu:
+ // add test coverage to test mGraphicsEnvironment.toggleAngleAsSystemDriver()
+ // works properly on Android devices / emulators.
+ ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
+ mController.onPreferenceChange(mPreference, false);
+ final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
+ assertThat(systemEGLDriver).isEqualTo("");
+ verify(mTransaction).add(any(RebootConfirmationDialogFragment.class), any());
+ }
+
+ @Test
+ public void updateState_angleNotSupported_preferenceShouldNotBeChecked() {
+ ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "");
+ mController.updateState(mPreference);
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void updateState_angleNotSupported_preferenceShouldNotBeEnabled() {
+ ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "");
+ mController.updateState(mPreference);
+ verify(mPreference).setEnabled(false);
+ }
+
+ @Test
+ public void updateState_angleSupported_angleUsed_preferenceShouldBeChecked() {
+ ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
+ // TODO: b/270994705 yuxinhu:
+ // add test coverage to test mGraphicsEnvironment.toggleAngleAsSystemDriver()
+ // works properly on Android devices / emulators.
+ ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, ANGLE_DRIVER_SUFFIX);
+ mController.updateState(mPreference);
+ verify(mPreference).setChecked(true); //false
+ }
+
+ @Test
+ public void updateState_angleSupported_angleNotUsed_preferenceShouldNotBeChecked() {
+ ShadowSystemProperties.override(PROPERTY_RO_GFX_ANGLE_SUPPORTED, "true");
+ // TODO: b/270994705 yuxinhu:
+ // add test coverage to test mGraphicsEnvironment.toggleAngleAsSystemDriver(false)
+ // works properly on Android devices / emulators.
+ ShadowSystemProperties.override(PROPERTY_PERSISTENT_GRAPHICS_EGL, "");
+ mController.updateState(mPreference);
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void onDeveloperOptionSwitchDisabled_shouldDisableAngleAsSystemDriver() {
+ mController.onDeveloperOptionsSwitchDisabled();
+ final String systemEGLDriver = SystemProperties.get(PROPERTY_PERSISTENT_GRAPHICS_EGL);
+ assertThat(systemEGLDriver).isEqualTo("");
+ }
+
+ @Test
+ public void onDeveloperOptionSwitchDisabled_preferenceShouldNotBeChecked() {
+ mController.onDeveloperOptionsSwitchDisabled();
+ verify(mPreference).setChecked(false);
+ }
+
+ @Test
+ public void onDeveloperOptionsSwitchDisabled_preferenceShouldNotBeEnabled() {
+ mController.onDeveloperOptionsSwitchDisabled();
+ verify(mPreference).setEnabled(false);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java b/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java
index 37bf54c..ad495c7 100644
--- a/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java
+++ b/tests/robotests/src/com/android/settings/development/qstile/WinscopeTraceTest.java
@@ -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.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 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 @@
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 @@
assertThat(mWinscopeTrace.isEnabled()).isTrue();
verify(mSurfaceFlinger)
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
- eq(0 /* flags */));
+ eq(0 /* flags */));
verifyNoMoreInteractions(mSurfaceFlinger);
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
index 9d700a6..6699b34 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
@@ -19,11 +19,14 @@
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.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 @@
}
@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
diff --git a/tests/robotests/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceControllerTest.java
index 8bb3ff6..a82e1f1 100644
--- a/tests/robotests/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceControllerTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.atLeastOnce;
@@ -27,6 +28,10 @@
import android.content.ContentResolver;
import android.content.Context;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.provider.Settings;
@@ -64,12 +69,16 @@
@Mock
private PreferenceScreen mPreferenceScreen;
+ @Mock
+ private PackageManager mPackageManager;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(ApplicationProvider.getApplicationContext());
mContentResolver = spy(mContext.getContentResolver());
when(mContext.getContentResolver()).thenReturn(mContentResolver);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
setCustomizableLockScreenQuickAffordancesEnabled(false);
@@ -199,5 +208,19 @@
});
return cursor;
});
+
+ if (isEnabled) {
+ final ApplicationInfo applicationInfo = new ApplicationInfo();
+ applicationInfo.packageName = "package";
+
+ final ActivityInfo activityInfo = new ActivityInfo();
+ activityInfo.applicationInfo = applicationInfo;
+ activityInfo.name = "activity";
+
+ final ResolveInfo resolveInfo = new ResolveInfo();
+ resolveInfo.activityInfo = activityInfo;
+
+ when(mPackageManager.resolveActivity(any(), any())).thenReturn(resolveInfo);
+ }
}
}
diff --git a/tests/robotests/src/com/android/settings/display/DeviceStateAutoRotateDetailsFragmentTest.java b/tests/robotests/src/com/android/settings/display/DeviceStateAutoRotateDetailsFragmentTest.java
index c1268b6..e5940b6 100644
--- a/tests/robotests/src/com/android/settings/display/DeviceStateAutoRotateDetailsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/display/DeviceStateAutoRotateDetailsFragmentTest.java
@@ -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 @@
@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 @@
when(mContext.getApplicationContext()).thenReturn(mContext);
when(mFragment.getContext()).thenReturn(mContext);
when(mFragment.getResources()).thenReturn(mResources);
+ setUpPostureMappings();
}
@Test
@@ -67,7 +74,9 @@
@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 @@
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});
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
index 9c3644e..aaeeea4 100644
--- a/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/PeakRefreshRatePreferenceControllerTest.java
@@ -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 @@
}
@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 @@
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);
}
}
diff --git a/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java b/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java
index 4fec38b..4596364 100644
--- a/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/SmartAutoRotateControllerTest.java
@@ -53,6 +53,7 @@
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 @@
}
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);
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
index 598ef6e..0321483 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/RestrictAppPreferenceControllerTest.java
@@ -28,7 +28,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.Activity;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
@@ -39,18 +38,19 @@
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.AppInfo;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import java.util.ArrayList;
@@ -98,7 +98,7 @@
mOtherUserPackageOps = new AppOpsManager.PackageOps(
RESTRICTED_PACKAGE_NAME, OTHER_USER_UID, restrictedOps);
- mContext = spy(Robolectric.setupActivity(Activity.class));
+ mContext = spy(ApplicationProvider.getApplicationContext());
doReturn(mAppOpsManager).when(mContext).getSystemService(Context.APP_OPS_SERVICE);
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
doReturn(mContext).when(mFragment).getContext();
@@ -180,6 +180,7 @@
assertThat(mPreference.isVisible()).isFalse();
}
+ @Ignore
@Test
public void handlePreferenceTreeClick_startFragment() {
final ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
index f9cac56..5f825ae 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
@@ -25,12 +25,15 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.hardware.usb.UsbManager;
+import android.hardware.usb.UsbPort;
+import android.hardware.usb.UsbPortStatus;
import androidx.preference.Preference;
+import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
@@ -38,22 +41,33 @@
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
+import java.util.ArrayList;
+import java.util.List;
+
@RunWith(RobolectricTestRunner.class)
public class TopLevelBatteryPreferenceControllerTest {
private Context mContext;
private TopLevelBatteryPreferenceController mController;
private BatterySettingsFeatureProvider mBatterySettingsFeatureProvider;
+ @Mock
+ private UsbPort mUsbPort;
+ @Mock
+ private UsbManager mUsbManager;
+ @Mock
+ private UsbPortStatus mUsbPortStatus;
+
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = spy(Robolectric.setupActivity(Activity.class));
+ mContext = spy(ApplicationProvider.getApplicationContext());
mController = new TopLevelBatteryPreferenceController(mContext, "test_key");
+ when(mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
}
@Test
@@ -89,27 +103,61 @@
}
@Test
- public void getDashboardLabel_returnsCorrectLabel() {
+ public void getDashboardLabel_returnsBatterPercentString() {
mController.mPreference = new Preference(mContext);
BatteryInfo info = new BatteryInfo();
info.batteryPercentString = "3%";
+
assertThat(mController.getDashboardLabel(mContext, info, true))
.isEqualTo(info.batteryPercentString);
+ }
+ @Test
+ public void getDashboardLabel_returnsRemainingLabel() {
+ mController.mPreference = new Preference(mContext);
+ BatteryInfo info = new BatteryInfo();
+ info.batteryPercentString = "3%";
info.remainingLabel = "Phone will shut down soon";
+
assertThat(mController.getDashboardLabel(mContext, info, true))
.isEqualTo("3% - Phone will shut down soon");
+ }
+ @Test
+ public void getDashboardLabel_returnsChargeLabel() {
+ mController.mPreference = new Preference(mContext);
+ BatteryInfo info = new BatteryInfo();
info.discharging = false;
info.chargeLabel = "5% - charging";
- assertThat(mController.getDashboardLabel(mContext, info, true)).isEqualTo("5% - charging");
+
+ assertThat(mController.getDashboardLabel(mContext, info, true))
+ .isEqualTo(info.chargeLabel);
+ }
+
+ @Test
+ public void getDashboardLabel_incompatibleCharger_returnsCorrectLabel() {
+ setupIncompatibleEvent();
+ mController.mPreference = new Preference(mContext);
+ BatteryInfo info = new BatteryInfo();
+
+ assertThat(mController.getDashboardLabel(mContext, info, true))
+ .isEqualTo(mContext.getString(R.string.battery_info_status_not_charging));
}
@Test
public void getSummary_batteryNotPresent_shouldShowWarningMessage() {
mController.mIsBatteryPresent = false;
-
assertThat(mController.getSummary())
.isEqualTo(mContext.getString(R.string.battery_missing_message));
}
+
+ private void setupIncompatibleEvent() {
+ final List<UsbPort> usbPorts = new ArrayList<>();
+ usbPorts.add(mUsbPort);
+ when(mUsbManager.getPorts()).thenReturn(usbPorts);
+ when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
+ when(mUsbPort.supportsComplianceWarnings()).thenReturn(true);
+ when(mUsbPortStatus.isConnected()).thenReturn(true);
+ when(mUsbPortStatus.getComplianceWarnings()).thenReturn(new int[]{1});
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java
index a03c50a..71202df 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/OpenRestrictAppFragmentActionTest.java
@@ -18,9 +18,10 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.app.Activity;
import android.content.Context;
+import androidx.test.core.app.ApplicationProvider;
+
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.core.InstrumentedPreferenceFragment;
import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
@@ -33,11 +34,11 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
import java.util.ArrayList;
import java.util.List;
@@ -64,8 +65,7 @@
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- mContext = Robolectric.setupActivity(Activity.class);
-
+ mContext = ApplicationProvider.getApplicationContext();
mAppInfos = new ArrayList<>();
mAppInfos.add(new AppInfo.Builder()
.setPackageName(PACKAGE_NAME_1)
@@ -88,6 +88,7 @@
DatabaseTestUtils.clearDb(mContext);
}
+ @Ignore
@Test
public void testHandlePositiveAction() {
mAction.handlePositiveAction(METRICS_KEY);
diff --git a/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java
index 348f64d..50f618f 100644
--- a/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationSwitchBarControllerTest.java
@@ -23,6 +23,7 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.os.UserManager;
import android.provider.Settings;
import android.widget.Switch;
@@ -109,13 +110,25 @@
}
@Test
+ public void onLocationModeChanged_Restricted_shouldDisableSwitchByAdmin() {
+ final RestrictedLockUtils.EnforcedAdmin admin = RestrictedLockUtils.EnforcedAdmin
+ .createDefaultEnforcedAdminWithRestriction(UserManager.DISALLOW_SHARE_LOCATION);
+ doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
+ doReturn(false).when(mEnabler).hasShareLocationRestriction(anyInt());
+
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, true);
+
+ verify(mSwitchBar).setDisabledByAdmin(admin);
+ }
+
+ @Test
public void onLocationModeChanged_Restricted_shouldDisableSwitch() {
doReturn(null).when(mEnabler).getShareLocationEnforcedAdmin(anyInt());
doReturn(true).when(mEnabler).hasShareLocationRestriction(anyInt());
- mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, true);
+ mController.onLocationModeChanged(Settings.Secure.LOCATION_MODE_BATTERY_SAVING, false);
- verify(mSwitchBar).setEnabled(false);
+ verify(mSwitchBar).setEnabled(true);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
index 057b6cb..b2f0ad5 100644
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsPreferenceControllerTest.java
@@ -169,6 +169,7 @@
@Test
public void getAvailibilityStatus_availableByDefault() {
+ doReturn(true).when(mUserManager).isAdminUser();
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDeviceStateRotationLockSettingsManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDeviceStateRotationLockSettingsManager.java
index 72df3cc..ed266e3 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDeviceStateRotationLockSettingsManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDeviceStateRotationLockSettingsManager.java
@@ -27,6 +27,7 @@
public class ShadowDeviceStateRotationLockSettingsManager {
private static boolean sDeviceStateRotationLockEnabled;
+ private boolean mIsRotationLockedForAllStates;
@Implementation
public static boolean isDeviceStateRotationLockEnabled(Context context) {
@@ -36,4 +37,13 @@
public static void setDeviceStateRotationLockEnabled(boolean enabled) {
sDeviceStateRotationLockEnabled = enabled;
}
+
+ @Implementation
+ public boolean isRotationLockedForAllStates() {
+ return mIsRotationLockedForAllStates;
+ }
+
+ public void setRotationLockedForAllStates(boolean value) {
+ mIsRotationLockedForAllStates = value;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchBarTest.java b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchBarTest.java
new file mode 100644
index 0000000..dc69d8e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchBarTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.widget.TextView;
+
+import com.android.settingslib.R;
+import com.android.settingslib.RestrictedLockUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class SettingsMainSwitchBarTest {
+
+ private SettingsMainSwitchBar mMainSwitchBar;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ final Context context = RuntimeEnvironment.application;
+ mMainSwitchBar = new SettingsMainSwitchBar(context);
+ }
+
+ @Test
+ public void disabledByAdmin_shouldBeDisabled() {
+ mMainSwitchBar.setDisabledByAdmin(new RestrictedLockUtils.EnforcedAdmin());
+
+ TextView title = (TextView) mMainSwitchBar.findViewById(R.id.switch_text);
+ assertThat(title.isEnabled()).isFalse();
+ assertThat(mMainSwitchBar.getSwitch().isEnabled()).isFalse();
+ }
+
+ @Test
+ public void disabledByAdmin_setNull_shouldBeEnabled() {
+ mMainSwitchBar.setDisabledByAdmin(null);
+
+ TextView title = (TextView) mMainSwitchBar.findViewById(R.id.switch_text);
+ assertThat(title.isEnabled()).isTrue();
+ assertThat(mMainSwitchBar.getSwitch().isEnabled()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
index 0a54c88..fe663ab 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
@@ -16,10 +16,12 @@
package com.android.settings.wifi.tether;
+import static android.net.wifi.SoftApConfiguration.SECURITY_TYPE_WPA3_SAE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static com.android.settings.wifi.WifiUtils.setCanShowWifiHotspotCached;
+import static com.android.settings.wifi.repository.WifiHotspotRepository.BAND_2GHZ_5GHZ_6GHZ;
import static com.android.settings.wifi.tether.WifiTetherSettings.KEY_WIFI_HOTSPOT_SECURITY;
import static com.android.settings.wifi.tether.WifiTetherSettings.KEY_WIFI_HOTSPOT_SPEED;
@@ -41,6 +43,7 @@
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.TetheringManager;
+import android.net.wifi.SoftApConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.UserManager;
@@ -84,6 +87,8 @@
private static final int XML_RES = R.xml.wifi_tether_settings;
private static final String[] WIFI_REGEXS = {"wifi_regexs"};
+ private static final String SSID = "ssid";
+ private static final String PASSWORD = "password";
@Rule
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
@@ -117,6 +122,12 @@
private LiveData<Integer> mSpeedSummary;
@Mock
private SettingsMainSwitchBar mMainSwitchBar;
+ @Mock
+ private WifiTetherSSIDPreferenceController mSSIDPreferenceController;
+ @Mock
+ private WifiTetherPasswordPreferenceController mPasswordPreferenceController;
+ @Mock
+ private WifiTetherAutoOffPreferenceController mWifiTetherAutoOffPreferenceController;
private WifiTetherSettings mSettings;
@@ -143,6 +154,12 @@
mSettings = spy(new WifiTetherSettings(mWifiRestriction));
mSettings.mMainSwitchBar = mMainSwitchBar;
+ mSettings.mSSIDPreferenceController = mSSIDPreferenceController;
+ when(mSSIDPreferenceController.getSSID()).thenReturn(SSID);
+ mSettings.mPasswordPreferenceController = mPasswordPreferenceController;
+ when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(PASSWORD);
+ mSettings.mWifiTetherAutoOffPreferenceController = mWifiTetherAutoOffPreferenceController;
+ when(mWifiTetherAutoOffPreferenceController.isEnabled()).thenReturn(true);
mSettings.mWifiTetherViewModel = mWifiTetherViewModel;
when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SECURITY)).thenReturn(mWifiHotspotSecurity);
when(mSettings.findPreference(KEY_WIFI_HOTSPOT_SPEED)).thenReturn(mWifiHotspotSpeed);
@@ -327,6 +344,22 @@
}
@Test
+ public void buildNewConfig_speedFeatureIsAvailableAndPasswordChanged_bandShouldNotBeLost() {
+ String newPassword = "new" + PASSWORD;
+ SoftApConfiguration currentConfig = new SoftApConfiguration.Builder()
+ .setPassphrase(PASSWORD, SECURITY_TYPE_WPA3_SAE)
+ .setBand(BAND_2GHZ_5GHZ_6GHZ)
+ .build();
+ when(mWifiTetherViewModel.getSoftApConfiguration()).thenReturn(currentConfig);
+ when(mWifiTetherViewModel.isSpeedFeatureAvailable()).thenReturn(true);
+ when(mPasswordPreferenceController.getPasswordValidated(anyInt())).thenReturn(newPassword);
+
+ SoftApConfiguration newConfig = mSettings.buildNewConfig();
+
+ assertThat(newConfig.getBand()).isEqualTo(currentConfig.getBand());
+ }
+
+ @Test
public void onRestartingChanged_restartingFalse_setLoadingFalse() {
doNothing().when(mSettings).setLoading(anyBoolean(), anyBoolean());
diff --git a/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt
index a1d8d3f..12fdc23 100644
--- a/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt
+++ b/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt
@@ -251,7 +251,7 @@
val summary = repository.getNotificationSummary(APP)
- assertThat(summary).isEqualTo(context.getString(R.string.off))
+ assertThat(summary).isEqualTo(context.getString(R.string.notifications_disabled))
}
@Test
@@ -273,7 +273,7 @@
val summary = repository.getNotificationSummary(APP)
- assertThat(summary).isEqualTo(context.getString(R.string.off))
+ assertThat(summary).isEqualTo(context.getString(R.string.notifications_disabled))
}
@Test
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 2a2aaee..3145cce 100644
--- a/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/credentials/CredentialManagerPreferenceControllerTest.java
@@ -123,6 +123,25 @@
}
@Test
+ public void verifyHiddenIfAutofillSelectedProvider() {
+ CredentialManagerPreferenceController controller =
+ createControllerWithServices(Collections.emptyList());
+
+ // Set the autofill provider.
+ Settings.Secure.putStringForUser(mContext.getContentResolver(),
+ Settings.Secure.AUTOFILL_SERVICE, "com.example.test/AutofillClass",
+ UserHandle.myUserId());
+
+ // Verify the error cases
+ assertThat(controller.isProviderHiddenBecauseOfAutofill(null)).isFalse();
+ assertThat(controller.isProviderHiddenBecauseOfAutofill("")).isFalse();
+ assertThat(controller.isProviderHiddenBecauseOfAutofill("test")).isFalse();
+
+ // Verify the example.
+ assertThat(controller.isProviderHiddenBecauseOfAutofill("com.example.test")).isTrue();
+ }
+
+ @Test
public void displayPreference_noServices_noPreferencesAdded_useAutofillUri() {
Settings.Secure.putStringForUser(
mContext.getContentResolver(),
diff --git a/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java b/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java
index 5b10adf..b0998c0 100644
--- a/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java
+++ b/tests/unit/src/com/android/settings/localepicker/LocaleDialogFragmentTest.java
@@ -38,6 +38,7 @@
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 @@
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 @@
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 @@
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
diff --git a/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java b/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java
index 31b8e79..5ac367e 100644
--- a/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/localepicker/LocaleHelperPreferenceControllerTest.java
@@ -19,12 +19,14 @@
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 @@
public class LocaleHelperPreferenceControllerTest {
private Context mContext;
private LocaleHelperPreferenceController mLocaleHelperPreferenceController;
+ private FakeFeatureFactory mFeatureFactory;
@Mock
private FooterPreference mMockFooterPreference;
@@ -49,11 +52,16 @@
}
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);
+ });
}
}