Merge "Fix calculateSizeBytes"
diff --git a/protos/network_mode_choices.proto b/protos/network_mode_choices.proto
index 8c3ec93..9c2b9b4 100644
--- a/protos/network_mode_choices.proto
+++ b/protos/network_mode_choices.proto
@@ -8,7 +8,8 @@
// EnabledNetworks is a list which tries to categorized the entries of popup menu
// based on carrier network types available to the end user.
-// Next tag: 13
+// Next tag: 15
+// TODO(b/268145152): rename the ENABLED_NETWORKS for good readability.
enum EnabledNetworks {
// No EnabledNetworks specified.
ENABLED_NETWORKS_UNSPECIFIED = 0;
@@ -17,39 +18,56 @@
ENABLED_NETWORKS_UNKNOWN = 1;
// For the case where CDMA is supported and LTE is not prioritized over
- // CDMA.
+ // CDMA (LTE, 3G, 1x, global).
ENABLED_NETWORKS_CDMA_CHOICES = 2;
// For the case where CDMA is supported and LTE is not available.
+ // CDMA (3G, 1x)
ENABLED_NETWORKS_CDMA_NO_LTE_CHOICES = 3;
// For the case where CDMA is supported and LTE is available.
+ // CDMA (LTE, Global)
ENABLED_NETWORKS_CDMA_ONLY_LTE_CHOICES = 4;
// For the case where TDSCDMA is primary network type.
+ // TDSCDMA (LTE, 3G, 2G)
ENABLED_NETWORKS_TDSCDMA_CHOICES = 5;
// For the case where GSM and LTE options are removed from the menu.
+ // (3G)
ENABLED_NETWORKS_EXCEPT_GSM_LTE_CHOICES = 6;
- // For the case where GSM and 4G options are removed from the menu.
+ // For the case where GSM option are removed from the menu. The wording of LTE is '4G'.
+ // (4G, 3G)
ENABLED_NETWORKS_EXCEPT_GSM_4G_CHOICES = 7;
- // For the case where GSM is removed from the menu, and both 4G/LTE are not an
- // option.
+ // For the case where GSM option are removed from the menu. The wording of LTE is 'LTE'.
+ // (LTE, 3G)
ENABLED_NETWORKS_EXCEPT_GSM_CHOICES = 8;
// For the case where LTE is disabled.
+ // (3G, 3G)
ENABLED_NETWORKS_EXCEPT_LTE_CHOICES = 9;
- // For the case where GSM related carrier with 4G/LTE supported.
+ // For the case where GSM related carrier with 4G/LTE supported. The wording of LTE is '4G'.
+ // (2G, 3G, 4G)
ENABLED_NETWORKS_4G_CHOICES = 10;
- // For the case where GSM related carrier without 4G/LTE supported.
+ // For the case where GSM related carrier with 4G/LTE supported. The wording of LTE is 'LTE'.
+ // (2G, 3G, LTE)
ENABLED_NETWORKS_CHOICES = 11;
// For the case where world mode is enabled.
+ // ("Global", "LTE / CDMA", "LTE / GSM / UMTS")
PREFERRED_NETWORK_MODE_CHOICES_WORLD_MODE = 12;
+
+ // For the case where GSM, 3G options are removed from the menu. The wording of LTE is '4G'.
+ // (4G)
+ ENABLED_NETWORKS_4G_CHOICES_EXCEPT_GSM_3G = 13;
+
+ // For the case where GSM and 3G are removed from the menu. The wording of LTE is 'LTE'.
+ // (LTE)
+ ENABLED_NETWORKS_CHOICES_EXCEPT_GSM_3G = 14;
}
// A request for popup menu.
diff --git a/res/layout/notification_channel_panel.xml b/res/layout/notification_channel_panel.xml
index 06635a0..14e10cc 100644
--- a/res/layout/notification_channel_panel.xml
+++ b/res/layout/notification_channel_panel.xml
@@ -16,8 +16,8 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_content"
- android:layout_height="@dimen/output_switcher_slice_max_height"
- android:maxHeight="@dimen/output_switcher_slice_max_height"
+ android:layout_height="@dimen/notif_channel_panel_max_height"
+ android:maxHeight="@dimen/notif_channel_panel_max_height"
android:background="@drawable/settings_panel_background"
android:orientation="vertical"
android:layout_width="match_parent">
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 4295dd4..7a4e1d5 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -19,5 +19,5 @@
<dimen name="biometric_auth_pattern_view_size">248dp</dimen>
<dimen name="biometric_auth_pattern_view_max_size">348dp</dimen>
- <dimen name="output_switcher_slice_max_height">300dp</dimen>
+ <dimen name="notif_channel_panel_max_height">300dp</dimen>
</resources>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 2055442..e4bd550 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1105,6 +1105,10 @@
<item>"0"</item>
</string-array>
+ <string-array name="enabled_networks_except_gsm_3g_values" translatable="false">
+ <item>"9"</item>
+ </string-array>
+
<string-array name="enabled_networks_except_lte_values" translatable="false">
<item>"0"</item>
<item>"1"</item>
diff --git a/res/values/config.xml b/res/values/config.xml
index 5c5a07f..df2bae3 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -666,6 +666,9 @@
<!-- Whether the toggle for Auto-rotate with Face Detection should be shown. -->
<bool name="config_auto_rotate_face_detection_available">true</bool>
+ <!-- Whether to display the 3G option at network mode.-->
+ <bool name="config_display_network_mode_3g_option">true</bool>
+
<!-- The radius of the enrollment progress bar, in dp -->
<integer name="config_udfpsEnrollProgressBar" translatable="false">
280
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 529c53b..ad6ee3d 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -345,6 +345,9 @@
<dimen name="output_switcher_slice_max_height">600dp</dimen>
<dimen name="output_switcher_panel_icon_size">52dp</dimen>
+ <!-- Notification channels panel related dimensions -->
+ <dimen name="notif_channel_panel_max_height">600dp</dimen>
+
<!-- Settings panel related dimensions -->
<dimen name="settings_panel_corner_radius">28dp</dimen>
<dimen name="settings_panel_title_margin">24dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 98462db..83698eb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5301,6 +5301,10 @@
<string name="battery_usage_screen_footer_empty">Battery usage data will be available in a few hours once fully charged</string>
<!-- [CHAR_LIMIT=NONE] Battery chart label for the current time. -->
<string name="battery_usage_chart_label_now">now</string>
+ <!-- [CHAR_LIMIT=NONE] A hyphen for two timestamps. For example, "6 AM - 8 AM", which means "from 6 AM to 8 AM". Please notice the spaces around the hyphen -->
+ <string name="battery_usage_timestamps_hyphen"><xliff:g id="from_timestamp">%1$s</xliff:g> - <xliff:g id="to_timestamp">%2$s</xliff:g></string>
+ <!-- [CHAR_LIMIT=NONE] The first slot is a week day (e.g. "Monday"); the second slot is a hourly time span (e.g. "6 AM - 8 AM"). -->
+ <string name="battery_usage_day_and_hour"><xliff:g id="day">%1$s</xliff:g> <xliff:g id="hour">%2$s</xliff:g></string>
<!-- [CHAR_LIMIT=NONE] Accessibility content description for battery chart view. -->
<string name="battery_usage_chart">Battery usage chart</string>
<!-- [CHAR_LIMIT=NONE] Accessibility content description for daily battery chart view. -->
diff --git a/res/xml/accounts_dashboard_settings_credman.xml b/res/xml/accounts_dashboard_settings_credman.xml
index 605d315..38f3f55 100644
--- a/res/xml/accounts_dashboard_settings_credman.xml
+++ b/res/xml/accounts_dashboard_settings_credman.xml
@@ -46,13 +46,6 @@
settings:keywords="@string/credman_keywords" />
<PreferenceCategory
- android:key="passwords_category"
- android:order="30"
- android:persistent="false"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
- settings:keywords="@string/autofill_keywords" />
-
- <PreferenceCategory
android:key="dashboard_tile_placeholder"
android:order="130"/>
diff --git a/res/xml/accounts_personal_dashboard_settings_credman.xml b/res/xml/accounts_personal_dashboard_settings_credman.xml
index a5188dd..c3f061d 100644
--- a/res/xml/accounts_personal_dashboard_settings_credman.xml
+++ b/res/xml/accounts_personal_dashboard_settings_credman.xml
@@ -47,13 +47,6 @@
settings:keywords="@string/credman_keywords" />
<PreferenceCategory
- android:key="passwords_category"
- android:order="30"
- android:persistent="false"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
- settings:keywords="@string/autofill_keywords" />
-
- <PreferenceCategory
android:key="dashboard_tile_placeholder"
android:order="130"/>
diff --git a/res/xml/accounts_work_dashboard_settings_credman.xml b/res/xml/accounts_work_dashboard_settings_credman.xml
index f4e8af2..1559476 100644
--- a/res/xml/accounts_work_dashboard_settings_credman.xml
+++ b/res/xml/accounts_work_dashboard_settings_credman.xml
@@ -47,13 +47,6 @@
settings:keywords="@string/credman_keywords" />
<PreferenceCategory
- android:key="passwords_category"
- android:order="30"
- android:persistent="false"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
- settings:keywords="@string/autofill_keywords" />
-
- <PreferenceCategory
android:key="dashboard_tile_placeholder"
android:order="130"/>
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index a06efb7..7089736 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -98,6 +98,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
+import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.drawable.IconCompat;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;
@@ -704,23 +705,26 @@
&& bundle.getBoolean(ChooseLockSettingsHelper.EXTRA_KEY_ALLOW_ANY_USER, false);
final int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
if (userId == LockPatternUtils.USER_FRP) {
- return allowAnyUser ? userId : enforceSystemUser(context, userId);
+ return allowAnyUser ? userId : checkUserOwnsFrpCredential(context, userId);
} else {
return allowAnyUser ? userId : enforceSameOwner(context, userId);
}
}
/**
- * Returns the given user id if the current user is the system user.
+ * Returns the given user id if the current user owns frp credential.
*
- * @throws SecurityException if the current user is not the system user.
+ * @throws SecurityException if the current user do not own the frp credential.
*/
- public static int enforceSystemUser(Context context, int userId) {
- if (UserHandle.myUserId() == UserHandle.USER_SYSTEM) {
+ @VisibleForTesting
+ static int checkUserOwnsFrpCredential(Context context, int userId) {
+ final UserManager um = context.getSystemService(UserManager.class);
+ if (LockPatternUtils.userOwnsFrpCredential(context,
+ um.getUserInfo(UserHandle.myUserId()))) {
return userId;
}
- throw new SecurityException("Given user id " + userId + " must only be used from "
- + "USER_SYSTEM, but current user is " + UserHandle.myUserId());
+ throw new SecurityException("Current user id " + UserHandle.myUserId()
+ + " does not own frp credential.");
}
/**
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 0558f25..e59b4c2 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -228,7 +228,7 @@
return;
}
- var alwaysOnPreference = new SwitchPreference(getPrefContext());
+ SwitchPreference alwaysOnPreference = new SwitchPreference(getPrefContext());
alwaysOnPreference.setTitle(
R.string.accessibility_screen_magnification_always_on_title);
alwaysOnPreference.setSummary(
@@ -237,8 +237,9 @@
MagnificationAlwaysOnPreferenceController.PREF_KEY);
generalCategory.addPreference(alwaysOnPreference);
- var alwaysOnPreferenceController = new MagnificationAlwaysOnPreferenceController(
- getContext(), MagnificationAlwaysOnPreferenceController.PREF_KEY);
+ MagnificationAlwaysOnPreferenceController alwaysOnPreferenceController =
+ new MagnificationAlwaysOnPreferenceController(
+ getContext(), MagnificationAlwaysOnPreferenceController.PREF_KEY);
getSettingsLifecycle().addObserver(alwaysOnPreferenceController);
alwaysOnPreferenceController.displayPreference(getPreferenceScreen());
addPreferenceController(alwaysOnPreferenceController);
@@ -347,7 +348,7 @@
AccessibilitySettingsContentObserver contentObserver) {
super.registerKeysToObserverCallback(contentObserver);
- var keysToObserve = List.of(
+ List<String> keysToObserve = List.of(
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_FOLLOW_TYPING_ENABLED,
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED
);
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 16351e8..bba2826 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -76,9 +76,9 @@
CredentialManagerPreferenceController cmpp =
use(CredentialManagerPreferenceController.class);
cmpp.init(this, getFragmentManager());
+ } else {
+ getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
-
- getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
@Override
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index 30fb1a1..e0d49d2 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -70,9 +70,9 @@
CredentialManagerPreferenceController cmpp =
use(CredentialManagerPreferenceController.class);
cmpp.init(this, getFragmentManager());
+ } else {
+ getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
-
- getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
@Override
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index 5a89457..da380b3 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -70,9 +70,9 @@
CredentialManagerPreferenceController cmpp =
use(CredentialManagerPreferenceController.class);
cmpp.init(this, getFragmentManager());
+ } else {
+ getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
-
- getSettingsLifecycle().addObserver(use(PasswordsPreferenceController.class));
}
@Override
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
index 7bbd31b..e19b4f4 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
@@ -26,6 +26,7 @@
import androidx.window.embedding.ActivityFilter;
import androidx.window.embedding.ActivityRule;
+import androidx.window.embedding.EmbeddingAspectRatio;
import androidx.window.embedding.RuleController;
import androidx.window.embedding.SplitAttributes;
import androidx.window.embedding.SplitPairFilter;
@@ -111,6 +112,7 @@
.setClearTop(clearTop)
.setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp())
.setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp())
+ .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.alwaysAllow())
.setDefaultSplitAttributes(attributes)
.build();
RuleController.getInstance(context).addRule(splitPairRule);
@@ -231,6 +233,7 @@
activityFilters, intent)
.setMinWidthDp(ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthDp())
.setMinSmallestWidthDp(ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthDp())
+ .setMaxAspectRatioInPortrait(EmbeddingAspectRatio.alwaysAllow())
.setSticky(false)
.setFinishPrimaryWithPlaceholder(SplitRule.FinishBehavior.ADJACENT)
.setDefaultSplitAttributes(attributes)
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 3f335bc..ed45c2b 100644
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -457,6 +457,7 @@
};
final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context)
+ .setUseDefaultSubtitle() // use default subtitle if subtitle is null/empty
.setUseDefaultTitle(); // use default title if title is null/empty
final BiometricManager bm = context.getSystemService(BiometricManager.class);
diff --git a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
index 865f173..7160b0d 100644
--- a/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
+++ b/src/com/android/settings/applications/credentials/CredentialManagerPreferenceController.java
@@ -293,15 +293,8 @@
return true;
} else {
- // Show the confirm disable dialog.
- final DialogFragment fragment =
- newConfirmationDialogFragment(packageName, title, pref);
-
- if (fragment == null || mFragmentManager == null) {
- return true;
- }
-
- fragment.show(mFragmentManager, ConfirmationDialogFragment.TAG);
+ // Disable the provider.
+ togglePackageNameDisabled(packageName);
}
return true;
@@ -334,29 +327,6 @@
});
}
- private @Nullable ConfirmationDialogFragment newConfirmationDialogFragment(
- @NonNull String packageName,
- @NonNull CharSequence appName,
- @NonNull SwitchPreference pref) {
- DialogHost host =
- new DialogHost() {
- @Override
- public void onDialogClick(int whichButton) {
- if (whichButton == DialogInterface.BUTTON_POSITIVE) {
- // Since the package is now enabled then we
- // should remove it from the enabled list.
- togglePackageNameDisabled(packageName);
- } else if (whichButton == DialogInterface.BUTTON_NEGATIVE) {
- // Set the checked back to true because we
- // backed out of turning this off.
- pref.setChecked(true);
- }
- }
- };
-
- return new ConfirmationDialogFragment(host, packageName, appName);
- }
-
private @Nullable ErrorDialogFragment newErrorDialogFragment() {
DialogHost host =
new DialogHost() {
@@ -416,44 +386,4 @@
@Override
public void onClick(DialogInterface dialog, int which) {}
}
-
- /**
- * Confirmation dialog fragment shows a dialog to the user to confirm that they are disabling a
- * provider.
- */
- public static class ConfirmationDialogFragment extends CredentialManagerDialogFragment {
-
- ConfirmationDialogFragment(
- DialogHost dialogHost, @NonNull String packageName, @NonNull CharSequence appName) {
- super(dialogHost);
-
- final Bundle argument = new Bundle();
- argument.putString(PACKAGE_NAME_KEY, packageName);
- argument.putCharSequence(APP_NAME_KEY, appName);
- setArguments(argument);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final Bundle bundle = getArguments();
- final String title =
- getContext()
- .getString(
- R.string.credman_confirmation_message_title,
- bundle.getCharSequence(
- CredentialManagerDialogFragment.APP_NAME_KEY));
-
- return new AlertDialog.Builder(getActivity())
- .setTitle(title)
- .setMessage(getContext().getString(R.string.credman_confirmation_message))
- .setPositiveButton(R.string.credman_confirmation_message_positive_button, this)
- .setNegativeButton(android.R.string.cancel, this)
- .create();
- }
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- getDialogHost().onDialogClick(which);
- }
- }
}
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
index b9ad2c3..747a125 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/ScaryWarningDialogFragment.java
@@ -41,7 +41,7 @@
@Override
public int getMetricsCategory() {
- return SettingsEnums.DIALOG_SERVICE_ACCESS_WARNING;
+ return SettingsEnums.DIALOG_NOTIFICATION_ACCESS_GRANT;
}
public ScaryWarningDialogFragment setServiceInfo(ComponentName cn, CharSequence label,
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index c7e74ef..50351a8 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -126,7 +126,7 @@
if (mCachedDevice == null) {
return CONDITIONALLY_UNAVAILABLE;
}
- return Utils.isAdvancedDetailsHeader(mCachedDevice.getDevice())
+ return BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice())
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
index 06a71f0..8f90b28 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
@@ -57,7 +57,7 @@
boolean hasLeAudio = mCachedDevice.getConnectableProfiles()
.stream()
.anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO);
- return !Utils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && !hasLeAudio;
+ return !BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && !hasLeAudio;
}
@Override
diff --git a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
index 188770b..9e4d12f 100644
--- a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java
@@ -111,7 +111,7 @@
.stream()
.anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO);
- return !Utils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && hasLeAudio
+ return !BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && hasLeAudio
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index 9aa363a..37c826f 100644
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -28,18 +28,14 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.UserHandle;
-import android.provider.DeviceConfig;
import android.provider.Settings;
-import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import com.android.settings.R;
-import com.android.settings.core.SettingsUIDeviceConfig;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.bluetooth.BluetoothUtils;
import com.android.settingslib.bluetooth.BluetoothUtils.ErrorListener;
@@ -166,38 +162,6 @@
}
/**
- * Check if the Bluetooth device supports advanced details header
- *
- * @param bluetoothDevice the BluetoothDevice to get metadata
- * @return true if it supports advanced details header, false otherwise.
- */
- public static boolean isAdvancedDetailsHeader(@NonNull BluetoothDevice bluetoothDevice) {
- final boolean advancedEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
- SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, true);
- if (!advancedEnabled) {
- Log.d(TAG, "isAdvancedDetailsHeader: advancedEnabled is false");
- return false;
- }
- // The metadata is for Android R
- final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(bluetoothDevice,
- BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
- if (untetheredHeadset) {
- Log.d(TAG, "isAdvancedDetailsHeader: untetheredHeadset is true");
- return true;
- }
- // The metadata is for Android S
- final String deviceType = BluetoothUtils.getStringMetaData(bluetoothDevice,
- BluetoothDevice.METADATA_DEVICE_TYPE);
- if (TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET)
- || TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_WATCH)
- || TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_DEFAULT)) {
- Log.d(TAG, "isAdvancedDetailsHeader: deviceType is " + deviceType);
- return true;
- }
- return false;
- }
-
- /**
* Returns the Bluetooth Package name
*/
public static String findBluetoothPackageName(Context context)
diff --git a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
index ba2d0da..ffe81f1 100644
--- a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
+++ b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
@@ -44,6 +44,7 @@
import com.android.settings.notification.SoundSettings;
import com.android.settings.notification.zen.ZenModeSettings;
import com.android.settings.privacy.PrivacyDashboardFragment;
+import com.android.settings.safetycenter.MoreSecurityPrivacyFragment;
import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.security.SecurityAdvancedSettings;
import com.android.settings.security.SecuritySettings;
@@ -132,6 +133,8 @@
CategoryKey.CATEGORY_COMMUNAL_SETTINGS);
PARENT_TO_CATEGORY_KEY_MAP.put(SpecialAccessSettings.class.getName(),
CategoryKey.CATEGORY_SPECIAL_APP_ACCESS);
+ PARENT_TO_CATEGORY_KEY_MAP.put(MoreSecurityPrivacyFragment.class.getName(),
+ CategoryKey.CATEGORY_MORE_SECURITY_PRIVACY_SETTINGS);
CATEGORY_KEY_TO_PARENT_MAP = new ArrayMap<>(PARENT_TO_CATEGORY_KEY_MAP.size());
diff --git a/src/com/android/settings/deviceinfo/simstatus/EidStatus.java b/src/com/android/settings/deviceinfo/simstatus/EidStatus.java
index 2f986a3..5da671b 100644
--- a/src/com/android/settings/deviceinfo/simstatus/EidStatus.java
+++ b/src/com/android/settings/deviceinfo/simstatus/EidStatus.java
@@ -144,6 +144,7 @@
}
return eid;
})
+ .filter(Objects::nonNull)
.findFirst()
.orElse(null);
}
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.java b/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.java
index e0a8af6..8f2083f 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimEidPreferenceController.java
@@ -121,11 +121,11 @@
@Override
public CharSequence getSummary() {
- String summary = mShowEidOnSummary ? mEidStatus.getEid() : null;
- if (TextUtils.isEmpty(summary)) {
- summary = mContext.getString(R.string.device_info_protected_single_press);
+ if (!mShowEidOnSummary) {
+ return mContext.getString(R.string.device_info_protected_single_press);
}
- return summary;
+ String summary = mEidStatus.getEid();
+ return (summary == null) ? "" : summary;
}
@Override
@@ -135,7 +135,8 @@
}
boolean isAvailable = SubscriptionUtil.isSimHardwareVisible(mContext) &&
mContext.getSystemService(UserManager.class).isAdminUser() &&
- !Utils.isWifiOnly(mContext);
+ !Utils.isWifiOnly(mContext) &&
+ ((mEidStatus != null) && !TextUtils.isEmpty(mEidStatus.getEid()));
return isAvailable ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
@@ -149,15 +150,20 @@
WindowManager.LayoutParams.FLAG_SECURE);
dialogShwon.setCanceledOnTouchOutside(false);
- TextView textView = dialogShwon.findViewById(R.id.esim_id_value);
- textView.setText(PhoneNumberUtil.expandByTts(mEidStatus.getEid()));
- textView.setTextIsSelectable(true);
+ String eid = mEidStatus.getEid();
+ if (eid != null) {
+ TextView textView = dialogShwon.findViewById(R.id.esim_id_value);
+ textView.setText(PhoneNumberUtil.expandByTts(eid));
+ textView.setTextIsSelectable(true);
- ImageView qrCodeView = dialogShwon.findViewById(R.id.esim_id_qrcode);
- qrCodeView.setImageBitmap(getEidQRcode(mEidStatus.getEid().toString(),
- qrCodeView.getWidth()));
-
+ ImageView qrCodeView = dialogShwon.findViewById(R.id.esim_id_qrcode);
+ qrCodeView.setImageBitmap(getEidQRcode(eid, qrCodeView.getWidth()));
+ }
mShowEidOnSummary = true;
+
+ dialogShwon.setOnDismissListener(dlg -> {
+ mPreference.setSummary(getSummary());
+ });
}
/**
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
index 437ffda..e622f4c 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.os.BatteryUsageStats;
+import android.os.PowerManager;
import androidx.annotation.VisibleForTesting;
@@ -61,11 +62,14 @@
final BatteryTipPolicy policy = new BatteryTipPolicy(getContext());
final BatteryInfo batteryInfo = mBatteryUtils.getBatteryInfo(TAG);
final Context context = getContext().getApplicationContext();
+ final boolean isPowerSaveMode =
+ context.getSystemService(PowerManager.class).isPowerSaveMode();
- tips.add(new LowBatteryDetector(context, policy, batteryInfo).detect());
+ tips.add(new LowBatteryDetector(context, policy, batteryInfo, isPowerSaveMode).detect());
tips.add(new HighUsageDetector(context, policy, mBatteryUsageStats, batteryInfo).detect());
tips.add(new SmartBatteryDetector(
- context, policy, batteryInfo, context.getContentResolver()).detect());
+ context, policy, batteryInfo, context.getContentResolver(), isPowerSaveMode)
+ .detect());
tips.add(new BatteryDefenderDetector(batteryInfo, context).detect());
tips.add(new DockDefenderDetector(batteryInfo, context).detect());
tips.add(new IncompatibleChargerDetector(context, batteryInfo).detect());
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
index c6afefe..214b01a 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipPreferenceController.java
@@ -36,6 +36,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
/**
* Controller in charge of the battery tip group
@@ -98,15 +99,7 @@
if (batteryTips == null) {
return;
}
- if (mBatteryTips == null) {
- mBatteryTips = batteryTips;
- } else {
- // mBatteryTips and batteryTips always have the same length and same sequence.
- for (int i = 0, size = batteryTips.size(); i < size; i++) {
- mBatteryTips.get(i).updateState(batteryTips.get(i));
- }
- }
-
+ mBatteryTips = batteryTips;
mCardPreference.setVisible(false);
for (int i = 0, size = batteryTips.size(); i < size; i++) {
final BatteryTip batteryTip = mBatteryTips.get(i);
@@ -171,9 +164,9 @@
if (mBatteryTips == null) {
return null;
}
-
- return mBatteryTips.stream().anyMatch(BatteryTip::isVisible)
- ? mBatteryTips.stream().filter(BatteryTip::isVisible).findFirst().get() : null;
+ Optional<BatteryTip> visibleBatteryTip =
+ mBatteryTips.stream().filter(BatteryTip::isVisible).findFirst();
+ return visibleBatteryTip.orElse(null);
}
/**
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java
index 08df2e4..2dc057e 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/BatteryDefenderDetector.java
@@ -37,11 +37,13 @@
@Override
public BatteryTip detect() {
- if (mBatteryInfo.isOverheated && !FeatureFactory.getFactory(mContext)
- .getPowerUsageFeatureProvider(mContext)
- .isExtraDefend()) {
- return new BatteryDefenderTip(BatteryTip.StateType.NEW);
- }
- return new BatteryDefenderTip(BatteryTip.StateType.INVISIBLE);
+ final boolean isBasicBatteryDefend = mBatteryInfo.isOverheated
+ && !FeatureFactory.getFactory(mContext)
+ .getPowerUsageFeatureProvider(mContext)
+ .isExtraDefend();
+ final int state = isBasicBatteryDefend
+ ? BatteryTip.StateType.NEW : BatteryTip.StateType.INVISIBLE;
+ final boolean isPluggedIn = mBatteryInfo.pluggedStatus != 0;
+ return new BatteryDefenderTip(state, isPluggedIn);
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
index 8d668fe..ed8cc62 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetector.java
@@ -17,7 +17,6 @@
package com.android.settings.fuelgauge.batterytip.detectors;
import android.content.Context;
-import android.os.PowerManager;
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
@@ -30,26 +29,27 @@
* Detect whether the battery is too low
*/
public class LowBatteryDetector implements BatteryTipDetector {
- private BatteryInfo mBatteryInfo;
- private BatteryTipPolicy mPolicy;
- private PowerManager mPowerManager;
- private int mWarningLevel;
+ private final BatteryInfo mBatteryInfo;
+ private final BatteryTipPolicy mPolicy;
+ private final boolean mIsPowerSaveMode;
+ private final int mWarningLevel;
- public LowBatteryDetector(Context context, BatteryTipPolicy policy, BatteryInfo batteryInfo) {
+
+ public LowBatteryDetector(Context context, BatteryTipPolicy policy, BatteryInfo batteryInfo,
+ boolean isPowerSaveMode) {
mPolicy = policy;
mBatteryInfo = batteryInfo;
- mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mWarningLevel = context.getResources().getInteger(
com.android.internal.R.integer.config_lowBatteryWarningLevel);
+ mIsPowerSaveMode = isPowerSaveMode;
}
@Override
public BatteryTip detect() {
- final boolean powerSaveModeOn = mPowerManager.isPowerSaveMode();
final boolean lowBattery = mBatteryInfo.batteryLevel <= mWarningLevel
|| (mBatteryInfo.discharging && mBatteryInfo.remainingTimeUs != 0
&& mBatteryInfo.remainingTimeUs < TimeUnit.HOURS.toMicros(mPolicy.lowBatteryHour));
- final boolean lowBatteryEnabled = mPolicy.lowBatteryEnabled && !powerSaveModeOn;
+ final boolean lowBatteryEnabled = mPolicy.lowBatteryEnabled && !mIsPowerSaveMode;
final boolean dischargingLowBatteryState =
mPolicy.testLowBatteryTip || (mBatteryInfo.discharging && lowBattery);
@@ -61,6 +61,6 @@
state = BatteryTip.StateType.NEW;
}
- return new LowBatteryTip(state, powerSaveModeOn);
+ return new LowBatteryTip(state, mIsPowerSaveMode);
}
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetector.java
index 23409a1..0487ac3 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetector.java
@@ -18,7 +18,6 @@
import android.content.ContentResolver;
import android.content.Context;
-import android.os.PowerManager;
import android.provider.Settings;
import com.android.settings.fuelgauge.BatteryInfo;
@@ -32,17 +31,17 @@
public class SmartBatteryDetector implements BatteryTipDetector {
private static final int EXPECTED_BATTERY_LEVEL = 30;
- private BatteryInfo mBatteryInfo;
- private BatteryTipPolicy mPolicy;
- private ContentResolver mContentResolver;
- private PowerManager mPowerManager;
+ private final BatteryInfo mBatteryInfo;
+ private final BatteryTipPolicy mPolicy;
+ private final ContentResolver mContentResolver;
+ private final boolean mIsPowerSaveMode;
public SmartBatteryDetector(Context context, BatteryTipPolicy policy, BatteryInfo batteryInfo,
- ContentResolver contentResolver) {
+ ContentResolver contentResolver, boolean isPowerSaveMode) {
mPolicy = policy;
mBatteryInfo = batteryInfo;
mContentResolver = contentResolver;
- mPowerManager = context.getSystemService(PowerManager.class);
+ mIsPowerSaveMode = isPowerSaveMode;
}
@Override
@@ -53,7 +52,7 @@
mBatteryInfo.batteryLevel <= EXPECTED_BATTERY_LEVEL;
// Show it if in test or smart battery is off.
final boolean enableSmartBatteryTip =
- smartBatteryOff && !mPowerManager.isPowerSaveMode() && isUnderExpectedBatteryLevel
+ smartBatteryOff && !mIsPowerSaveMode && isUnderExpectedBatteryLevel
|| mPolicy.testSmartBatteryTip;
final int state =
enableSmartBatteryTip ? BatteryTip.StateType.NEW : BatteryTip.StateType.INVISIBLE;
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
index 2035f23..df0c192 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTip.java
@@ -19,9 +19,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.BatteryManager;
-import android.os.Parcel;
import android.util.Log;
import androidx.preference.Preference;
@@ -39,12 +36,11 @@
private static final String TAG = "BatteryDefenderTip";
- public BatteryDefenderTip(@StateType int state) {
- super(TipType.BATTERY_DEFENDER, state, false /* showDialog */);
- }
+ private boolean mIsPluggedIn;
- private BatteryDefenderTip(Parcel in) {
- super(in);
+ public BatteryDefenderTip(@StateType int state, boolean isPluggedIn) {
+ super(TipType.BATTERY_DEFENDER, state, false /* showDialog */);
+ mIsPluggedIn = isPluggedIn;
}
@Override
@@ -92,7 +88,7 @@
resumeCharging(context);
preference.setVisible(false);
});
- cardPreference.setPrimaryButtonVisible(isPluggedIn(context));
+ cardPreference.setPrimaryButtonVisible(mIsPluggedIn);
cardPreference.setSecondaryButtonText(context.getString(R.string.learn_more));
cardPreference.setSecondaryButtonClickListener(
@@ -117,23 +113,4 @@
Log.i(TAG, "send resume charging broadcast intent=" + intent);
}
-
- private boolean isPluggedIn(Context context) {
- final Intent batteryIntent =
- context.registerReceiver(
- /* receiver= */ null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
- return batteryIntent != null
- && batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
- }
-
- public static final Creator CREATOR = new Creator() {
- public BatteryTip createFromParcel(Parcel in) {
- return new BatteryDefenderTip(in);
- }
-
- public BatteryTip[] newArray(int size) {
- return new BatteryDefenderTip[size];
- }
- };
-
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/DockDefenderTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/DockDefenderTip.java
index 327f974..134cfa0 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/DockDefenderTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/DockDefenderTip.java
@@ -19,7 +19,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
-import android.os.Parcel;
import android.util.Log;
import androidx.preference.Preference;
@@ -44,10 +43,6 @@
mMode = mode;
}
- private DockDefenderTip(Parcel in) {
- super(in);
- }
-
public int getMode() {
return mMode;
}
@@ -162,14 +157,4 @@
Log.i(TAG, "send resume charging broadcast intent=" + intent);
}
-
- public static final Creator CREATOR = new Creator() {
- public BatteryTip createFromParcel(Parcel in) {
- return new DockDefenderTip(in);
- }
-
- public BatteryTip[] newArray(int size) {
- return new DockDefenderTip[size];
- }
- };
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java
index 7ad3d13..7ce6b14 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/IncompatibleChargerTip.java
@@ -19,7 +19,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
-import android.os.Parcel;
import android.util.Log;
import androidx.preference.Preference;
@@ -37,10 +36,6 @@
super(TipType.INCOMPATIBLE_CHARGER, state, /* showDialog */ false);
}
- private IncompatibleChargerTip(Parcel in) {
- super(in);
- }
-
@Override
public CharSequence getTitle(Context context) {
return context.getString(R.string.battery_tip_incompatible_charging_title);
@@ -89,14 +84,4 @@
cardPreference.setSecondaryButtonContentDescription(context.getString(
R.string.battery_tip_incompatible_charging_content_description));
}
-
- public static final Creator CREATOR = new Creator() {
- public BatteryTip createFromParcel(Parcel in) {
- return new IncompatibleChargerTip(in);
- }
-
- public BatteryTip[] newArray(int size) {
- return new IncompatibleChargerTip[size];
- }
- };
}
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
index 79d78e2..7ec8811 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/LowBatteryTip.java
@@ -91,5 +91,4 @@
return new LowBatteryTip[size];
}
};
-
}
diff --git a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
index d9ac14e..f13a4ef 100644
--- a/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batteryusage/BatteryChartPreferenceController.java
@@ -440,7 +440,8 @@
return selectedHourText;
}
- return String.format("%s %s", selectedDayText, selectedHourText);
+ return mContext.getString(
+ R.string.battery_usage_day_and_hour, selectedDayText, selectedHourText);
}
private String getAccessibilityAnnounceMessage() {
@@ -666,8 +667,8 @@
}
return index == timestamps.size() - 1
? generateText(timestamps, index)
- : String.format("%s%s%s", generateText(timestamps, index),
- mIs24HourFormat ? "-" : " - ", generateText(timestamps, index + 1));
+ : mContext.getString(R.string.battery_usage_timestamps_hyphen,
+ generateText(timestamps, index), generateText(timestamps, index + 1));
}
public HourlyChartLabelTextGenerator setLatestTimestamp(Long latestTimestamp) {
diff --git a/src/com/android/settings/inputmethod/KeyboardPreferenceController.java b/src/com/android/settings/inputmethod/KeyboardPreferenceController.java
index adabec5..26b07d8 100644
--- a/src/com/android/settings/inputmethod/KeyboardPreferenceController.java
+++ b/src/com/android/settings/inputmethod/KeyboardPreferenceController.java
@@ -27,13 +27,13 @@
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.inputmethod.PhysicalKeyboardFragment.HardKeyboardDeviceInfo;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
import java.util.List;
public class KeyboardPreferenceController extends BasePreferenceController
- implements PreferenceControllerMixin, LifecycleObserver, OnResume, OnPause,
+ implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop,
InputManager.InputDeviceListener {
private final InputManager mIm;
@@ -61,13 +61,13 @@
}
@Override
- public void onPause() {
- mIm.unregisterInputDeviceListener(this);
+ public void onStart() {
+ mIm.registerInputDeviceListener(this, null);
}
@Override
- public void onResume() {
- mIm.registerInputDeviceListener(this, null);
+ public void onStop() {
+ mIm.unregisterInputDeviceListener(this);
}
@Override
@@ -84,6 +84,9 @@
}
private void updateSummary() {
+ if (mPreference == null) {
+ return;
+ }
final List<HardKeyboardDeviceInfo> keyboards =
PhysicalKeyboardFragment.getHardKeyboards(mContext);
if (keyboards.isEmpty()) {
diff --git a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
index 9a1b2e4..0bd938e 100644
--- a/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
+++ b/src/com/android/settings/inputmethod/NewKeyboardSettingsUtils.java
@@ -17,7 +17,7 @@
package com.android.settings.inputmethod;
import android.content.Context;
-import android.provider.Settings;
+import android.view.InputDevice;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
@@ -38,17 +38,18 @@
static final String EXTRA_INPUT_METHOD_INFO = "input_method_info";
static final String EXTRA_INPUT_METHOD_SUBTYPE = "input_method_subtype";
- static InputMethodInfo getActiveIme(Context context, InputMethodManager imm) {
- InputMethodInfo activeIme = null;
- List<InputMethodInfo> infoList = imm.getEnabledInputMethodList();
- String imeId = Settings.Secure.getStringForUser(context.getContentResolver(),
- Settings.Secure.DEFAULT_INPUT_METHOD, context.getUserId());
- for (InputMethodInfo method : infoList) {
- if (method.getId().equals(imeId)) {
- activeIme = method;
+ static boolean isTouchpad() {
+ for (int deviceId : InputDevice.getDeviceIds()) {
+ final InputDevice device = InputDevice.getDevice(deviceId);
+ if (device == null) {
+ continue;
+ }
+ if ((device.getSources() & InputDevice.SOURCE_TOUCHPAD)
+ == InputDevice.SOURCE_TOUCHPAD) {
+ return true;
}
}
- return activeIme;
+ return false;
}
static List<String> getSuitableImeLabels(Context context, InputMethodManager imm, int userId) {
diff --git a/src/com/android/settings/inputmethod/TouchGesturesButtonPreferenceController.java b/src/com/android/settings/inputmethod/TouchGesturesButtonPreferenceController.java
index bbe65c1..7efa637 100644
--- a/src/com/android/settings/inputmethod/TouchGesturesButtonPreferenceController.java
+++ b/src/com/android/settings/inputmethod/TouchGesturesButtonPreferenceController.java
@@ -63,7 +63,9 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ boolean touchGestureDeveloperMode = FeatureFlagUtils
+ .isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD_GESTURE);
+ return touchGestureDeveloperMode ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
private void showTouchpadGestureEducation() {
diff --git a/src/com/android/settings/inputmethod/TrackpadSettingsController.java b/src/com/android/settings/inputmethod/TrackpadSettingsController.java
index 41be395..3de58e4 100644
--- a/src/com/android/settings/inputmethod/TrackpadSettingsController.java
+++ b/src/com/android/settings/inputmethod/TrackpadSettingsController.java
@@ -17,21 +17,73 @@
package com.android.settings.inputmethod;
import android.content.Context;
+import android.hardware.input.InputManager;
import android.util.FeatureFlagUtils;
-import com.android.settings.core.BasePreferenceController;
+import androidx.preference.Preference;
-public class TrackpadSettingsController extends BasePreferenceController {
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+public class TrackpadSettingsController extends BasePreferenceController
+ implements PreferenceControllerMixin, LifecycleObserver, OnStart, OnStop,
+ InputManager.InputDeviceListener {
+
+ private final InputManager mIm;
+
+ private Preference mPreference;
public TrackpadSettingsController(Context context, String key) {
super(context, key);
+ mIm = context.getSystemService(InputManager.class);
+ }
+
+ @Override
+ public void onInputDeviceAdded(int deviceId) {
+ updateEntry();
+ }
+
+ @Override
+ public void onInputDeviceRemoved(int deviceId) {
+ updateEntry();
+ }
+
+ @Override
+ public void onInputDeviceChanged(int deviceId) {
+ updateEntry();
+ }
+
+ @Override
+ public void onStart() {
+ mIm.registerInputDeviceListener(this, null);
+ }
+
+ @Override
+ public void onStop() {
+ mIm.unregisterInputDeviceListener(this);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ mPreference = preference;
+ updateEntry();
+ }
+
+ private void updateEntry() {
+ if (mPreference == null) {
+ return;
+ }
+ mPreference.setVisible(isAvailable());
}
@Override
public int getAvailabilityStatus() {
- // TODO: Need to detect if trackpad is connected with device.
boolean isFeatureOn = FeatureFlagUtils
.isEnabled(mContext, FeatureFlagUtils.SETTINGS_NEW_KEYBOARD_TRACKPAD);
- return isFeatureOn ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ boolean isTouchpad = NewKeyboardSettingsUtils.isTouchpad();
+ return (isFeatureOn && isTouchpad) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
}
diff --git a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
index 9c7e637..5e29df1 100644
--- a/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
+++ b/src/com/android/settings/localepicker/LocalePickerWithRegionActivity.java
@@ -31,7 +31,7 @@
/** A activity to show the locale picker page. */
public class LocalePickerWithRegionActivity extends SettingsBaseActivity
- implements LocalePickerWithRegion.LocaleSelectedListener {
+ implements LocalePickerWithRegion.LocaleSelectedListener, MenuItem.OnActionExpandListener {
private static final String TAG = LocalePickerWithRegionActivity.class.getSimpleName();
private static final String PARENT_FRAGMENT_NAME = "localeListEditor";
@@ -53,7 +53,9 @@
this,
LocalePickerWithRegionActivity.this,
false /* translate only */,
- explicitLocales);
+ explicitLocales,
+ null /* appPackageName */,
+ this);
getFragmentManager()
.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
@@ -97,5 +99,17 @@
return Settings.Global.getInt(
getContentResolver(), Settings.Global.DEVICE_DEMO_MODE, 0) == 1;
}
+
+ @Override
+ public boolean onMenuItemActionExpand(MenuItem item) {
+ mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemActionCollapse(MenuItem item) {
+ mAppBarLayout.setExpanded(false /*expanded*/, false /*animate*/);
+ return true;
+ }
}
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 1aca6b9..7f94f73 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -101,6 +101,7 @@
return visible ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
+
protected boolean isCallStateIdle() {
return mCallState == TelephonyManager.CALL_STATE_IDLE;
}
@@ -203,6 +204,9 @@
private boolean mIs5gEntryDisplayed;
private boolean mShow4gForLTE;
private boolean mSupported5gRadioAccessFamily;
+ private boolean mDisplay2gOptions;
+ private boolean mDisplay3gOptions;
+ private boolean mLteEnabled;
private int mSelectedEntry;
private int mSubId;
private String mSummary;
@@ -229,23 +233,32 @@
mSupported5gRadioAccessFamily = checkSupportedRadioBitmask(
mTelephonyManager.getSupportedRadioAccessFamily(),
TelephonyManager.NETWORK_TYPE_BITMASK_NR);
- mIsGlobalCdma = mTelephonyManager.isLteCdmaEvdoGsmWcdmaEnabled()
- && carrierConfig != null
- && carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL);
- mShow4gForLTE = carrierConfig != null && carrierConfig.getBoolean(
- CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
+ if (carrierConfig != null) {
+ mIsGlobalCdma = mTelephonyManager.isLteCdmaEvdoGsmWcdmaEnabled()
+ && carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_SHOW_CDMA_CHOICES_BOOL);
+ mShow4gForLTE = carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_SHOW_4G_FOR_LTE_DATA_ICON_BOOL);
+ mDisplay2gOptions = carrierConfig.getBoolean(
+ CarrierConfigManager.KEY_PREFER_2G_BOOL);
+ // TODO: Using the carrier config.
+ mDisplay3gOptions = getResourcesForSubId().getBoolean(
+ R.bool.config_display_network_mode_3g_option);
+ mLteEnabled = carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL);
+ }
Log.d(LOG_TAG, "PreferenceEntriesBuilder: subId" + mSubId
- + ",Supported5gRadioAccessFamily :" + mSupported5gRadioAccessFamily
- + ",mAllowed5gNetworkType :" + mAllowed5gNetworkType
- + ",IsGlobalCdma :" + mIsGlobalCdma
- + ",Show4gForLTE :" + mShow4gForLTE);
+ + " ,Supported5gRadioAccessFamily :" + mSupported5gRadioAccessFamily
+ + " ,mAllowed5gNetworkType :" + mAllowed5gNetworkType
+ + " ,IsGlobalCdma :" + mIsGlobalCdma
+ + " ,Display2gOptions:" + mDisplay2gOptions
+ + " ,Display3gOptions:" + mDisplay3gOptions
+ + " ,Display4gOptions" + mLteEnabled
+ + " ,Show4gForLTE :" + mShow4gForLTE);
}
void setPreferenceEntries() {
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
- final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
- final boolean display2gOptions = carrierConfig != null
- && carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL);
+
clearAllEntries();
UiOptions.Builder uiOptions = UiOptions.newBuilder();
uiOptions.setType(getEnabledNetworkType());
@@ -321,6 +334,16 @@
.addFormat(UiOptions.PresentFormat.addWorldModeCdmaEntry)
.addFormat(UiOptions.PresentFormat.addWorldModeGsmEntry);
break;
+ case ENABLED_NETWORKS_4G_CHOICES_EXCEPT_GSM_3G:
+ uiOptions = uiOptions
+ .setChoices(R.array.enabled_networks_except_gsm_3g_values)
+ .addFormat(UiOptions.PresentFormat.add5gAnd4gEntry);
+ break;
+ case ENABLED_NETWORKS_CHOICES_EXCEPT_GSM_3G:
+ uiOptions = uiOptions
+ .setChoices(R.array.enabled_networks_values)
+ .addFormat(UiOptions.PresentFormat.add5gAndLteEntry);
+ break;
default:
throw new IllegalArgumentException("Not supported enabled network types.");
}
@@ -336,53 +359,55 @@
// Compose options based on given values and formats.
IntStream.range(0, formatList.size()).forEach(entryIndex -> {
switch (formatList.get(entryIndex)) {
- case add1xEntry:
- if (display2gOptions) {
- add1xEntry(entryValuesInt[entryIndex]);
- }
- break;
- case add2gEntry:
- if (display2gOptions) {
- add2gEntry(entryValuesInt[entryIndex]);
- }
- break;
- case add3gEntry:
- add3gEntry(entryValuesInt[entryIndex]);
- break;
- case addGlobalEntry:
- addGlobalEntry(entryValuesInt[entryIndex]);
- break;
- case addWorldModeCdmaEntry:
- addCustomEntry(
- getResourcesForSubId().getString(
- R.string.network_world_mode_cdma_lte),
- entryValuesInt[entryIndex]);
- break;
- case addWorldModeGsmEntry:
- addCustomEntry(
- getResourcesForSubId().getString(
- R.string.network_world_mode_gsm_lte),
- entryValuesInt[entryIndex]);
- break;
- case add4gEntry:
- add4gEntry(entryValuesInt[entryIndex]);
- break;
- case addLteEntry:
- addLteEntry(entryValuesInt[entryIndex]);
- break;
- case add5gEntry:
- add5gEntry(addNrToLteNetworkType(entryValuesInt[entryIndex]));
- break;
- case add5gAnd4gEntry:
- add5gEntry(addNrToLteNetworkType(entryValuesInt[entryIndex]));
- add4gEntry(entryValuesInt[entryIndex]);
- break;
- case add5gAndLteEntry:
- add5gEntry(addNrToLteNetworkType(entryValuesInt[entryIndex]));
- addLteEntry(entryValuesInt[entryIndex]);
- break;
- default:
- throw new IllegalArgumentException("Not supported ui options format.");
+ case add1xEntry:
+ if (mDisplay2gOptions) {
+ add1xEntry(entryValuesInt[entryIndex]);
+ }
+ break;
+ case add2gEntry:
+ if (mDisplay2gOptions) {
+ add2gEntry(entryValuesInt[entryIndex]);
+ }
+ break;
+ case add3gEntry:
+ if (mDisplay3gOptions) {
+ add3gEntry(entryValuesInt[entryIndex]);
+ }
+ break;
+ case addGlobalEntry:
+ addGlobalEntry(entryValuesInt[entryIndex]);
+ break;
+ case addWorldModeCdmaEntry:
+ addCustomEntry(
+ getResourcesForSubId().getString(
+ R.string.network_world_mode_cdma_lte),
+ entryValuesInt[entryIndex]);
+ break;
+ case addWorldModeGsmEntry:
+ addCustomEntry(
+ getResourcesForSubId().getString(
+ R.string.network_world_mode_gsm_lte),
+ entryValuesInt[entryIndex]);
+ break;
+ case add4gEntry:
+ add4gEntry(entryValuesInt[entryIndex]);
+ break;
+ case addLteEntry:
+ addLteEntry(entryValuesInt[entryIndex]);
+ break;
+ case add5gEntry:
+ add5gEntry(addNrToLteNetworkType(entryValuesInt[entryIndex]));
+ break;
+ case add5gAnd4gEntry:
+ add5gEntry(addNrToLteNetworkType(entryValuesInt[entryIndex]));
+ add4gEntry(entryValuesInt[entryIndex]);
+ break;
+ case add5gAndLteEntry:
+ add5gEntry(addNrToLteNetworkType(entryValuesInt[entryIndex]));
+ addLteEntry(entryValuesInt[entryIndex]);
+ break;
+ default:
+ throw new IllegalArgumentException("Not supported ui options format.");
}
});
}
@@ -402,7 +427,6 @@
private EnabledNetworks getEnabledNetworkType() {
EnabledNetworks enabledNetworkType = EnabledNetworks.ENABLED_NETWORKS_UNKNOWN;
final int phoneType = mTelephonyManager.getPhoneType();
- final PersistableBundle carrierConfig = mCarrierConfigCache.getConfigForSubId(mSubId);
if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
final int lteForced = android.provider.Settings.Global.getInt(
@@ -437,17 +461,17 @@
} else if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
if (MobileNetworkUtils.isTdscdmaSupported(mContext, mSubId)) {
enabledNetworkType = EnabledNetworks.ENABLED_NETWORKS_TDSCDMA_CHOICES;
- } else if (carrierConfig != null
- && !carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)
- && !carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
+ } else if (!mDisplay2gOptions && !mDisplay3gOptions) {
+ enabledNetworkType = mShow4gForLTE
+ ? EnabledNetworks.ENABLED_NETWORKS_4G_CHOICES_EXCEPT_GSM_3G
+ : EnabledNetworks.ENABLED_NETWORKS_CHOICES_EXCEPT_GSM_3G;
+ } else if (!mDisplay2gOptions && !mLteEnabled) {
enabledNetworkType = EnabledNetworks.ENABLED_NETWORKS_EXCEPT_GSM_LTE_CHOICES;
- } else if (carrierConfig != null
- && !carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)) {
+ } else if (!mDisplay2gOptions) {
enabledNetworkType = mShow4gForLTE
? EnabledNetworks.ENABLED_NETWORKS_EXCEPT_GSM_4G_CHOICES
: EnabledNetworks.ENABLED_NETWORKS_EXCEPT_GSM_CHOICES;
- } else if (carrierConfig != null
- && !carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
+ } else if (!mLteEnabled) {
enabledNetworkType = EnabledNetworks.ENABLED_NETWORKS_EXCEPT_LTE_CHOICES;
} else if (mIsGlobalCdma) {
enabledNetworkType = EnabledNetworks.ENABLED_NETWORKS_CDMA_CHOICES;
@@ -462,6 +486,13 @@
enabledNetworkType = EnabledNetworks.PREFERRED_NETWORK_MODE_CHOICES_WORLD_MODE;
}
+ if (phoneType == TelephonyManager.PHONE_TYPE_NONE) {
+ Log.d(LOG_TAG, "phoneType: PHONE_TYPE_NONE");
+ enabledNetworkType = mShow4gForLTE
+ ? EnabledNetworks.ENABLED_NETWORKS_4G_CHOICES_EXCEPT_GSM_3G
+ : EnabledNetworks.ENABLED_NETWORKS_CHOICES_EXCEPT_GSM_3G;
+ }
+
Log.d(LOG_TAG, "enabledNetworkType: " + enabledNetworkType);
return enabledNetworkType;
}
diff --git a/src/com/android/settings/password/BiometricFragment.java b/src/com/android/settings/password/BiometricFragment.java
index e4c08e7..d364c71 100644
--- a/src/com/android/settings/password/BiometricFragment.java
+++ b/src/com/android/settings/password/BiometricFragment.java
@@ -129,6 +129,7 @@
mBiometricPrompt = new BiometricPrompt.Builder(getContext())
.setTitle(promptInfo.getTitle())
.setUseDefaultTitle() // use default title if title is null/empty
+ .setUseDefaultSubtitle() // use default subtitle if subtitle is null/empty
.setDeviceCredentialAllowed(true)
.setSubtitle(promptInfo.getSubtitle())
.setDescription(promptInfo.getDescription())
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 3b5600f..e56e86c 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -212,7 +212,7 @@
getTitleFromCredentialType(credentialType, isEffectiveUserManagedProfile));
}
if (mDetails == null) {
- promptInfo.setSubtitle(
+ promptInfo.setDeviceCredentialSubtitle(
getDetailsFromCredentialType(credentialType, isEffectiveUserManagedProfile));
}
diff --git a/src/com/android/settings/safetycenter/MoreSecurityPrivacyFragment.java b/src/com/android/settings/safetycenter/MoreSecurityPrivacyFragment.java
index 95732f4..3eb6102 100644
--- a/src/com/android/settings/safetycenter/MoreSecurityPrivacyFragment.java
+++ b/src/com/android/settings/safetycenter/MoreSecurityPrivacyFragment.java
@@ -33,6 +33,7 @@
import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.drawer.CategoryKey;
import com.android.settingslib.search.SearchIndexable;
import java.util.ArrayList;
@@ -60,6 +61,11 @@
}
@Override
+ public String getCategoryKey() {
+ return CategoryKey.CATEGORY_MORE_SECURITY_PRIVACY_SETTINGS;
+ }
+
+ @Override
protected String getLogTag() {
return TAG;
}
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 957d2fb..9a29c1c 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -97,6 +97,8 @@
AdapterView.OnItemSelectedListener, OnCheckedChangeListener,
TextView.OnEditorActionListener, View.OnKeyListener {
private static final String TAG = "WifiConfigController2";
+ @VisibleForTesting
+ static final String DEFAULT_ANONYMOUS_ID = "anonymous";
private static final String SYSTEM_CA_STORE_PATH = "/system/etc/security/cacerts";
@@ -187,7 +189,8 @@
private ArrayAdapter<CharSequence> mPhase2Adapter;
private Spinner mEapUserCertSpinner;
private TextView mEapIdentityView;
- private TextView mEapAnonymousView;
+ @VisibleForTesting
+ TextView mEapAnonymousView;
private Spinner mIpSettingsSpinner;
private TextView mIpAddressView;
@@ -1256,7 +1259,7 @@
mPhase2Spinner.setAdapter(mPhase2Adapter);
}
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
- mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
+ setAnonymousIdVisible();
showPeapFields();
setUserCertInvisible();
break;
@@ -1267,7 +1270,7 @@
mPhase2Spinner.setAdapter(mPhase2Adapter);
}
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
- mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
+ setAnonymousIdVisible();
setUserCertInvisible();
mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
break;
@@ -1313,7 +1316,6 @@
mView.findViewById(R.id.l_sim).setVisibility(View.VISIBLE);
} else {
mView.findViewById(R.id.l_identity).setVisibility(View.VISIBLE);
- mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
mView.findViewById(R.id.password_layout).setVisibility(View.VISIBLE);
mView.findViewById(R.id.show_password_layout).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_sim).setVisibility(View.GONE);
@@ -1358,6 +1360,12 @@
mEapAnonymousView.setText("");
}
+ @VisibleForTesting
+ void setAnonymousIdVisible() {
+ mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
+ mEapAnonymousView.setText(DEFAULT_ANONYMOUS_ID);
+ }
+
private void setPasswordInvisible() {
mPasswordView.setText("");
mView.findViewById(R.id.password_layout).setVisibility(View.GONE);
diff --git a/tests/robotests/src/com/android/settings/UtilsTest.java b/tests/robotests/src/com/android/settings/UtilsTest.java
index 0ef1f3a..7303b74 100644
--- a/tests/robotests/src/com/android/settings/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/UtilsTest.java
@@ -18,6 +18,7 @@
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -59,6 +60,9 @@
import androidx.core.graphics.drawable.IconCompat;
import androidx.fragment.app.FragmentActivity;
+import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,6 +71,7 @@
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowBinder;
import java.net.InetAddress;
@@ -74,6 +79,7 @@
import java.util.List;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowLockPatternUtils.class)
public class UtilsTest {
private static final String PACKAGE_NAME = "com.android.app";
@@ -88,7 +94,7 @@
@Mock
private DevicePolicyManager mDevicePolicyManager;
@Mock
- private UserManager mUserManager;
+ private UserManager mMockUserManager;
@Mock
private PackageManager mPackageManager;
@Mock
@@ -96,18 +102,27 @@
@Mock
private ApplicationInfo mApplicationInfo;
private Context mContext;
+ private UserManager mUserManager;
+ private static final int FLAG_SYSTEM = 0x00000000;
+ private static final int FLAG_MAIN = 0x00004000;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
+ mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
when(mContext.getSystemService(WifiManager.class)).thenReturn(wifiManager);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
.thenReturn(connectivityManager);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
}
+ @After
+ public void tearDown() {
+ ShadowLockPatternUtils.reset();
+ }
+
@Test
public void getWifiIpAddresses_succeeds() throws Exception {
when(wifiManager.getCurrentNetwork()).thenReturn(network);
@@ -173,8 +188,9 @@
public void isProfileOrDeviceOwner_deviceOwnerApp_returnTrue() {
when(mDevicePolicyManager.isDeviceOwnerAppOnAnyUser(PACKAGE_NAME)).thenReturn(true);
- assertThat(Utils.isProfileOrDeviceOwner(mUserManager, mDevicePolicyManager, PACKAGE_NAME))
- .isTrue();
+ assertThat(
+ Utils.isProfileOrDeviceOwner(mMockUserManager, mDevicePolicyManager, PACKAGE_NAME))
+ .isTrue();
}
@Test
@@ -182,12 +198,13 @@
final List<UserInfo> userInfos = new ArrayList<>();
userInfos.add(new UserInfo());
- when(mUserManager.getUsers()).thenReturn(userInfos);
+ when(mMockUserManager.getUsers()).thenReturn(userInfos);
when(mDevicePolicyManager.getProfileOwnerAsUser(userInfos.get(0).id))
.thenReturn(new ComponentName(PACKAGE_NAME, ""));
- assertThat(Utils.isProfileOrDeviceOwner(mUserManager, mDevicePolicyManager, PACKAGE_NAME))
- .isTrue();
+ assertThat(
+ Utils.isProfileOrDeviceOwner(mMockUserManager, mDevicePolicyManager, PACKAGE_NAME))
+ .isTrue();
}
@Test
@@ -339,4 +356,20 @@
assertThat(Utils.canCurrentUserDream(mockContext)).isFalse();
}
+
+ @Test
+ public void checkUserOwnsFrpCredential_userOwnsFrpCredential_returnUserId() {
+ ShadowLockPatternUtils.setUserOwnsFrpCredential(true);
+
+ assertThat(Utils.checkUserOwnsFrpCredential(mContext, 123)).isEqualTo(123);
+ }
+
+ @Test
+ public void checkUserOwnsFrpCredential_userNotOwnsFrpCredential_returnUserId() {
+ ShadowLockPatternUtils.setUserOwnsFrpCredential(false);
+
+ assertThrows(
+ SecurityException.class,
+ () -> Utils.checkUserOwnsFrpCredential(mContext, 123));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
index 1aefd14..58bc061 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragmentTest.java
@@ -114,7 +114,7 @@
new ArrayList<>(restrictApps));
mUnrestrictAppTip = new UnrestrictAppTip(BatteryTip.StateType.NEW, mAppInfo);
- mDefenderTip = new BatteryDefenderTip(BatteryTip.StateType.NEW);
+ mDefenderTip = new BatteryDefenderTip(BatteryTip.StateType.NEW, false /* isPluggedIn */);
}
@After
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java
index 3312e16..e4f286d 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/BatteryTipUtilsTest.java
@@ -63,7 +63,8 @@
mRestrictAppTip = spy(new RestrictAppTip(BatteryTip.StateType.NEW, new ArrayList<>()));
mLowBatteryTip = spy(
new LowBatteryTip(BatteryTip.StateType.NEW, false /* powerSaveModeOn */));
- mBatteryDefenderTip = spy(new BatteryDefenderTip(BatteryTip.StateType.NEW));
+ mBatteryDefenderTip = spy(new BatteryDefenderTip(BatteryTip.StateType.NEW,
+ false /* isPluggedIn */));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
index 245bacc..7104206 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/LowBatteryDetectorTest.java
@@ -21,7 +21,6 @@
import static org.mockito.Mockito.spy;
import android.content.Context;
-import android.os.PowerManager;
import com.android.settings.fuelgauge.BatteryInfo;
import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
@@ -34,8 +33,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowPowerManager;
import org.robolectric.util.ReflectionHelpers;
import java.util.concurrent.TimeUnit;
@@ -47,7 +44,6 @@
private BatteryInfo mBatteryInfo;
private BatteryTipPolicy mPolicy;
private LowBatteryDetector mLowBatteryDetector;
- private ShadowPowerManager mShadowPowerManager;
private Context mContext;
@Before
@@ -56,18 +52,19 @@
mPolicy = spy(new BatteryTipPolicy(RuntimeEnvironment.application));
mContext = RuntimeEnvironment.application;
- mShadowPowerManager = Shadows.shadowOf(mContext.getSystemService(PowerManager.class));
ReflectionHelpers.setField(mPolicy, "lowBatteryEnabled", true);
ReflectionHelpers.setField(mPolicy, "lowBatteryHour", 3);
mBatteryInfo.discharging = true;
- mLowBatteryDetector = new LowBatteryDetector(mContext, mPolicy, mBatteryInfo);
+ mLowBatteryDetector = new LowBatteryDetector(mContext, mPolicy, mBatteryInfo,
+ false /* isPowerSaveMode */);
}
@Test
public void testDetect_disabledByPolicy_tipInvisible() {
ReflectionHelpers.setField(mPolicy, "lowBatteryEnabled", false);
- mShadowPowerManager.setIsPowerSaveMode(true);
+ mLowBatteryDetector = new LowBatteryDetector(mContext, mPolicy, mBatteryInfo,
+ true /* isPowerSaveMode */);
assertThat(mLowBatteryDetector.detect().isVisible()).isFalse();
}
@@ -92,7 +89,8 @@
@Test
public void testDetect_batterySaverOn_tipInvisible() {
- mShadowPowerManager.setIsPowerSaveMode(true);
+ mLowBatteryDetector = new LowBatteryDetector(mContext, mPolicy, mBatteryInfo,
+ true /* isPowerSaveMode */);
assertThat(mLowBatteryDetector.detect().getState())
.isEqualTo(BatteryTip.StateType.INVISIBLE);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetectorTest.java
index 00dcbd4..d40f5b8 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/SmartBatteryDetectorTest.java
@@ -36,8 +36,6 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowPowerManager;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
@@ -50,7 +48,7 @@
private ContentResolver mContentResolver;
private SmartBatteryDetector mSmartBatteryDetector;
private BatteryTipPolicy mPolicy;
- private ShadowPowerManager mShadowPowerManager;
+
@Mock
private BatteryInfo mBatteryInfo;
@@ -61,9 +59,8 @@
mContext = RuntimeEnvironment.application;
mContentResolver = mContext.getContentResolver();
mPolicy = spy(new BatteryTipPolicy(mContext));
- mShadowPowerManager = Shadows.shadowOf(mContext.getSystemService(PowerManager.class));
- mSmartBatteryDetector =
- new SmartBatteryDetector(mContext, mPolicy, mBatteryInfo, mContentResolver);
+ mSmartBatteryDetector = new SmartBatteryDetector(mContext, mPolicy, mBatteryInfo,
+ mContentResolver, false /* isPowerSaveMode */);
}
@Test
@@ -77,7 +74,6 @@
public void testDetect_smartBatteryOff_tipVisible() {
Settings.Global.putInt(mContentResolver,
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, 0);
- mShadowPowerManager.setIsPowerSaveMode(false);
mBatteryInfo.batteryLevel = EXPECTED_BATTERY_LEVEL;
assertThat(mSmartBatteryDetector.detect().isVisible()).isTrue();
@@ -87,8 +83,9 @@
public void testDetect_batterySaverOn_tipInvisible() {
Settings.Global.putInt(mContentResolver,
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, 0);
- mShadowPowerManager.setIsPowerSaveMode(true);
mBatteryInfo.batteryLevel = EXPECTED_BATTERY_LEVEL;
+ mSmartBatteryDetector = new SmartBatteryDetector(mContext, mPolicy, mBatteryInfo,
+ mContentResolver, true /* isPowerSaveMode */);
assertThat(mSmartBatteryDetector.detect().isVisible()).isFalse();
}
@@ -97,8 +94,9 @@
public void testDetect_unexpectedBatteryLevel_tipInvisible() {
Settings.Global.putInt(mContentResolver,
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, 0);
- mShadowPowerManager.setIsPowerSaveMode(true);
mBatteryInfo.batteryLevel = UNEXPECTED_BATTERY_LEVEL;
+ mSmartBatteryDetector = new SmartBatteryDetector(mContext, mPolicy, mBatteryInfo,
+ mContentResolver, true /* isPowerSaveMode */);
assertThat(mSmartBatteryDetector.detect().isVisible()).isFalse();
}
@@ -107,7 +105,6 @@
public void testDetect_smartBatteryOn_tipInvisible() {
Settings.Global.putInt(mContentResolver,
Settings.Global.ADAPTIVE_BATTERY_MANAGEMENT_ENABLED, 1);
- mShadowPowerManager.setIsPowerSaveMode(false);
mBatteryInfo.batteryLevel = EXPECTED_BATTERY_LEVEL;
assertThat(mSmartBatteryDetector.detect().isVisible()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
index 8b6033a..244c394 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/BatteryDefenderTipTest.java
@@ -26,9 +26,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.BatteryManager;
import android.util.Log;
import androidx.preference.Preference;
@@ -66,7 +63,8 @@
mFeatureFactory = FakeFeatureFactory.setupForTest();
mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
mContext = RuntimeEnvironment.application;
- mBatteryDefenderTip = new BatteryDefenderTip(BatteryTip.StateType.NEW);
+ mBatteryDefenderTip = new BatteryDefenderTip(BatteryTip.StateType.NEW,
+ false /* isPluggedIn */);
when(mPreference.getContext()).thenReturn(mContext);
when(mCardPreference.getContext()).thenReturn(mContext);
@@ -133,7 +131,8 @@
@Test
public void updatePreference_whenCharging_setPrimaryButtonVisibleToBeTrue() {
- fakeDeviceIsCharging(true);
+ mBatteryDefenderTip = new BatteryDefenderTip(BatteryTip.StateType.NEW,
+ true /* isPluggedIn */);
mBatteryDefenderTip.updatePreference(mCardPreference);
@@ -142,8 +141,6 @@
@Test
public void updatePreference_whenNotCharging_setPrimaryButtonVisibleToBeFalse() {
- fakeDeviceIsCharging(false);
-
mBatteryDefenderTip.updatePreference(mCardPreference);
verify(mCardPreference).setPrimaryButtonVisible(false);
@@ -158,23 +155,10 @@
verify(mCardPreference).setPrimaryButtonVisible(false);
}
- private void fakeDeviceIsCharging(boolean charging) {
- int charged = charging ? 1 : 0; // 1 means charging, 0:not charging
- Intent batteryChangedIntent = new Intent(Intent.ACTION_BATTERY_CHANGED);
- batteryChangedIntent.putExtra(BatteryManager.EXTRA_PLUGGED, charged);
-
- Context mockContext = mock(Context.class);
- when(mockContext.getString(anyInt())).thenReturn("fake_string");
- when(mCardPreference.getContext()).thenReturn(mockContext);
- when(mockContext.registerReceiver(eq(null), any(IntentFilter.class)))
- .thenReturn(batteryChangedIntent);
- }
-
private void fakeGetChargingStatusFailed() {
Context mockContext = mock(Context.class);
when(mockContext.getString(anyInt())).thenReturn("fake_string");
when(mCardPreference.getContext()).thenReturn(mockContext);
- when(mockContext.registerReceiver(eq(null), any(IntentFilter.class))).thenReturn(null);
}
private String getLastErrorLog() {
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
index 74e3971..157c218 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java
@@ -19,6 +19,8 @@
import android.app.admin.DevicePolicyManager;
import android.app.admin.PasswordMetrics;
import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.UserInfo;
import android.os.UserHandle;
import com.android.internal.widget.LockPatternUtils;
@@ -42,6 +44,8 @@
private static Map<Integer, PasswordMetrics> sUserToProfileMetricsMap = new HashMap<>();
private static Map<Integer, Boolean> sUserToIsSecureMap = new HashMap<>();
+ private static boolean sIsUserOwnsFrpCredential;
+
@Resetter
public static void reset() {
sUserToComplexityMap.clear();
@@ -50,6 +54,7 @@
sUserToProfileMetricsMap.clear();
sUserToIsSecureMap.clear();
sDeviceEncryptionEnabled = false;
+ sIsUserOwnsFrpCredential = false;
}
@Implementation
@@ -122,6 +127,15 @@
return complexity;
}
+ @Implementation
+ public static boolean userOwnsFrpCredential(Context context, UserInfo info) {
+ return sIsUserOwnsFrpCredential;
+ }
+
+ public static void setUserOwnsFrpCredential(boolean isUserOwnsFrpCredential) {
+ sIsUserOwnsFrpCredential = isUserOwnsFrpCredential;
+ }
+
public static void setRequiredPasswordComplexity(int userHandle, int complexity) {
sUserToComplexityMap.put(userHandle, complexity);
}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
index 4a24ffa..ad086b7 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigController2Test.java
@@ -16,6 +16,7 @@
package com.android.settings.wifi;
+import static com.android.settings.wifi.WifiConfigController2.DEFAULT_ANONYMOUS_ID;
import static com.android.settings.wifi.WifiConfigController2.WIFI_EAP_METHOD_SIM;
import static com.google.common.truth.Truth.assertThat;
@@ -963,6 +964,20 @@
assertThat(list).doesNotContain(WIFI_EAP_TLS_V1_3);
}
+ @Test
+ public void setAnonymousIdVisible_showAnonymousIdAndSetDefaultId() {
+ View anonymousLayout = mView.findViewById(R.id.l_anonymous);
+ TextView anonymousId = mView.findViewById(R.id.anonymous);
+ mController.mEapAnonymousView = anonymousId;
+ anonymousLayout.setVisibility(View.GONE);
+ anonymousId.setText("");
+
+ mController.setAnonymousIdVisible();
+
+ assertThat(anonymousLayout.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(anonymousId.getText().toString()).isEqualTo(DEFAULT_ANONYMOUS_ID);
+ }
+
private void setUpModifyingSavedCertificateConfigController(String savedCaCertificate,
String savedUserCertificate) {
final WifiConfiguration mockWifiConfig = mock(WifiConfiguration.class);
diff --git a/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
index 4b99646..7f170b5 100644
--- a/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/EnabledNetworkModePreferenceControllerTest.java
@@ -497,6 +497,7 @@
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL, true);
mPersistableBundle.putBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL, true);
}
+ mController.init(SUB_ID);
}
private void mockAllowedNetworkTypes(long allowedNetworkType) {