diff --git a/res/layout/dream_preference_layout.xml b/res/layout/dream_preference_layout.xml
index abb2a34d922..894ac32acba 100644
--- a/res/layout/dream_preference_layout.xml
+++ b/res/layout/dream_preference_layout.xml
@@ -64,36 +64,38 @@
app:layout_constraintStart_toStartOf="@+id/preview"
app:layout_constraintEnd_toEndOf="@+id/preview"/>
-
-
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/summary_text"/>
+
+
diff --git a/res/layout/dream_preview_button.xml b/res/layout/dream_preview_button.xml
index b34786312f3..f4d7ca11671 100644
--- a/res/layout/dream_preview_button.xml
+++ b/res/layout/dream_preview_button.xml
@@ -24,10 +24,10 @@
android:layout_height="wrap_content"
android:text="@string/dream_preview_button_title"
android:textAllCaps="false"
- android:textColor="?androidprv:attr/textColorOnAccent"
+ android:textColor="?android:attr/textColorPrimaryInverse"
android:theme="@style/Theme.CollapsingToolbar.Settings"
android:layout_marginBottom="16dp"
android:layout_gravity="bottom|center"
app:backgroundTint="?androidprv:attr/colorAccentPrimaryVariant"
- app:iconTint="?androidprv:attr/textColorOnAccent"
+ app:iconTint="?android:attr/textColorPrimaryInverse"
app:icon="@drawable/dream_preview_icon"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 78dbccee23e..5cd1ebb244e 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -445,10 +445,12 @@
28dp
8dp
20dp
- 18dp
+ 14sp
+ 16dp
8dp
- 18dp
- 10dp
+ 16sp
+ 18dp
+ 8dp
16dp
20dp
48dp
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7726b403c19..d29e3520af6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -13343,6 +13343,10 @@
Show device controls
Access controls when locked
+
+ Control from locked device
+
+ Control external devices without unlocking your phone or tablet if allowed by the device controls app
Show double-line clock when available
diff --git a/res/values/styles.xml b/res/values/styles.xml
index ebaea6b18aa..38277675729 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -734,6 +734,7 @@
parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title" >
- center_horizontal
- 6dp
+ - 14sp
+
+
supportedSystemLocales = new ArrayList<>();
+ Collection supportedSystemLocales = new HashSet<>();
getCurrentSystemLocales().forEach(systemLocale -> {
mAppSupportedLocales.forEach(supportedLocale -> {
if (compareLocale(systemLocale, supportedLocale)) {
diff --git a/src/com/android/settings/display/ControlsPrivacyPreferenceController.java b/src/com/android/settings/display/ControlsPrivacyPreferenceController.java
index 00573a784a9..6f146d5968b 100644
--- a/src/com/android/settings/display/ControlsPrivacyPreferenceController.java
+++ b/src/com/android/settings/display/ControlsPrivacyPreferenceController.java
@@ -30,6 +30,9 @@ import com.android.settings.overlay.FeatureFactory;
/**
* Preference for showing/hiding sensitive device controls content while the device is locked.
+ *
+ * Note that ControlsTrivialPrivacyPreferenceController depends on the preferenceKey
+ * of this controller.
*/
public class ControlsPrivacyPreferenceController extends TogglePreferenceController {
diff --git a/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceController.java b/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceController.java
new file mode 100644
index 00000000000..a6c8e03d53c
--- /dev/null
+++ b/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceController.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2022 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.display;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Preference for requiring authorization to use home controls for certain devices.
+ */
+public class ControlsTrivialPrivacyPreferenceController extends TogglePreferenceController {
+
+ private static final String SETTING_KEY = Settings.Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS;
+ private static final String DEPENDENCY_SETTING_KEY = Settings.Secure.LOCKSCREEN_SHOW_CONTROLS;
+
+ public ControlsTrivialPrivacyPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getInt(mContext.getContentResolver(), SETTING_KEY, 0) != 0;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putInt(mContext.getContentResolver(), SETTING_KEY,
+ isChecked ? 1 : 0);
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return mContext.getText(R.string.lockscreen_trivial_controls_summary);
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ preference.setEnabled(getAvailabilityStatus() != DISABLED_DEPENDENT_SETTING);
+ refreshSummary(preference);
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_display;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return showDeviceControlsSettingsEnabled() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ }
+
+ private boolean showDeviceControlsSettingsEnabled() {
+ return Settings.Secure.getInt(mContext.getContentResolver(), DEPENDENCY_SETTING_KEY, 0)
+ != 0;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ Preference currentPreference = screen.findPreference(getPreferenceKey());
+ currentPreference.setDependency("lockscreen_privacy_controls_switch");
+ }
+}
diff --git a/src/com/android/settings/dream/DreamAdapter.java b/src/com/android/settings/dream/DreamAdapter.java
index 4e16ccb2240..154181dca4a 100644
--- a/src/com/android/settings/dream/DreamAdapter.java
+++ b/src/com/android/settings/dream/DreamAdapter.java
@@ -16,9 +16,11 @@
package com.android.settings.dream;
+import android.annotation.LayoutRes;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -39,14 +41,15 @@ import java.util.List;
*/
public class DreamAdapter extends RecyclerView.Adapter {
private final List mItemList;
+ private final @LayoutRes int mLayoutRes;
private int mLastSelectedPos = -1;
/**
* View holder for each {@link IDreamItem}.
*/
private class DreamViewHolder extends RecyclerView.ViewHolder {
- private final ImageView mIconView;
private final TextView mTitleView;
+ private final TextView mSummaryView;
private final ImageView mPreviewView;
private final ImageView mPreviewPlaceholderView;
private final Button mCustomizeButton;
@@ -57,8 +60,8 @@ public class DreamAdapter extends RecyclerView.Adapter
mContext = context;
mPreviewView = view.findViewById(R.id.preview);
mPreviewPlaceholderView = view.findViewById(R.id.preview_placeholder);
- mIconView = view.findViewById(R.id.icon);
mTitleView = view.findViewById(R.id.title_text);
+ mSummaryView = view.findViewById(R.id.summary_text);
mCustomizeButton = view.findViewById(R.id.customize_button);
}
@@ -68,6 +71,14 @@ public class DreamAdapter extends RecyclerView.Adapter
public void bindView(IDreamItem item, int position) {
mTitleView.setText(item.getTitle());
+ final CharSequence summary = item.getSummary();
+ if (TextUtils.isEmpty(summary)) {
+ mSummaryView.setVisibility(View.GONE);
+ } else {
+ mSummaryView.setText(summary);
+ mSummaryView.setVisibility(View.VISIBLE);
+ }
+
final Drawable previewImage = item.getPreviewImage();
if (previewImage != null) {
mPreviewView.setImageDrawable(previewImage);
@@ -82,7 +93,10 @@ public class DreamAdapter extends RecyclerView.Adapter
icon.setTint(Utils.getColorAttrDefaultColor(mContext,
com.android.internal.R.attr.colorAccentPrimaryVariant));
}
- mIconView.setImageDrawable(icon);
+ final int iconSize = mContext.getResources().getDimensionPixelSize(
+ R.dimen.dream_item_icon_size);
+ icon.setBounds(0, 0, iconSize, iconSize);
+ mTitleView.setCompoundDrawablesRelative(icon, null, null, null);
if (item.isActive()) {
mLastSelectedPos = position;
@@ -104,15 +118,16 @@ public class DreamAdapter extends RecyclerView.Adapter
}
}
- public DreamAdapter(List itemList) {
+ public DreamAdapter(@LayoutRes int layoutRes, List itemList) {
mItemList = itemList;
+ mLayoutRes = layoutRes;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
View view = LayoutInflater.from(viewGroup.getContext())
- .inflate(R.layout.dream_preference_layout, viewGroup, false);
+ .inflate(mLayoutRes, viewGroup, false);
return new DreamViewHolder(view, viewGroup.getContext());
}
diff --git a/src/com/android/settings/dream/DreamPickerController.java b/src/com/android/settings/dream/DreamPickerController.java
index b7ba6142413..201d6de7f00 100644
--- a/src/com/android/settings/dream/DreamPickerController.java
+++ b/src/com/android/settings/dream/DreamPickerController.java
@@ -74,9 +74,10 @@ public class DreamPickerController extends BasePreferenceController {
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mAdapter = new DreamAdapter(mDreamInfos.stream()
- .map(DreamItem::new)
- .collect(Collectors.toList()));
+ mAdapter = new DreamAdapter(R.layout.dream_preference_layout,
+ mDreamInfos.stream()
+ .map(DreamItem::new)
+ .collect(Collectors.toList()));
final LayoutPreference pref = screen.findPreference(getPreferenceKey());
if (pref == null) {
@@ -111,6 +112,11 @@ public class DreamPickerController extends BasePreferenceController {
return mDreamInfo.caption;
}
+ @Override
+ public CharSequence getSummary() {
+ return mDreamInfo.description;
+ }
+
@Override
public Drawable getIcon() {
return mDreamInfo.icon;
diff --git a/src/com/android/settings/dream/IDreamItem.java b/src/com/android/settings/dream/IDreamItem.java
index c462fe25502..49c82bec42a 100644
--- a/src/com/android/settings/dream/IDreamItem.java
+++ b/src/com/android/settings/dream/IDreamItem.java
@@ -18,23 +18,52 @@ package com.android.settings.dream;
import android.graphics.drawable.Drawable;
+import androidx.annotation.Nullable;
+
/**
* Interface representing a dream item to be displayed.
*/
public interface IDreamItem {
+ /**
+ * Gets the title of this dream.
+ */
CharSequence getTitle();
+ /**
+ * Gets the summary of this dream, or null if the dream doesn't provide one.
+ */
+ @Nullable
+ CharSequence getSummary();
+
+ /**
+ * Gets the icon for the dream.
+ */
Drawable getIcon();
+ /**
+ * Callback which can be implemented to handle clicks on this dream.
+ */
void onItemClicked();
+ /**
+ * Callback which can be implemented to handle the customization of this dream.
+ */
default void onCustomizeClicked() {
}
+ /**
+ * Gets the preview image of this dream.
+ */
Drawable getPreviewImage();
+ /**
+ * Returns whether or not this dream is currently active.
+ */
boolean isActive();
+ /**
+ * Returns whether to allow customization of this dream or not.
+ */
default boolean allowCustomization() {
return false;
}
diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java
index b3351ac1579..2e4a1f28917 100644
--- a/src/com/android/settings/security/LockscreenDashboardFragment.java
+++ b/src/com/android/settings/security/LockscreenDashboardFragment.java
@@ -21,8 +21,13 @@ import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROF
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.database.ContentObserver;
import android.hardware.display.AmbientDisplayConfiguration;
+import android.net.Uri;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
@@ -68,6 +73,8 @@ public class LockscreenDashboardFragment extends DashboardFragment
private AmbientDisplayConfiguration mConfig;
private OwnerInfoPreferenceController mOwnerInfoPreferenceController;
+ @VisibleForTesting
+ ContentObserver mControlsContentObserver;
@Override
public int getMetricsCategory() {
@@ -106,6 +113,27 @@ public class LockscreenDashboardFragment extends DashboardFragment
use(AmbientDisplayNotificationsPreferenceController.class).setConfig(getConfig(context));
use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
+
+ mControlsContentObserver = new ContentObserver(
+ new Handler(Looper.getMainLooper())) {
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ updatePreferenceStates();
+ }
+ };
+ context.getContentResolver().registerContentObserver(
+ Settings.Secure.getUriFor(Settings.Secure.LOCKSCREEN_SHOW_CONTROLS),
+ false /* notifyForDescendants */, mControlsContentObserver);
+ }
+
+ @Override
+ public void onDetach() {
+ if (mControlsContentObserver != null) {
+ getContext().getContentResolver().unregisterContentObserver(mControlsContentObserver);
+ mControlsContentObserver = null;
+ }
+ super.onDetach();
}
@Override
diff --git a/tests/robotests/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceControllerTest.java
new file mode 100644
index 00000000000..2c53d4e1457
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/ControlsTrivialPrivacyPreferenceControllerTest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2022 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.display;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.verify;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class ControlsTrivialPrivacyPreferenceControllerTest {
+
+ private static final String TEST_KEY = "test_key";
+ private static final String SETTING_KEY = Settings.Secure.LOCKSCREEN_ALLOW_TRIVIAL_CONTROLS;
+ private static final String DEPENDENCY_SETTING_KEY = Settings.Secure.LOCKSCREEN_SHOW_CONTROLS;
+
+ private Context mContext;
+ private ContentResolver mContentResolver;
+ private ControlsTrivialPrivacyPreferenceController mController;
+
+ @Mock
+ private Preference mPreference;
+
+ @Mock
+ private PreferenceScreen mPreferenceScreen;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = ApplicationProvider.getApplicationContext();
+
+ mContentResolver = mContext.getContentResolver();
+
+ mController = new ControlsTrivialPrivacyPreferenceController(mContext, TEST_KEY);
+ }
+
+ @Test
+ public void isCheckedWhenSettingIsTrue() {
+ Settings.Secure.putInt(mContentResolver, SETTING_KEY, 1);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isCheckedWhenSettingIsFalse() {
+ Settings.Secure.putInt(mContentResolver, SETTING_KEY, 0);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isCheckedWhenSettingIsNull() {
+ Settings.Secure.putString(mContentResolver, SETTING_KEY, null);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void checkedMeansSettingIsTrue() {
+ mController.setChecked(true);
+
+ assertThat(Settings.Secure.getInt(mContentResolver, SETTING_KEY, 0)).isNotEqualTo(0);
+ }
+
+ @Test
+ public void uncheckedMeansSettingIsFalse() {
+ mController.setChecked(false);
+
+ assertThat(Settings.Secure.getInt(mContentResolver, SETTING_KEY, 0)).isEqualTo(0);
+ }
+
+ @Test
+ public void getSummaryRequireDeviceControls() {
+ Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 0);
+
+ assertThat(mController.getSummary().toString()).isEqualTo(
+ mContext.getText(R.string.lockscreen_trivial_controls_summary));
+ }
+
+ @Test
+ public void getSummaryDefault() {
+ Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 1);
+
+ assertThat(mController.getSummary().toString()).isEqualTo(
+ mContext.getText(R.string.lockscreen_trivial_controls_summary));
+ }
+
+ @Test
+ public void updateState() {
+ Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 1);
+
+ mController.updateState(mPreference);
+
+ verify(mPreference).setEnabled(anyBoolean());
+ verify(mPreference, atLeastOnce()).setSummary(mController.getSummary());
+ }
+
+ @Test
+ public void getAvailabilityStatusWithoutDeviceControls() {
+ Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 0);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void getAvailabilityStatusWithDeviceControls() {
+ Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 1);
+
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.AVAILABLE);
+ }
+
+ @Test
+ public void setDependency() {
+ Mockito.when(mPreferenceScreen
+ .findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ mController.displayPreference(mPreferenceScreen);
+ verify(mPreference).setDependency(anyString());
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
index 5c60001ee33..bf5e9577250 100644
--- a/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/security/LockscreenDashboardFragmentTest.java
@@ -67,6 +67,7 @@ public class LockscreenDashboardFragmentTest {
.thenReturn(mLockPatternUtils);
mContext = RuntimeEnvironment.application;
mTestFragment = spy(new TestFragment());
+ doReturn(mContext).when(mTestFragment).getContext();
}
@Test
@@ -131,6 +132,14 @@ public class LockscreenDashboardFragmentTest {
.doesNotContain("security_lockscreen_settings_screen");
}
+ @Test
+ public void controlsSettings() {
+ mTestFragment.onAttach(mContext);
+ assertThat(mTestFragment.mControlsContentObserver).isNotNull();
+ mTestFragment.onDetach();
+ assertThat(mTestFragment.mControlsContentObserver).isNull();
+ }
+
public static class TestFragment extends LockscreenDashboardFragment {
@Override
protected T use(Class clazz) {
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
index 0f9d54b441d..aa0daad44ff 100644
--- a/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
+++ b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
@@ -43,7 +43,9 @@ import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Locale;
+import java.util.Set;
/**
* Unittest for ApplocaleDetails
@@ -151,8 +153,9 @@ public class AppLocaleDetailsTest {
@Test
@UiThreadTest
public void
- handleAllLocalesData_noAppAndNoSupportedSimLocale_1stSuggestedLocaleIsAssetLocale() {
- Locale firstAssetLocale = new Locale("en", "GB");
+ handleAllLocalesData_noAppAndNoSupportedSimLocale_suggestedLocaleIsSupported() {
+ Locale testEnAssetLocale = new Locale("en", "GB");
+ Locale testJaAssetLocale = new Locale("ja", "JP");
setupInitialLocales(
/* appLocale= */ "",
/* simCountry= */ "tw",
@@ -166,8 +169,8 @@ public class AppLocaleDetailsTest {
helper.handleAllLocalesData();
Collection suggestedLocales = helper.getSuggestedLocales();
- Locale locale = suggestedLocales.iterator().next();
- assertTrue(locale.equals(firstAssetLocale));
+ assertTrue(suggestedLocales.contains(testEnAssetLocale));
+ assertTrue(suggestedLocales.contains(testJaAssetLocale));
}
@Test
@@ -295,6 +298,35 @@ public class AppLocaleDetailsTest {
assertTrue(locale.equals(systemLocale));
}
+ @Test
+ @UiThreadTest
+ public void handleAllLocalesData_sameLocaleButDifferentRegion_notShowDuplicatedLocale() {
+ setupInitialLocales(
+ /* appLocale= */ "",
+ /* simCountry= */ "",
+ /* networkCountry= */ "",
+ /* systemLocales= */ "en-us, en-gb, jp, ne",
+ /* packageLocales= */ "pa, cn, tw, en-us, en-gb",
+ /* assetLocales= */ new String[]{});
+ DummyAppLocaleDetailsHelper helper =
+ new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+ helper.handleAllLocalesData();
+
+ Collection suggestedLocales = helper.getSuggestedLocales();
+ assertFalse(hasDuplicatedResult(suggestedLocales));
+ }
+
+ private boolean hasDuplicatedResult(Collection locales) {
+ Set tempSet = new HashSet<>();
+ for (Locale locale : locales) {
+ if (!tempSet.add(locale)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Test
@UiThreadTest
public void handleAllLocalesData_supportLocaleListIsNotEmpty() {