Merge changes from topic "le_audio_allowlist" into main
* changes:
Config LE audio connection by default
LE Audio Allowlist toggle behavior refactor
Remove allowlist reboot behavior
Change the LE Audio Allowlist toggle wording
diff --git a/aconfig/Android.bp b/aconfig/Android.bp
index 7b571e0..6daa90c 100644
--- a/aconfig/Android.bp
+++ b/aconfig/Android.bp
@@ -12,7 +12,6 @@
"settings_experience_flag_declarations.aconfig",
"settings_onboarding_experience_flag_declarations.aconfig",
"settings_telephony_flag_declarations.aconfig",
- "settings_biometrics_integration_declarations.aconfig",
],
}
diff --git a/aconfig/settings_biometrics_integration_declarations.aconfig b/aconfig/settings_biometrics_integration_declarations.aconfig
deleted file mode 100644
index 529e126..0000000
--- a/aconfig/settings_biometrics_integration_declarations.aconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-package: "com.android.settings.flags"
-
-flag {
- name: "sfps_enroll_refinement"
- namespace: "biometrics_integration"
- description: "This flag controls whether the sfps pause enrollment feature should be enabled"
- bug: "288155127"
-}
-
diff --git a/aconfig/settings_globalintl_flag_declarations.aconfig b/aconfig/settings_globalintl_flag_declarations.aconfig
index 3740dd3..68662d0 100644
--- a/aconfig/settings_globalintl_flag_declarations.aconfig
+++ b/aconfig/settings_globalintl_flag_declarations.aconfig
@@ -2,14 +2,14 @@
flag {
name: "terms_of_address_enabled"
- namespace: "settings_globalintl"
+ namespace: "globalintl"
description: "Feature flag for Terms of Address"
bug: "297798866"
}
flag {
name: "locale_notification_enabled"
- namespace: "settings_globalintl"
+ namespace: "globalintl"
description: "Feature flag for locale notification"
- bug: "248514263"
+ bug: "301380610"
}
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 33bc805..515b571 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -12495,4 +12495,21 @@
<string name="quarantined_apps_title" translatable="false">Quarantined Apps</string>
<!-- Do not translate. Developer settings: Button to unquarantine an app [CHAR LIMIT=20] -->
<string name="unquarantine_app_button" translatable="false">Unquarantine app</string>
+
+ <!-- Title of preference to manage content protection settings -->
+ <string name="content_protection_preference_title">Scanning for deceptive apps</string>
+ <!-- Summary of the preference to manage content protection settings -->
+ <string name="content_protection_preference_summary">Check app activity for phishing</string>
+ <!-- Title of the switch bar on the subpage of content protection settings -->
+ <string name="content_protection_preference_user_consent_switch_title">Use scanning</string>
+ <!-- Title of the toggle switch of work apps on the subpage of content protection settings -->
+ <string name="content_protection_preference_user_consent_work_profile_switch_title">Use scanning for work apps</string>
+ <!-- Summary of the subpage of content protection settings -->
+ <string name="content_protection_preference_subpage_summary">Scanning runs privately right on your device, checking app activity for phishing or other deceptive behavior. If it\’s detected, some app info is sent to Google Play Protect to confirm the threat and warn app users.</string>
+ <!-- Information at the bottom of the subpage of content protection settings -->
+ <string name="content_protection_preference_subpage_info">
+ <![CDATA[
+ This is a protected security feature. No device or personal info is shared with Google.
+ \n\nPhishing is an attempt to steal sign-in credentials or other personal info.
+ ]]></string>
</resources>
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index b08bc61..de06806 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -95,6 +95,9 @@
private static final String ALTERNATE_INTENT = "android.settings.SYNC_SETTINGS";
private static final String PRIMARY_INTENT = "android.settings.CREDENTIAL_PROVIDER";
private static final int MAX_SELECTABLE_PROVIDERS = 5;
+ private static final String SETTINGS_ACTIVITY_INTENT_ACTION = "android.intent.action.MAIN";
+ private static final String SETTINGS_ACTIVITY_INTENT_CATEGORY =
+ "android.intent.category.LAUNCHER";
private final PackageManager mPm;
private final List<CredentialProviderInfo> mServices;
@@ -481,13 +484,22 @@
continue;
}
+ // Get the settings activity.
+ CharSequence settingsActivity =
+ combinedInfo.getCredentialProviderInfos().get(0).getSettingsActivity();
+
Drawable icon = combinedInfo.getAppIcon(context, getUser());
CharSequence title = combinedInfo.getAppName(context);
// Build the pref and add it to the output & group.
CombiPreference pref =
addProviderPreference(
- context, title, icon, packageName, combinedInfo.getSettingsSubtitle());
+ context,
+ title == null ? "" : title,
+ icon,
+ packageName,
+ combinedInfo.getSettingsSubtitle(),
+ settingsActivity);
output.put(packageName, pref);
group.addPreference(pref);
}
@@ -507,7 +519,8 @@
label == null ? "" : label,
service.getServiceIcon(mContext),
service.getServiceInfo().packageName,
- service.getSettingsSubtitle());
+ service.getSettingsSubtitle(),
+ service.getSettingsActivity());
}
/**
@@ -566,7 +579,8 @@
@NonNull CharSequence title,
@Nullable Drawable icon,
@NonNull String packageName,
- @Nullable CharSequence subtitle) {
+ @Nullable CharSequence subtitle,
+ @Nullable CharSequence settingsActivity) {
final CombiPreference pref =
new CombiPreference(prefContext, mEnabledPackageNames.contains(packageName));
pref.setTitle(title);
@@ -582,29 +596,73 @@
}
pref.setPreferenceListener(
- (p, isChecked) -> {
- if (isChecked) {
- if (mEnabledPackageNames.size() >= MAX_SELECTABLE_PROVIDERS) {
- // Show the error if too many enabled.
- pref.setChecked(false);
- final DialogFragment fragment = newErrorDialogFragment();
+ new CombiPreference.OnCombiPreferenceClickListener() {
+ @Override
+ public void onCheckChanged(CombiPreference p, boolean isChecked) {
+ if (isChecked) {
+ if (mEnabledPackageNames.size() >= MAX_SELECTABLE_PROVIDERS) {
+ // Show the error if too many enabled.
+ pref.setChecked(false);
+ final DialogFragment fragment = newErrorDialogFragment();
- if (fragment == null || mFragmentManager == null) {
+ if (fragment == null || mFragmentManager == null) {
+ return;
+ }
+
+ fragment.show(mFragmentManager, ErrorDialogFragment.TAG);
return;
}
- fragment.show(mFragmentManager, ErrorDialogFragment.TAG);
+ togglePackageNameEnabled(packageName);
+
+ // Enable all prefs.
+ if (mPrefs.containsKey(packageName)) {
+ mPrefs.get(packageName).setChecked(true);
+ }
+ } else {
+ togglePackageNameDisabled(packageName);
+ }
+ }
+
+ @Override
+ public void onLeftSideClicked() {
+ if (settingsActivity == null) {
+ Log.w(TAG, "settingsActivity was null");
return;
}
- togglePackageNameEnabled(packageName);
-
- // Enable all prefs.
- if (mPrefs.containsKey(packageName)) {
- mPrefs.get(packageName).setChecked(true);
+ String settingsActivityStr = String.valueOf(settingsActivity);
+ ComponentName cn = ComponentName.unflattenFromString(settingsActivityStr);
+ if (cn == null) {
+ Log.w(
+ TAG,
+ "Failed to deserialize settingsActivity attribute, we got: "
+ + settingsActivityStr);
+ return;
}
- } else {
- togglePackageNameDisabled(packageName);
+
+ Intent intent = new Intent(SETTINGS_ACTIVITY_INTENT_ACTION);
+ intent.addCategory(SETTINGS_ACTIVITY_INTENT_CATEGORY);
+ intent.setComponent(cn);
+
+ Context context = mContext;
+ int currentUserId = getUser();
+ int contextUserId = context.getUser().getIdentifier();
+
+ if (currentUserId != contextUserId) {
+ Log.d(
+ TAG,
+ "onLeftSideClicked(): using context for current user ("
+ + currentUserId
+ + ") instead of user "
+ + contextUserId
+ + " on headless system user mode");
+ context =
+ context.createContextAsUser(
+ UserHandle.of(currentUserId), /* flags= */ 0);
+ }
+
+ context.startActivity(intent);
}
});
@@ -920,6 +978,9 @@
public interface OnCombiPreferenceClickListener {
/** Called when the check is updated */
void onCheckChanged(CombiPreference p, boolean isChecked);
+
+ /** Called when the left side is clicked. */
+ void onLeftSideClicked();
}
public CombiPreference(Context context, boolean initialValue) {
@@ -968,6 +1029,18 @@
// Store this for later.
mSwitch = switchView;
}
+
+ super.setOnPreferenceClickListener(
+ new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (mOnClickListener != null) {
+ mOnClickListener.onLeftSideClicked();
+ }
+
+ return true;
+ }
+ });
}
}
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 1d84f7d..be2a948 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -68,13 +68,10 @@
import com.android.settings.biometrics.BiometricEnrollSidecar;
import com.android.settings.biometrics.BiometricUtils;
import com.android.settings.biometrics.BiometricsEnrollEnrolling;
-import com.android.settings.biometrics.fingerprint.feature.SfpsEnrollmentFeature;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.display.DisplayDensityUtils;
import com.airbnb.lottie.LottieAnimationView;
-import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.LottieCompositionFactory;
import com.airbnb.lottie.LottieProperty;
import com.airbnb.lottie.model.KeyPath;
@@ -102,22 +99,27 @@
private static final int PROGRESS_BAR_MAX = 10000;
- public static final int STAGE_UNKNOWN = -1;
+ private static final int STAGE_UNKNOWN = -1;
private static final int STAGE_CENTER = 0;
private static final int STAGE_GUIDED = 1;
private static final int STAGE_FINGERTIP = 2;
private static final int STAGE_LEFT_EDGE = 3;
private static final int STAGE_RIGHT_EDGE = 4;
- public static final int SFPS_STAGE_NO_ANIMATION = 0;
+ @VisibleForTesting
+ protected static final int SFPS_STAGE_NO_ANIMATION = 0;
- public static final int SFPS_STAGE_CENTER = 1;
+ @VisibleForTesting
+ protected static final int SFPS_STAGE_CENTER = 1;
- public static final int SFPS_STAGE_FINGERTIP = 2;
+ @VisibleForTesting
+ protected static final int SFPS_STAGE_FINGERTIP = 2;
- public static final int SFPS_STAGE_LEFT_EDGE = 3;
+ @VisibleForTesting
+ protected static final int SFPS_STAGE_LEFT_EDGE = 3;
- public static final int SFPS_STAGE_RIGHT_EDGE = 4;
+ @VisibleForTesting
+ protected static final int SFPS_STAGE_RIGHT_EDGE = 4;
@IntDef({STAGE_UNKNOWN, STAGE_CENTER, STAGE_GUIDED, STAGE_FINGERTIP, STAGE_LEFT_EDGE,
STAGE_RIGHT_EDGE})
@@ -194,8 +196,6 @@
private OrientationEventListener mOrientationEventListener;
private int mPreviousRotation = 0;
- private SfpsEnrollmentFeature mSfpsEnrollmentFeature;
-
@VisibleForTesting
protected boolean shouldShowLottie() {
DisplayDensityUtils displayDensity = new DisplayDensityUtils(getApplicationContext());
@@ -232,11 +232,6 @@
mAccessibilityManager = getSystemService(AccessibilityManager.class);
mIsAccessibilityEnabled = mAccessibilityManager.isEnabled();
- mSfpsEnrollmentFeature = mCanAssumeSfps
- ? FeatureFactory.getFeatureFactory()
- .getFingerprintFeatureProvider().getSfpsEnrollmentFeature()
- : null;
-
listenOrientationEvent();
if (mCanAssumeUdfps) {
@@ -604,8 +599,7 @@
}
switch (getCurrentSfpsStage()) {
case SFPS_STAGE_NO_ANIMATION:
- setHeaderText(mSfpsEnrollmentFeature
- .getFeaturedStageHeaderResource(SFPS_STAGE_NO_ANIMATION));
+ setHeaderText(R.string.security_settings_fingerprint_enroll_repeat_title);
if (!mHaveShownSfpsNoAnimationLottie && mIllustrationLottie != null) {
mHaveShownSfpsNoAnimationLottie = true;
mIllustrationLottie.setContentDescription(
@@ -614,48 +608,39 @@
0
)
);
- configureEnrollmentStage(mSfpsEnrollmentFeature
- .getSfpsEnrollLottiePerStage(SFPS_STAGE_NO_ANIMATION));
+ configureEnrollmentStage(R.raw.sfps_lottie_no_animation);
}
break;
case SFPS_STAGE_CENTER:
- setHeaderText(mSfpsEnrollmentFeature
- .getFeaturedStageHeaderResource(SFPS_STAGE_CENTER));
+ setHeaderText(R.string.security_settings_sfps_enroll_finger_center_title);
if (!mHaveShownSfpsCenterLottie && mIllustrationLottie != null) {
mHaveShownSfpsCenterLottie = true;
- configureEnrollmentStage(mSfpsEnrollmentFeature
- .getSfpsEnrollLottiePerStage(SFPS_STAGE_CENTER));
+ configureEnrollmentStage(R.raw.sfps_lottie_pad_center);
}
break;
case SFPS_STAGE_FINGERTIP:
- setHeaderText(mSfpsEnrollmentFeature
- .getFeaturedStageHeaderResource(SFPS_STAGE_FINGERTIP));
+ setHeaderText(R.string.security_settings_sfps_enroll_fingertip_title);
if (!mHaveShownSfpsTipLottie && mIllustrationLottie != null) {
mHaveShownSfpsTipLottie = true;
- configureEnrollmentStage(mSfpsEnrollmentFeature
- .getSfpsEnrollLottiePerStage(SFPS_STAGE_FINGERTIP));
+ configureEnrollmentStage(R.raw.sfps_lottie_tip);
}
break;
case SFPS_STAGE_LEFT_EDGE:
- setHeaderText(mSfpsEnrollmentFeature
- .getFeaturedStageHeaderResource(SFPS_STAGE_LEFT_EDGE));
+ setHeaderText(R.string.security_settings_sfps_enroll_left_edge_title);
if (!mHaveShownSfpsLeftEdgeLottie && mIllustrationLottie != null) {
mHaveShownSfpsLeftEdgeLottie = true;
- configureEnrollmentStage(mSfpsEnrollmentFeature
- .getSfpsEnrollLottiePerStage(SFPS_STAGE_LEFT_EDGE));
+ configureEnrollmentStage(R.raw.sfps_lottie_left_edge);
}
break;
case SFPS_STAGE_RIGHT_EDGE:
- setHeaderText(mSfpsEnrollmentFeature
- .getFeaturedStageHeaderResource(SFPS_STAGE_RIGHT_EDGE));
+ setHeaderText(R.string.security_settings_sfps_enroll_right_edge_title);
if (!mHaveShownSfpsRightEdgeLottie && mIllustrationLottie != null) {
mHaveShownSfpsRightEdgeLottie = true;
- configureEnrollmentStage(mSfpsEnrollmentFeature
- .getSfpsEnrollLottiePerStage(SFPS_STAGE_RIGHT_EDGE));
+ configureEnrollmentStage(R.raw.sfps_lottie_right_edge);
}
break;
@@ -676,23 +661,15 @@
}
@VisibleForTesting void configureEnrollmentStage(@RawRes int lottie) {
- if (lottie == STAGE_UNKNOWN) return;
if (!mCanAssumeSfps) {
setDescriptionText("");
}
LottieCompositionFactory.fromRawRes(this, lottie)
- .addListener((c) -> onLottieComposition(mIllustrationLottie, c));
- }
-
- private void onLottieComposition(LottieAnimationView view, LottieComposition composition) {
- if (view == null || composition == null) {
- return;
- }
- view.setComposition(composition);
- view.setVisibility(View.VISIBLE);
- view.playAnimation();
- mSfpsEnrollmentFeature.handleOnEnrollmentLottieComposition(
- view, composition, getCurrentSfpsStage());
+ .addListener((c) -> {
+ mIllustrationLottie.setComposition(c);
+ mIllustrationLottie.setVisibility(View.VISIBLE);
+ mIllustrationLottie.playAnimation();
+ });
}
@EnrollStage
@@ -722,8 +699,17 @@
}
final int progressSteps = mSidecar.getEnrollmentSteps() - mSidecar.getEnrollmentRemaining();
- return mSfpsEnrollmentFeature
- .getCurrentSfpsEnrollStage(progressSteps, this::getStageThresholdSteps);
+ if (progressSteps < getStageThresholdSteps(0)) {
+ return SFPS_STAGE_NO_ANIMATION;
+ } else if (progressSteps < getStageThresholdSteps(1)) {
+ return SFPS_STAGE_CENTER;
+ } else if (progressSteps < getStageThresholdSteps(2)) {
+ return SFPS_STAGE_FINGERTIP;
+ } else if (progressSteps < getStageThresholdSteps(3)) {
+ return SFPS_STAGE_LEFT_EDGE;
+ } else {
+ return SFPS_STAGE_RIGHT_EDGE;
+ }
}
private boolean isStageHalfCompleted() {
@@ -754,26 +740,22 @@
Log.w(TAG, "getStageThresholdSteps: Enrollment not started yet");
return 1;
}
- final float threshold = mSfpsEnrollmentFeature.getEnrollStageThreshold(this, index);
- return Math.round(mSidecar.getEnrollmentSteps() * threshold);
+ return Math.round(mSidecar.getEnrollmentSteps()
+ * mFingerprintManager.getEnrollStageThreshold(index));
}
@Override
public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) {
- final CharSequence featuredString = mSfpsEnrollmentFeature
- .getFeaturedVendorString(this, helpMsgId, helpString);
-
- if (!TextUtils.isEmpty(featuredString)) {
+ if (!TextUtils.isEmpty(helpString)) {
if (!(mCanAssumeUdfps || mCanAssumeSfps)) {
mErrorText.removeCallbacks(mTouchAgainRunnable);
}
- showError(featuredString);
+ showError(helpString);
if (mUdfpsEnrollHelper != null) mUdfpsEnrollHelper.onEnrollmentHelp();
}
dismissTouchDialogIfSfps();
- mSfpsEnrollmentFeature.handleOnEnrollmentHelp(helpMsgId, featuredString, () -> this);
}
@Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintFeatureProvider.java b/src/com/android/settings/biometrics/fingerprint/FingerprintFeatureProvider.java
deleted file mode 100644
index 906f95a..0000000
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintFeatureProvider.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.biometrics.fingerprint;
-
-import com.android.settings.biometrics.fingerprint.feature.SfpsEnrollmentFeature;
-
-public interface FingerprintFeatureProvider {
- /**
- * Gets the feature implementation of SFPS enrollment.
- * @return the feature implementation
- */
- SfpsEnrollmentFeature getSfpsEnrollmentFeature();
-}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintFeatureProviderImpl.java b/src/com/android/settings/biometrics/fingerprint/FingerprintFeatureProviderImpl.java
deleted file mode 100644
index 27c216d..0000000
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintFeatureProviderImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.biometrics.fingerprint;
-
-import com.android.settings.biometrics.fingerprint.feature.SfpsEnrollmentFeature;
-import com.android.settings.biometrics.fingerprint.feature.SfpsEnrollmentFeatureImpl;
-
-public class FingerprintFeatureProviderImpl implements FingerprintFeatureProvider {
-
- private SfpsEnrollmentFeature mSfpsEnrollmentFeatureImpl;
-
- @Override
- public SfpsEnrollmentFeature getSfpsEnrollmentFeature() {
- if (mSfpsEnrollmentFeatureImpl == null) {
- mSfpsEnrollmentFeatureImpl = new SfpsEnrollmentFeatureImpl();
- }
- return mSfpsEnrollmentFeatureImpl;
- }
-}
diff --git a/src/com/android/settings/biometrics/fingerprint/feature/SfpsEnrollmentFeature.java b/src/com/android/settings/biometrics/fingerprint/feature/SfpsEnrollmentFeature.java
deleted file mode 100644
index 10177db..0000000
--- a/src/com/android/settings/biometrics/fingerprint/feature/SfpsEnrollmentFeature.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.biometrics.fingerprint.feature;
-
-import android.content.Context;
-
-import androidx.annotation.NonNull;
-
-import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
-
-import com.airbnb.lottie.LottieAnimationView;
-import com.airbnb.lottie.LottieComposition;
-
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-public interface SfpsEnrollmentFeature {
-
- /**
- * Gets current SFPS enrollment stage.
- * @param progressSteps current step of enrollment
- * @param mapper a mapper to map each stage to its threshold
- * @return current enrollment stage
- */
- int getCurrentSfpsEnrollStage(int progressSteps, Function<Integer, Integer> mapper);
-
- /**
- * Gets the vendor string by feature.
- * @param context Context
- * @param id An integer identifying the error message
- * @param msg A human-readable string that can be shown in UI
- * @return A human-readable string of specific feature
- */
- default CharSequence getFeaturedVendorString(Context context, int id, CharSequence msg) {
- return msg;
- }
-
- /**
- * Gets the stage header string by feature.
- * @param stage the specific stage
- * @return the resource id of the header text of the specific stage
- */
- int getFeaturedStageHeaderResource(int stage);
-
- /**
- * Gets the enrollment lottie resource id per stage
- * @param stage current enrollment stage
- * @return enrollment lottie resource id
- */
- int getSfpsEnrollLottiePerStage(int stage);
-
- /**
- * Handles extra stuffs on lottie composition.
- * @param animView the view related to the lottie
- * @param composition lottie composition
- * @param stage current enrollment stage
- */
- default void handleOnEnrollmentLottieComposition(
- LottieAnimationView animView, LottieComposition composition, int stage) {}
-
- /**
- * Handles extra stuffs on receiving enrollment help.
- * @param helpMsgId help message id
- * @param helpString help message
- * @param enrollingSupplier supplier of enrolling context
- */
- default void handleOnEnrollmentHelp(int helpMsgId, CharSequence helpString,
- Supplier<FingerprintEnrollEnrolling> enrollingSupplier) {}
-
- /**
- * Gets the fingerprint enrollment threshold.
- * @param context context
- * @param index the enrollment stage index
- * @return threshold
- */
- float getEnrollStageThreshold(@NonNull Context context, int index);
-}
diff --git a/src/com/android/settings/biometrics/fingerprint/feature/SfpsEnrollmentFeatureImpl.java b/src/com/android/settings/biometrics/fingerprint/feature/SfpsEnrollmentFeatureImpl.java
deleted file mode 100644
index 2e24482..0000000
--- a/src/com/android/settings/biometrics/fingerprint/feature/SfpsEnrollmentFeatureImpl.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.biometrics.fingerprint.feature;
-
-import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.SFPS_STAGE_CENTER;
-import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.SFPS_STAGE_FINGERTIP;
-import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.SFPS_STAGE_LEFT_EDGE;
-import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.SFPS_STAGE_NO_ANIMATION;
-import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.SFPS_STAGE_RIGHT_EDGE;
-import static com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling.STAGE_UNKNOWN;
-
-import android.content.Context;
-import android.hardware.fingerprint.FingerprintManager;
-
-import androidx.annotation.NonNull;
-
-import com.android.settings.R;
-
-import java.util.function.Function;
-
-public class SfpsEnrollmentFeatureImpl implements SfpsEnrollmentFeature {
-
- private FingerprintManager mFingerprintManager;
-
- @Override
- public int getCurrentSfpsEnrollStage(int progressSteps, Function<Integer, Integer> mapper) {
- if (mapper == null) {
- return STAGE_UNKNOWN;
- }
- if (progressSteps < mapper.apply(0)) {
- return SFPS_STAGE_NO_ANIMATION;
- } else if (progressSteps < mapper.apply(1)) {
- return SFPS_STAGE_CENTER;
- } else if (progressSteps < mapper.apply(2)) {
- return SFPS_STAGE_FINGERTIP;
- } else if (progressSteps < mapper.apply(3)) {
- return SFPS_STAGE_LEFT_EDGE;
- } else {
- return SFPS_STAGE_RIGHT_EDGE;
- }
- }
-
- @Override
- public int getFeaturedStageHeaderResource(int stage) {
- return switch (stage) {
- case SFPS_STAGE_NO_ANIMATION
- -> R.string.security_settings_fingerprint_enroll_repeat_title;
- case SFPS_STAGE_CENTER -> R.string.security_settings_sfps_enroll_finger_center_title;
- case SFPS_STAGE_FINGERTIP -> R.string.security_settings_sfps_enroll_fingertip_title;
- case SFPS_STAGE_LEFT_EDGE -> R.string.security_settings_sfps_enroll_left_edge_title;
- case SFPS_STAGE_RIGHT_EDGE -> R.string.security_settings_sfps_enroll_right_edge_title;
- default -> throw new IllegalArgumentException("Invalid stage: " + stage);
- };
- }
-
- @Override
- public int getSfpsEnrollLottiePerStage(int stage) {
- return switch (stage) {
- case SFPS_STAGE_NO_ANIMATION -> R.raw.sfps_lottie_no_animation;
- case SFPS_STAGE_CENTER -> R.raw.sfps_lottie_pad_center;
- case SFPS_STAGE_FINGERTIP -> R.raw.sfps_lottie_tip;
- case SFPS_STAGE_LEFT_EDGE -> R.raw.sfps_lottie_left_edge;
- case SFPS_STAGE_RIGHT_EDGE -> R.raw.sfps_lottie_right_edge;
- default -> throw new IllegalArgumentException("Invalid stage: " + stage);
- };
- }
-
- @Override
- public float getEnrollStageThreshold(@NonNull Context context, int index) {
- if (mFingerprintManager == null) {
- mFingerprintManager = context.getSystemService(FingerprintManager.class);
- }
- return mFingerprintManager.getEnrollStageThreshold(index);
- }
-}
diff --git a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
index 95cf64c..992136c 100644
--- a/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
+++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverController.java
@@ -170,9 +170,10 @@
((SwitchPreference) mPreference).setChecked(false);
}
- // Regardless of whether ANGLE is enabled, disable the developer option UI
- // as long as UI is not enabled via debug property.
- if (!isAngleDeveloperOptionEnabled()) {
+ // Disable the developer option toggle UI if ANGLE is disabled, this means next time the
+ // debug property needs to be set to true again to enable ANGLE. If ANGLE is enabled, don't
+ // disable the developer option toggle UI so that it can be turned off easily.
+ if (!isAngleDeveloperOptionEnabled() && !((SwitchPreference) mPreference).isChecked()) {
mPreference.setEnabled(false);
}
}
diff --git a/src/com/android/settings/overlay/FeatureFactory.kt b/src/com/android/settings/overlay/FeatureFactory.kt
index ac689d9..7645076 100644
--- a/src/com/android/settings/overlay/FeatureFactory.kt
+++ b/src/com/android/settings/overlay/FeatureFactory.kt
@@ -21,7 +21,6 @@
import com.android.settings.accounts.AccountFeatureProvider
import com.android.settings.applications.ApplicationFeatureProvider
import com.android.settings.biometrics.face.FaceFeatureProvider
-import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
import com.android.settings.bluetooth.BluetoothFeatureProvider
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
@@ -105,17 +104,9 @@
*/
abstract val bluetoothFeatureProvider: BluetoothFeatureProvider
- /**
- * Retrieves implementation for Face feature.
- */
abstract val faceFeatureProvider: FaceFeatureProvider
/**
- * Retrieves implementation for Fingerprint feature.
- */
- abstract val fingerprintFeatureProvider: FingerprintFeatureProvider
-
- /**
* Gets implementation for Biometrics repository provider.
*/
abstract val biometricsRepositoryProvider: BiometricsRepositoryProvider
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.kt b/src/com/android/settings/overlay/FeatureFactoryImpl.kt
index 7f991b7..0afe9f4 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.kt
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.kt
@@ -29,8 +29,6 @@
import com.android.settings.applications.ApplicationFeatureProviderImpl
import com.android.settings.biometrics.face.FaceFeatureProvider
import com.android.settings.biometrics.face.FaceFeatureProviderImpl
-import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
-import com.android.settings.biometrics.fingerprint.FingerprintFeatureProviderImpl
import com.android.settings.biometrics2.factory.BiometricsRepositoryProviderImpl
import com.android.settings.bluetooth.BluetoothFeatureProvider
import com.android.settings.bluetooth.BluetoothFeatureProviderImpl
@@ -147,10 +145,6 @@
override val faceFeatureProvider: FaceFeatureProvider by lazy { FaceFeatureProviderImpl() }
- override val fingerprintFeatureProvider: FingerprintFeatureProvider by lazy {
- FingerprintFeatureProviderImpl()
- }
-
override val biometricsRepositoryProvider by lazy { BiometricsRepositoryProviderImpl() }
override val wifiTrackerLibProvider: WifiTrackerLibProvider by lazy {
diff --git a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
index 76fed9b..8c78e80 100644
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
@@ -72,6 +72,10 @@
@Override
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
final int privacy = Integer.parseInt((String) newValue);
+ if (mWifiEntry.getPrivacy() == privacy) {
+ // Prevent disconnection + reconnection if settings not changed.
+ return true;
+ }
mWifiEntry.setPrivacy(privacy);
// To activate changing, we need to reconnect network. WiFi will auto connect to
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 72e9b54..f0b2fbe 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -57,7 +57,6 @@
import com.google.common.truth.Correspondence;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -78,7 +77,6 @@
ShadowUserManager.class,
ShadowStorageManager.class,
ShadowSettings.ShadowSecure.class,
- com.android.settings.testutils.shadow.ShadowFragment.class,
})
public class ToggleScreenMagnificationPreferenceFragmentTest {
@@ -101,7 +99,6 @@
private static final String KEY_FOLLOW_TYPING =
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED;
-
private FragmentController<ToggleScreenMagnificationPreferenceFragment> mFragController;
private Context mContext;
private Resources mSpyResources;
@@ -109,6 +106,7 @@
@Before
public void setUpTestFragment() {
+
mContext = ApplicationProvider.getApplicationContext();
// Set up the fragment that support window magnification feature
@@ -130,7 +128,6 @@
}
@Test
- @Ignore
public void onResume_defaultStateForFollowingTyping_switchPreferenceShouldReturnTrue() {
setKeyFollowTypingEnabled(true);
@@ -144,7 +141,6 @@
}
@Test
- @Ignore
public void onResume_disableFollowingTyping_switchPreferenceShouldReturnFalse() {
setKeyFollowTypingEnabled(false);
@@ -158,7 +154,6 @@
}
@Test
- @Ignore
public void onResume_haveRegisterToSpecificUris() {
ShadowContentResolver shadowContentResolver = Shadows.shadowOf(
mContext.getContentResolver());
@@ -187,7 +182,6 @@
}
@Test
- @Ignore
public void hasValueInSettings_putValue_hasValue() {
setMagnificationTripleTapEnabled(/* enabled= */ true);
@@ -196,7 +190,6 @@
}
@Test
- @Ignore
public void optInAllValuesToSettings_optInValue_haveMatchString() {
int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP;
@@ -210,7 +203,6 @@
}
@Test
- @Ignore
public void optInAllValuesToSettings_existOtherValue_optInValue_haveMatchString() {
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, PLACEHOLDER_COMPONENT_NAME.flattenToString());
@@ -222,7 +214,6 @@
}
@Test
- @Ignore
public void optInAllValuesToSettings_software_sizeValueIsNull_putLargeSizeValue() {
ShadowSettings.ShadowSecure.reset();
@@ -236,7 +227,6 @@
}
@Test
- @Ignore
public void optInAllValuesToSettings_software_sizeValueIsNotNull_sizeValueIsNotChanged() {
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.LARGE,
FloatingMenuSizePreferenceController.Size.SMALL}) {
@@ -255,7 +245,6 @@
}
@Test
- @Ignore
public void optInAllValuesToSettings_hardware_sizeValueIsNotChanged() {
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
FloatingMenuSizePreferenceController.Size.LARGE,
@@ -274,7 +263,6 @@
}
@Test
- @Ignore
public void optInAllValuesToSettings_tripletap_sizeValueIsNotChanged() {
for (int size : new int[] {FloatingMenuSizePreferenceController.Size.UNKNOWN,
FloatingMenuSizePreferenceController.Size.LARGE,
@@ -293,7 +281,6 @@
}
@Test
- @Ignore
public void optOutAllValuesToSettings_optOutValue_emptyString() {
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
@@ -310,7 +297,6 @@
}
@Test
- @Ignore
public void optOutValueFromSettings_existOtherValue_optOutValue_haveMatchString() {
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY,
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
@@ -328,7 +314,6 @@
}
@Test
- @Ignore
public void updateShortcutPreferenceData_assignDefaultValueToVariable() {
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
@@ -341,7 +326,6 @@
}
@Test
- @Ignore
public void updateShortcutPreferenceData_hasValueInSettings_assignToVariable() {
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
setMagnificationTripleTapEnabled(/* enabled= */ true);
@@ -355,7 +339,6 @@
}
@Test
- @Ignore
public void updateShortcutPreferenceData_hasValueInSharedPreference_assignToVariable() {
final PreferredShortcut tripleTapShortcut = new PreferredShortcut(
MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TRIPLETAP);
@@ -370,7 +353,6 @@
}
@Test
- @Ignore
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
ToggleScreenMagnificationPreferenceFragment fragment =
mFragController.create(R.id.main_content, /* bundle= */
@@ -386,7 +368,6 @@
}
@Test
- @Ignore
public void setupMagnificationEditShortcutDialog_shortcutPreferenceOn_checkboxIsSavedValue() {
ToggleScreenMagnificationPreferenceFragment fragment =
mFragController.create(R.id.main_content, /* bundle= */
@@ -407,7 +388,6 @@
}
@Test
- @Ignore
public void restoreValueFromSavedInstanceState_assignToVariable() {
final Bundle fragmentState = createFragmentSavedInstanceState(
UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
@@ -429,7 +409,6 @@
}
@Test
- @Ignore
public void onCreateView_magnificationAreaNotSupported_settingsPreferenceIsNull() {
setWindowMagnificationSupported(
/* magnificationAreaSupported= */ false,
@@ -441,7 +420,6 @@
}
@Test
- @Ignore
public void onCreateView_windowMagnificationNotSupported_settingsPreferenceIsNull() {
setWindowMagnificationSupported(
/* magnificationAreaSupported= */ true,
@@ -453,7 +431,6 @@
}
@Test
- @Ignore
public void onCreateView_setDialogDelegateAndAddTheControllerToLifeCycleObserver() {
Correspondence instanceOf = Correspondence.transforming(
observer -> (observer instanceof MagnificationModePreferenceController),
@@ -471,7 +448,6 @@
}
@Test
- @Ignore
public void onCreateDialog_setDialogDelegate_invokeDialogDelegate() {
ToggleScreenMagnificationPreferenceFragment fragment =
mFragController.create(
@@ -488,7 +464,6 @@
}
@Test
- @Ignore
public void getMetricsCategory_returnsCorrectCategory() {
ToggleScreenMagnificationPreferenceFragment fragment =
mFragController.create(
@@ -499,7 +474,6 @@
}
@Test
- @Ignore
public void getHelpResource_returnsCorrectHelpResource() {
ToggleScreenMagnificationPreferenceFragment fragment =
mFragController.create(
@@ -509,7 +483,6 @@
}
@Test
- @Ignore
public void onProcessArguments_defaultArgumentUnavailable_shouldSetDefaultArguments() {
ToggleScreenMagnificationPreferenceFragment fragment =
mFragController.create(
@@ -524,7 +497,6 @@
}
@Test
- @Ignore
public void getSummary_magnificationEnabled_returnShortcutOnWithSummary() {
setMagnificationTripleTapEnabled(true);
@@ -535,7 +507,6 @@
}
@Test
- @Ignore
public void getSummary_magnificationDisabled_returnShortcutOffWithSummary() {
setMagnificationTripleTapEnabled(false);
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
index 61500d1..4de369e 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrollingTest.java
@@ -53,9 +53,6 @@
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Vibrator;
-import android.platform.test.annotations.RequiresFlagsDisabled;
-import android.platform.test.flag.junit.CheckFlagsRule;
-import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.view.Display;
import android.view.Surface;
import android.view.View;
@@ -65,9 +62,6 @@
import android.widget.TextView;
import com.android.settings.R;
-import com.android.settings.biometrics.fingerprint.feature.SfpsEnrollmentFeatureImpl;
-import com.android.settings.flags.Flags;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.widget.RingProgressBar;
@@ -77,7 +71,6 @@
import org.junit.Before;
import org.junit.Ignore;
-import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -100,8 +93,6 @@
private static final String ENROLL_PROGRESS_COLOR_LIGHT = "#699FF3";
private static final String ENROLL_PROGRESS_COLOR_DARK = "#7DA7F1";
- @Rule
- public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
@Mock private FingerprintManager mFingerprintManager;
@@ -603,23 +594,6 @@
assertThat(getLayout().getDescriptionTextView().getVisibility()).isEqualTo(View.GONE);
}
- @Test
- @RequiresFlagsDisabled(Flags.FLAG_SFPS_ENROLL_REFINEMENT)
- public void testFingerprintFeatureProvider_impl() {
- // We should always get default implementation when the flag is disabled.
- assertThat(FeatureFactory.getFeatureFactory().getFingerprintFeatureProvider())
- .isInstanceOf(FingerprintFeatureProviderImpl.class);
- }
-
- @Test
- @RequiresFlagsDisabled(Flags.FLAG_SFPS_ENROLL_REFINEMENT)
- public void testFingerprintFeatureProvider_sfpsEnrollmentFeatureImpl() {
- // We should always get default implementation when the flag is disabled.
- assertThat(FeatureFactory.getFeatureFactory()
- .getFingerprintFeatureProvider().getSfpsEnrollmentFeature())
- .isInstanceOf(SfpsEnrollmentFeatureImpl.class);
- }
-
private GlifLayout getLayout() {
return (GlifLayout) mActivity.findViewById(R.id.setup_wizard_layout);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
index 5827498..9131051 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetailTest.java
@@ -30,7 +30,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
-import static org.robolectric.shadows.ShadowLooper.shadowMainLooper;
import android.app.AppOpsManager;
import android.app.backup.BackupManager;
@@ -42,7 +41,6 @@
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.os.Process;
import android.os.UserHandle;
import androidx.fragment.app.FragmentActivity;
@@ -77,6 +75,8 @@
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;
+import java.util.concurrent.TimeUnit;
+
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {
ShadowEntityHeaderController.class,
@@ -88,7 +88,6 @@
private static final String SUMMARY = "summary";
private static final String[] PACKAGE_NAME = {"com.android.app"};
private static final String USAGE_PERCENT = "16%";
- private static final String SLOT_TIME = "12 am-2 am";
private static final int ICON_ID = 123;
private static final int UID = 1;
private static final long BACKGROUND_TIME_MS = 100;
@@ -96,7 +95,6 @@
private static final long FOREGROUND_SERVICE_TIME_MS = 444;
private static final long FOREGROUND_TIME_MS =
FOREGROUND_ACTIVITY_TIME_MS + FOREGROUND_SERVICE_TIME_MS;
- private static final long FOREGROUND_SERVICE_TIME_US = FOREGROUND_SERVICE_TIME_MS * 1000;
private static final String KEY_PREF_UNRESTRICTED = "unrestricted_pref";
private static final String KEY_PREF_OPTIMIZED = "optimized_pref";
private static final String KEY_PREF_RESTRICTED = "restricted_pref";
@@ -264,405 +262,6 @@
}
@Test
- public void initHeader_noAnyTimeNoConsumedPower_hasEmptySummary() {
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, /* value */ 0);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEmpty();
- }
-
- @Test
- public void initHeader_noAnyTimeButConsumedPower_hasEmptySummary() {
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, /* value */ 0);
- bundle.putInt(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_AMOUNT, /* value */ 10);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEmpty();
- }
-
- @Test
- public void initHeader_ScreenTimeZerobackgroundTwoMin_hasCorrectSummary() {
- final long backgroundTimeTwoMinutes = 120000;
- final long foregroundTimeZero = 0;
- final long screenOnTimeZero = 0;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeZero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeZero);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString())
- .isEqualTo("Background: 2 min\n(since last full charge)");
- }
-
- @Test
- public void initHeader_ScreenTimeZerobackgroundLessThanAMin_hasCorrectSummary() {
- final long backgroundTimeLessThanAMinute = 59999;
- final long foregroundTimeZero = 0;
- final long screenOnTimeZero = 0;
- Bundle bundle = new Bundle();
- bundle.putLong(
- AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanAMinute);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeZero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeZero);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString())
- .isEqualTo("Background: less than a min\n(since last full charge)");
- }
-
- @Test
- public void initHeader_ScreenTimeAMinuteBackgroundTwoMin_hasCorrectSummary() {
- final long backgroundTimeTwoMinutes = 120000;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeAMinute = 60000;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeAMinute);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: 1 min\nBackground: 2 min\n(since last full charge)");
- }
-
- @Test
- public void initHeader_ScreenTimeAMinuteBackgroundLessThanAMin_hasCorrectSummary() {
- final long backgroundTimeLessThanAMinute = 59999;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeAMinute = 60000;
- Bundle bundle = new Bundle();
- bundle.putLong(
- AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanAMinute);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeAMinute);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: 1 min\nBackground: less than a min\n(since last full charge)");
- }
-
- @Test
- public void initHeader_ScreenTimeAMinuteBackgroundZero_hasCorrectSummary() {
- final long backgroundTimezero = 0;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeAMinute = 60000;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimezero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeAMinute);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: 1 min\n(since last full charge)");
- }
-
- @Test
- public void initHeader_ScreenTimeLessThanAMinBackgroundTwoMin_hasCorrectSummary() {
- final long backgroundTimeTwoMinutes = 120000;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeLessThanAMinute = 59999;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeLessThanAMinute);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: less than a min\nBackground: 2 min\n(since last full charge)");
- }
-
- @Test
- public void initHeader_ScreenTimeLessThanAMinBackgroundLessThanAMin_hasCorrectSummary() {
- final long backgroundTimeLessThanAMinute = 59999;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeLessThanAMinute = 59999;
- Bundle bundle = new Bundle();
- bundle.putLong(
- AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanAMinute);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeLessThanAMinute);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: less than a min\nBackground: less than a min\n(since last full "
- + "charge)");
- }
-
- @Test
- public void initHeader_ScreenTimeLessThanAMinBackgroundZero_hasCorrectSummary() {
- final long backgroundTimezero = 0;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeLessThanAMinute = 59999;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimezero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeLessThanAMinute);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: less than a min\n(since last full charge)");
- }
-
- @Test
- public void initHeader_noAnyTimeNoConsumedPowerWithSlotTime_hasEmptySummary() {
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, /* value */ 0);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEmpty();
- }
-
- @Test
- public void initHeader_noAnyTimeButConsumedPowerWithSlotTime_hasEmptySummary() {
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, /* value */ 0);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, /* value */ 0);
- bundle.putInt(AdvancedPowerUsageDetail.EXTRA_POWER_USAGE_AMOUNT, /* value */ 10);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEmpty();
- }
-
- @Test
- public void initHeader_ScreenTimeZerobackgroundTwoMinWithSlotTime_hasCorrectSummary() {
- final long backgroundTimeTwoMinutes = 120000;
- final long foregroundTimeZero = 0;
- final long screenOnTimeZero = 0;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeZero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeZero);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString())
- .isEqualTo("Background: 2 min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_ScreenTimeZerobackgroundLessThanAMinWithSlotTime_hasCorrectSummary() {
- final long backgroundTimeLessThanAMinute = 59999;
- final long foregroundTimeZero = 0;
- final long screenOnTimeZero = 0;
- Bundle bundle = new Bundle();
- bundle.putLong(
- AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanAMinute);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeZero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeZero);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString())
- .isEqualTo("Background: less than a min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_ScreenTimeAMinuteBackgroundTwoMinWithSlotTime_hasCorrectSummary() {
- final long backgroundTimeTwoMinutes = 120000;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeAMinute = 60000;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeAMinute);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: 1 min\nBackground: 2 min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_ScreenTimeAMinuteBackgroundLessThanAMinWithSlotTime_hasCorrectSummary() {
- final long backgroundTimeLessThanAMinute = 59999;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeAMinute = 60000;
- Bundle bundle = new Bundle();
- bundle.putLong(
- AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanAMinute);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeAMinute);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: 1 min\nBackground: less than a min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_ScreenTimeAMinuteBackgroundZeroWithSlotTime_hasCorrectSummary() {
- final long backgroundTimezero = 0;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeAMinute = 60000;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimezero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeAMinute);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: 1 min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_ScreenTimeLessThanAMinBackgroundTwoMinWithSlotTime_hasCorrectSummary() {
- final long backgroundTimeTwoMinutes = 120000;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeLessThanAMinute = 59999;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeLessThanAMinute);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: less than a min\nBackground: 2 min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_ScreenTimeLessAMinBackgroundLessAMinWithSlotTime_hasCorrectSummary() {
- final long backgroundTimeLessThanAMinute = 59999;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeLessThanAMinute = 59999;
- Bundle bundle = new Bundle();
- bundle.putLong(
- AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimeLessThanAMinute);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeLessThanAMinute);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: less than a min\nBackground: less than a min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_ScreenTimeLessThanAMinBackgroundZeroWithSlotTime_hasCorrectSummary() {
- final long backgroundTimezero = 0;
- final long foregroundTimeTwoMinutes = 120000;
- final long screenOnTimeLessThanAMinute = 59999;
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, backgroundTimezero);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, foregroundTimeTwoMinutes);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, screenOnTimeLessThanAMinute);
- bundle.putString(AdvancedPowerUsageDetail.EXTRA_SLOT_TIME, SLOT_TIME);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue().toString()).isEqualTo(
- "Screen time: less than a min\n(12 am-2 am)");
- }
-
- @Test
- public void initHeader_systemUidWithChartIsEnabled_notNullSummary() {
- Bundle bundle = new Bundle();
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_BACKGROUND_TIME, 240000);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_FOREGROUND_TIME, 120000);
- bundle.putLong(AdvancedPowerUsageDetail.EXTRA_SCREEN_ON_TIME, 120000);
- bundle.putInt(AdvancedPowerUsageDetail.EXTRA_UID, Process.SYSTEM_UID);
- when(mFragment.getArguments()).thenReturn(bundle);
-
- mFragment.initHeader();
-
- ArgumentCaptor<CharSequence> captor = ArgumentCaptor.forClass(CharSequence.class);
- verify(mEntityHeaderController).setSummary(captor.capture());
- assertThat(captor.getValue()).isNotNull();
- }
-
- @Test
public void startBatteryDetailPage_invalidToShowSummary_noFGBDData() {
AdvancedPowerUsageDetail.startBatteryDetailPage(mActivity, mFragment,
mBatteryEntry, USAGE_PERCENT);
@@ -767,7 +366,7 @@
mFragment.onRadioButtonClicked(mOptimizePreference);
mFragment.onPause();
- shadowMainLooper().idle();
+ TimeUnit.SECONDS.sleep(1);
verify(mMetricsFeatureProvider)
.action(
SettingsEnums.OPEN_APP_BATTERY_USAGE,
@@ -791,7 +390,7 @@
mFragment.onRadioButtonClicked(mOptimizePreference);
mFragment.onPause();
- shadowMainLooper().idle();
+ TimeUnit.SECONDS.sleep(1);
verifyNoInteractions(mMetricsFeatureProvider);
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageTimeControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageTimeControllerTest.java
new file mode 100644
index 0000000..2449040
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageTimeControllerTest.java
@@ -0,0 +1,248 @@
+/*
+ * 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.fuelgauge;
+
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+
+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;
+
+@RunWith(RobolectricTestRunner.class)
+public final class PowerUsageTimeControllerTest {
+ private static final String SLOT_TIME = "12 am-2 am";
+ private static final String KEY_SCREEN_ON_TIME_PREF = "battery_usage_screen_time";
+ private static final String KEY_BACKGROUND_TIME_PREF = "battery_usage_background_time";
+ private static final String TEST_ANOMALY_HINT_TEXT = "test_anomaly_hint_text";
+
+ private Context mContext;
+ private PowerUsageTimeController mPowerUsageTimeController;
+
+ @Mock
+ private PreferenceCategory mPowerUsageTimeCategory;
+ @Mock
+ private PowerUsageTimePreference mScreenTimePreference;
+ @Mock
+ private PowerUsageTimePreference mBackgroundTimePreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mPowerUsageTimeController = new PowerUsageTimeController(mContext);
+ mPowerUsageTimeController.mPowerUsageTimeCategory = mPowerUsageTimeCategory;
+ mPowerUsageTimeController.mScreenTimePreference = mScreenTimePreference;
+ mPowerUsageTimeController.mBackgroundTimePreference = mBackgroundTimePreference;
+ doReturn(KEY_SCREEN_ON_TIME_PREF).when(mScreenTimePreference).getKey();
+ doReturn(KEY_BACKGROUND_TIME_PREF).when(mBackgroundTimePreference).getKey();
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_noInfo_prefInvisible() {
+ mPowerUsageTimeController.handleScreenTimeUpdated(/*slotTime=*/ null,
+ /*screenOnTimeInMs=*/ 0, /*backgroundTimeInMs=*/ 0,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyAllPreferencesVisible(false);
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_onlySlotTime_prefInvisible() {
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ /*screenOnTimeInMs=*/ 0, /*backgroundTimeInMs=*/ 0,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyAllPreferencesVisible(false);
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_lackBackgroundTime_onlyScreenOnTime() {
+ final long screenOnTimeAMinute = 60000;
+ final long backgroundTimeZero = 0;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeAMinute, backgroundTimeZero,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyOnePreferenceInvisible(mBackgroundTimePreference);
+ verify(mScreenTimePreference).setTimeTitle("Screen time");
+ verify(mScreenTimePreference).setTimeSummary("1 min");
+ verify(mScreenTimePreference, never()).setAnomalyHint(anyString());
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_lackScreenOnTime_onlyBackgroundTime() {
+ final long screenOnTimeZero = 0;
+ final long backgroundTimeTwoMinutes = 120000;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeZero, backgroundTimeTwoMinutes,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyOnePreferenceInvisible(mScreenTimePreference);
+ verify(mBackgroundTimePreference).setTimeTitle("Background time");
+ verify(mBackgroundTimePreference).setTimeSummary("2 min");
+ verify(mBackgroundTimePreference, never()).setAnomalyHint(anyString());
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_categoryTitleWithSlotTime_expectedResult() {
+ final long screenOnTimeAMinute = 60000;
+ final long backgroundTimeTwoMinutes = 120000;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeAMinute, backgroundTimeTwoMinutes,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyAllPreferencesVisible(true);
+ verify(mScreenTimePreference).setTimeTitle("Screen time");
+ verify(mScreenTimePreference).setTimeSummary("1 min");
+ verify(mScreenTimePreference, never()).setAnomalyHint(anyString());
+ verify(mBackgroundTimePreference).setTimeTitle("Background time");
+ verify(mBackgroundTimePreference).setTimeSummary("2 min");
+ verify(mBackgroundTimePreference, never()).setAnomalyHint(anyString());
+ verify(mPowerUsageTimeCategory).setTitle("App usage for 12 am-2 am");
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_categoryTitleWithoutSlotTime_expectedResult() {
+ final long backgroundTimeTwoMinutes = 120000;
+ final long screenOnTimeAMinute = 60000;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(/*slotTime=*/ null,
+ screenOnTimeAMinute, backgroundTimeTwoMinutes,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyAllPreferencesVisible(true);
+ verify(mPowerUsageTimeCategory).setTitle("App usage since last full charge");
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_BackgroundLessThanAMinWithSlotTime_expectedResult() {
+ final long screenOnTimeAMinute = 60000;
+ final long backgroundTimeLessThanAMinute = 59999;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeAMinute, backgroundTimeLessThanAMinute,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyAllPreferencesVisible(true);
+ verify(mScreenTimePreference).setTimeSummary("1 min");
+ verify(mBackgroundTimePreference).setTimeSummary("Less than a min");
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_ScreenTimeLessThanAMin_expectedResult() {
+ final long screenOnTimeLessThanAMinute = 59999;
+ final long backgroundTimeTwoMinutes = 120000;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeLessThanAMinute, backgroundTimeTwoMinutes,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyAllPreferencesVisible(true);
+ verify(mScreenTimePreference).setTimeSummary("Less than a min");
+ verify(mBackgroundTimePreference).setTimeSummary("2 min");
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_bothLessThanAMin_expectedResult() {
+ final long screenOnTimeLessThanAMinute = 59999;
+ final long backgroundTimeLessThanAMinute = 59999;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeLessThanAMinute, backgroundTimeLessThanAMinute,
+ /*anomalyHintPrefKey=*/ null, /*anomalyHintText=*/ null);
+
+ verifyAllPreferencesVisible(true);
+ verify(mScreenTimePreference).setTimeSummary("Less than a min");
+ verify(mBackgroundTimePreference).setTimeSummary("Less than a min");
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_anomalyOfScreenOnTime_expectedResult() {
+ final long screenOnTimeAMinute = 60000;
+ final long backgroundTimeTwoMinutes = 120000;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeAMinute, backgroundTimeTwoMinutes,
+ KEY_SCREEN_ON_TIME_PREF, TEST_ANOMALY_HINT_TEXT);
+
+ verifyAllPreferencesVisible(true);
+ verify(mScreenTimePreference).setAnomalyHint(TEST_ANOMALY_HINT_TEXT);
+ verify(mBackgroundTimePreference, never()).setAnomalyHint(anyString());
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_anomalyOfBackgroundTime_expectedResult() {
+ final long screenOnTimeAMinute = 60000;
+ final long backgroundTimeTwoMinutes = 120000;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeAMinute, backgroundTimeTwoMinutes,
+ KEY_BACKGROUND_TIME_PREF, TEST_ANOMALY_HINT_TEXT);
+
+ verifyAllPreferencesVisible(true);
+ verify(mScreenTimePreference, never()).setAnomalyHint(anyString());
+ verify(mBackgroundTimePreference).setAnomalyHint(TEST_ANOMALY_HINT_TEXT);
+ }
+
+ @Test
+ public void handleScreenTimeUpdated_anomalyOfScreenOnTimeWithoutTimeInfo_expectedResult() {
+ final long screenOnTimeZero = 0;
+ final long backgroundTimeTwoMinutes = 120000;
+
+ mPowerUsageTimeController.handleScreenTimeUpdated(SLOT_TIME,
+ screenOnTimeZero, backgroundTimeTwoMinutes,
+ KEY_SCREEN_ON_TIME_PREF, TEST_ANOMALY_HINT_TEXT);
+
+ verifyAllPreferencesVisible(true);
+ verify(mScreenTimePreference).setTimeSummary("Less than a min");
+ verify(mScreenTimePreference).setAnomalyHint(TEST_ANOMALY_HINT_TEXT);
+ verify(mBackgroundTimePreference, never()).setAnomalyHint(anyString());
+ }
+
+ private void verifySetPrefToVisible(Preference pref, boolean isVisible) {
+ verify(pref, isVisible ? times(1) : never()).setVisible(true);
+ }
+
+ private void verifyAllPreferencesVisible(boolean isVisible) {
+ verifySetPrefToVisible(mScreenTimePreference, isVisible);
+ verifySetPrefToVisible(mBackgroundTimePreference, isVisible);
+ verifySetPrefToVisible(mPowerUsageTimeCategory, isVisible);
+ }
+
+ private void verifyOnePreferenceInvisible(Preference pref) {
+ verifySetPrefToVisible(mScreenTimePreference, mScreenTimePreference != pref);
+ verifySetPrefToVisible(mBackgroundTimePreference, mBackgroundTimePreference != pref);
+ verifySetPrefToVisible(mPowerUsageTimeCategory, mPowerUsageTimeCategory != pref);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java
deleted file mode 100644
index d3244fa..0000000
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2019 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.wifi.details2;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-
-import androidx.preference.DropDownPreference;
-
-import com.android.settings.R;
-import com.android.wifitrackerlib.WifiEntry;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class WifiPrivacyPreferenceController2Test {
-
- private static final int PRIVACY_RANDOMIZED = WifiEntry.PRIVACY_RANDOMIZED_MAC;
- private static final int PRIVACY_TRUSTED = WifiEntry.PRIVACY_DEVICE_MAC;
-
- @Mock private WifiEntry mMockWifiEntry;
-
- private WifiPrivacyPreferenceController2 mPreferenceController;
- private Context mContext;
- private DropDownPreference mDropDownPreference;
- private String[] mPerferenceStrings;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
-
- mMockWifiEntry = mock(WifiEntry.class);
- WifiPrivacyPreferenceController2 preferenceController =
- new WifiPrivacyPreferenceController2(mContext);
- preferenceController.setWifiEntry(mMockWifiEntry);
- mPreferenceController = spy(preferenceController);
- mDropDownPreference = new DropDownPreference(mContext);
- mDropDownPreference.setEntries(R.array.wifi_privacy_entries);
- mDropDownPreference.setEntryValues(R.array.wifi_privacy_values);
-
- mPerferenceStrings = mContext.getResources().getStringArray(R.array.wifi_privacy_entries);
- }
-
- @Test
- public void testUpdateState_wifiPrivacy_setCorrectValue() {
- doReturn(PRIVACY_TRUSTED).when(mPreferenceController).getRandomizationValue();
-
- mPreferenceController.updateState(mDropDownPreference);
-
- int prefValue = mPreferenceController.translateMacRandomizedValueToPrefValue(
- PRIVACY_TRUSTED);
- assertThat(mDropDownPreference.getEntry()).isEqualTo(mPerferenceStrings[prefValue]);
- }
-
- @Test
- public void testUpdateState_wifiNotMetered_setCorrectValue() {
- doReturn(PRIVACY_RANDOMIZED).when(mPreferenceController).getRandomizationValue();
-
- mPreferenceController.updateState(mDropDownPreference);
-
- int prefValue = mPreferenceController.translateMacRandomizedValueToPrefValue(
- PRIVACY_RANDOMIZED);
- assertThat(mDropDownPreference.getEntry()).isEqualTo(mPerferenceStrings[prefValue]);
- }
-
- @Test
- public void testUpdateState_canSetPrivacyInNextUpdate_shouldBeSelectable() {
- // Return false in WifiEntry#canSetPrivacy to make preference un-selectable first.
- when(mMockWifiEntry.canSetPrivacy()).thenReturn(false);
-
- mPreferenceController.updateState(mDropDownPreference);
-
- assertThat(mDropDownPreference.isSelectable()).isFalse();
-
- // Return true in WifiEntry#canSetPrivacy to verify preference back to selectable.
- when(mMockWifiEntry.canSetPrivacy()).thenReturn(true);
-
- mPreferenceController.updateState(mDropDownPreference);
-
- assertThat(mDropDownPreference.isSelectable()).isTrue();
- }
-
- @Test
- public void testUpdateState_canNotSetPrivacyInNextUpdate_shouldNotBeSelectable() {
- // Return true in WifiEntry#canSetPrivacy to make preference selectable first.
- when(mMockWifiEntry.canSetPrivacy()).thenReturn(true);
-
- mPreferenceController.updateState(mDropDownPreference);
-
- assertThat(mDropDownPreference.isSelectable()).isTrue();
-
- // Return false in WifiEntry#canSetPrivacy to verify preference back to un-selectable.
- when(mMockWifiEntry.canSetPrivacy()).thenReturn(false);
-
- mPreferenceController.updateState(mDropDownPreference);
-
- assertThat(mDropDownPreference.isSelectable()).isFalse();
- }
-}
diff --git a/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java
index 9156cae..52a5f24 100644
--- a/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java
@@ -24,7 +24,6 @@
import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.biometrics.face.FaceFeatureProvider;
-import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider;
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider;
@@ -81,7 +80,6 @@
public final AccountFeatureProvider mAccountFeatureProvider;
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
public final FaceFeatureProvider mFaceFeatureProvider;
- public final FingerprintFeatureProvider mFingerprintFeatureProvider;
public final BiometricsRepositoryProvider mBiometricsRepositoryProvider;
public PanelFeatureProvider panelFeatureProvider;
@@ -134,7 +132,6 @@
panelFeatureProvider = mock(PanelFeatureProvider.class);
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
- mFingerprintFeatureProvider = mock(FingerprintFeatureProvider.class);
mBiometricsRepositoryProvider = mock(BiometricsRepositoryProvider.class);
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
securitySettingsFeatureProvider = mock(SecuritySettingsFeatureProvider.class);
@@ -260,11 +257,6 @@
}
@Override
- public FingerprintFeatureProvider getFingerprintFeatureProvider() {
- return mFingerprintFeatureProvider;
- }
-
- @Override
public BiometricsRepositoryProvider getBiometricsRepositoryProvider() {
return mBiometricsRepositoryProvider;
}
diff --git a/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt b/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt
index 54299eb..95f25ad 100644
--- a/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt
+++ b/tests/spa_unit/src/com/android/settings/testutils/FakeFeatureFactory.kt
@@ -22,7 +22,6 @@
import com.android.settings.accounts.AccountFeatureProvider
import com.android.settings.applications.ApplicationFeatureProvider
import com.android.settings.biometrics.face.FaceFeatureProvider
-import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider
import com.android.settings.bluetooth.BluetoothFeatureProvider
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider
@@ -121,8 +120,6 @@
get() = TODO("Not yet implemented")
override val faceFeatureProvider: FaceFeatureProvider
get() = TODO("Not yet implemented")
- override val fingerprintFeatureProvider: FingerprintFeatureProvider
- get() = TODO("Not yet implemented")
override val biometricsRepositoryProvider: BiometricsRepositoryProvider
get() = TODO("Not yet implemented")
override val wifiTrackerLibProvider: WifiTrackerLibProvider
diff --git a/tests/spa_unit/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.kt b/tests/spa_unit/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.kt
new file mode 100644
index 0000000..cb1f997
--- /dev/null
+++ b/tests/spa_unit/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.kt
@@ -0,0 +1,143 @@
+/*
+ * 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.wifi.details2
+
+import android.content.Context
+import androidx.preference.ListPreference
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.android.settings.R
+import com.android.wifitrackerlib.WifiEntry
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.any
+import org.mockito.kotlin.doReturn
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.never
+import org.mockito.kotlin.spy
+import org.mockito.kotlin.stub
+import org.mockito.kotlin.verify
+import org.mockito.kotlin.whenever
+
+@RunWith(AndroidJUnit4::class)
+class WifiPrivacyPreferenceController2Test {
+ private var mockWifiEntry = mock<WifiEntry>()
+
+ private var context: Context = ApplicationProvider.getApplicationContext()
+
+ private var controller = spy(WifiPrivacyPreferenceController2(context).apply {
+ setWifiEntry(mockWifiEntry)
+ })
+
+ private var preference = ListPreference(context).apply {
+ setEntries(R.array.wifi_privacy_entries)
+ setEntryValues(R.array.wifi_privacy_values)
+ }
+
+ private var preferenceStrings = context.resources.getStringArray(R.array.wifi_privacy_entries)
+
+ @Test
+ fun updateState_wifiPrivacy_setCorrectValue() {
+ controller.stub {
+ doReturn(WifiEntry.PRIVACY_DEVICE_MAC).whenever(mock).randomizationValue
+ }
+
+ controller.updateState(preference)
+
+ val prefValue = WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
+ WifiEntry.PRIVACY_DEVICE_MAC
+ )
+ assertThat(preference.entry).isEqualTo(preferenceStrings[prefValue])
+ }
+
+ @Test
+ fun updateState_wifiNotMetered_setCorrectValue() {
+ controller.stub {
+ doReturn(WifiEntry.PRIVACY_RANDOMIZED_MAC).whenever(mock).randomizationValue
+ }
+
+ controller.updateState(preference)
+
+ val prefValue = WifiPrivacyPreferenceController2.translateMacRandomizedValueToPrefValue(
+ WifiEntry.PRIVACY_RANDOMIZED_MAC
+ )
+ assertThat(preference.entry).isEqualTo(preferenceStrings[prefValue])
+ }
+
+ @Test
+ fun updateState_canSetPrivacyInNextUpdate_shouldBeSelectable() {
+ mockWifiEntry.stub {
+ // Return false in WifiEntry#canSetPrivacy to make preference un-selectable first.
+ on { canSetPrivacy() } doReturn false
+ }
+ controller.updateState(preference)
+ assertThat(preference.isSelectable).isFalse()
+
+ mockWifiEntry.stub {
+ // Return true in WifiEntry#canSetPrivacy to verify preference back to selectable.
+ on { canSetPrivacy() } doReturn true
+ }
+ controller.updateState(preference)
+ assertThat(preference.isSelectable).isTrue()
+ }
+
+ @Test
+ fun updateState_canNotSetPrivacyInNextUpdate_shouldNotBeSelectable() {
+ mockWifiEntry.stub {
+ // Return true in WifiEntry#canSetPrivacy to make preference selectable first.
+ on { canSetPrivacy() } doReturn true
+ }
+ controller.updateState(preference)
+ assertThat(preference.isSelectable).isTrue()
+
+ mockWifiEntry.stub {
+ // Return false in WifiEntry#canSetPrivacy to verify preference back to un-selectable.
+ on { canSetPrivacy() } doReturn false
+ }
+ controller.updateState(preference)
+ assertThat(preference.isSelectable).isFalse()
+ }
+
+ @Test
+ fun onPreferenceChange_sameNewValue_doNoting() {
+ mockWifiEntry.stub {
+ on { privacy } doReturn 0
+ on { connectedState } doReturn WifiEntry.CONNECTED_STATE_CONNECTED
+ }
+
+ controller.onPreferenceChange(preference, "0")
+
+ verify(mockWifiEntry, never()).privacy = any()
+ verify(mockWifiEntry, never()).disconnect(null)
+ verify(mockWifiEntry, never()).connect(null)
+ }
+
+ @Test
+ fun onPreferenceChange_differentNewValue_setAndReconnect() {
+ mockWifiEntry.stub {
+ on { privacy } doReturn 0
+ on { connectedState } doReturn WifiEntry.CONNECTED_STATE_CONNECTED
+ }
+
+ controller.onPreferenceChange(preference, "1")
+
+ verify(mockWifiEntry).privacy = 1
+ verify(mockWifiEntry).disconnect(null)
+ verify(mockWifiEntry).connect(null)
+ }
+}
diff --git a/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java b/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java
index 4aa38ae..a402d91 100644
--- a/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java
+++ b/tests/unit/src/com/android/settings/development/graphicsdriver/GraphicsDriverEnableAngleAsSystemDriverControllerJUnitTest.java
@@ -24,6 +24,8 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
@@ -472,4 +474,27 @@
SystemProperties.removeChangeCallback(propertyChangeSignal1.getCountDownJob());
SystemProperties.removeChangeCallback(propertyChangeSignal2.getCountDownJob());
}
+
+ @Test
+ public void updateState_DeveloperOptionPropertyIsFalse() {
+ // Test that when debug.graphics.angle.developeroption.enable is false:
+ when(mSystemPropertiesMock.getBoolean(eq(PROPERTY_DEBUG_ANGLE_DEVELOPER_OPTION),
+ anyBoolean())).thenReturn(false);
+ when(mSystemPropertiesMock.get(eq(PROPERTY_RO_GFX_ANGLE_SUPPORTED), any()))
+ .thenReturn("true");
+
+ // 1. "Enable ANGLE" switch is on, the switch should be enabled.
+ when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))
+ .thenReturn(ANGLE_DRIVER_SUFFIX);
+ mController.updateState(mPreference);
+ assertTrue(mPreference.isChecked());
+ assertTrue(mPreference.isEnabled());
+
+ // 2. "Enable ANGLE" switch is off, the switch should be disabled.
+ when(mSystemPropertiesMock.get(eq(PROPERTY_PERSISTENT_GRAPHICS_EGL), any()))
+ .thenReturn("");
+ mController.updateState(mPreference);
+ assertFalse(mPreference.isChecked());
+ assertFalse(mPreference.isEnabled());
+ }
}
diff --git a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
index b5062a0..a3a92a3 100644
--- a/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/unit/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -24,7 +24,6 @@
import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.biometrics.face.FaceFeatureProvider;
-import com.android.settings.biometrics.fingerprint.FingerprintFeatureProvider;
import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider;
import com.android.settings.bluetooth.BluetoothFeatureProvider;
import com.android.settings.connecteddevice.fastpair.FastPairFeatureProvider;
@@ -80,7 +79,6 @@
public final AccountFeatureProvider mAccountFeatureProvider;
public final BluetoothFeatureProvider mBluetoothFeatureProvider;
public final FaceFeatureProvider mFaceFeatureProvider;
- public final FingerprintFeatureProvider mFingerprintFeatureProvider;
public final BiometricsRepositoryProvider mBiometricsRepositoryProvider;
public PanelFeatureProvider panelFeatureProvider;
@@ -133,7 +131,6 @@
panelFeatureProvider = mock(PanelFeatureProvider.class);
mBluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
mFaceFeatureProvider = mock(FaceFeatureProvider.class);
- mFingerprintFeatureProvider = mock(FingerprintFeatureProvider.class);
mBiometricsRepositoryProvider = mock(BiometricsRepositoryProvider.class);
wifiTrackerLibProvider = mock(WifiTrackerLibProvider.class);
securitySettingsFeatureProvider = mock(SecuritySettingsFeatureProvider.class);
@@ -259,11 +256,6 @@
}
@Override
- public FingerprintFeatureProvider getFingerprintFeatureProvider() {
- return mFingerprintFeatureProvider;
- }
-
- @Override
public BiometricsRepositoryProvider getBiometricsRepositoryProvider() {
return mBiometricsRepositoryProvider;
}