From f94762176fed0bdbb160a55e49b0ff34d30f7b82 Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Fri, 11 Mar 2022 12:26:10 +0800 Subject: [PATCH 01/14] Fix that holding volume buttons to activate Extra dim feature doesn't do anything. Root cause: Original framework design which has 3 seconds restriction to prevent users from easily triggering the accessibility volume shortcut when first time using it. Solution: The system would bypass the 3 seconds restriction if users manually set any feature as the volume key shortcut. Bug: 202602908 Test: make RunSettingsRoboTests ROBOTEST_FILTER=ToggleFeaturePreferenceFragmentTest Change-Id: I324321577263904b6ff8b66e411766d16a6430dc --- ...cessibilityShortcutPreferenceFragment.java | 4 ++++ .../accessibility/AccessibilityUtil.java | 11 +++++++++ .../ToggleFeaturePreferenceFragment.java | 4 ++++ ...ScreenMagnificationPreferenceFragment.java | 4 ++++ .../ToggleFeaturePreferenceFragmentTest.java | 23 +++++++++++++++++++ 5 files changed, 46 insertions(+) diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java index a25c4a61207..34e1fb0557d 100644 --- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java +++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java @@ -333,6 +333,10 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF mShortcutPreference.setChecked(shortcutAssigned); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); + if (mHardwareTypeCheckBox.isChecked()) { + AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); + } + // Show the quick setting tooltip if the shortcut assigned in the first time if (shortcutAssigned) { showQuickSettingsTooltipIfNeeded(); diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java index 3e97edc22a4..e2e29333c98 100644 --- a/src/com/android/settings/accessibility/AccessibilityUtil.java +++ b/src/com/android/settings/accessibility/AccessibilityUtil.java @@ -434,4 +434,15 @@ public final class AccessibilityUtil { public static boolean isSystemApp(@NonNull AccessibilityServiceInfo info) { return info.getResolveInfo().serviceInfo.applicationInfo.isSystemApp(); } + + /** + * Bypasses the timeout restriction if volume key shortcut assigned. + * + * @param context the current context. + */ + public static void skipVolumeShortcutDialogTimeoutRestriction(Context context) { + Settings.Secure.putInt(context.getContentResolver(), + Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, /* + true */ 1); + } } diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index ccdc78bd26f..518b94d515e 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -732,6 +732,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference mShortcutPreference.setChecked(shortcutAssigned); mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext())); + if (mHardwareTypeCheckBox.isChecked()) { + AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); + } + // Show the quick setting tooltip if the shortcut assigned in the first time if (shortcutAssigned) { showQuickSettingsTooltipIfNeeded(); diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java index 1176fa462c0..eababa7b1e3 100644 --- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java @@ -361,6 +361,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends mShortcutPreference.setChecked(value != UserShortcutType.EMPTY); mShortcutPreference.setSummary( getShortcutTypeSummary(getPrefContext())); + + if (mHardwareTypeCheckBox.isChecked()) { + AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext()); + } } @Override diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java index 04018a6b6d7..3cbe17b0215 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java @@ -38,6 +38,7 @@ import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.CheckBox; import android.widget.PopupWindow; import androidx.annotation.XmlRes; @@ -183,6 +184,28 @@ public class ToggleFeaturePreferenceFragmentTest { assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE); } + @Test + public void dialogCheckboxClicked_hardwareType_skipTimeoutRestriction() { + mContext.setTheme(R.style.Theme_AppCompat); + final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */ + null); + mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME; + mFragment.mShortcutPreference = shortcutPreference; + final AlertDialog dialog = AccessibilityDialogUtils.showEditShortcutDialog( + mContext, DialogType.EDIT_SHORTCUT_GENERIC, PLACEHOLDER_DIALOG_TITLE, + mFragment::callOnAlertDialogCheckboxClicked); + mFragment.setupEditShortcutDialog(dialog); + + final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut); + final CheckBox hardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox); + hardwareTypeCheckBox.setChecked(true); + dialog.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick(); + final boolean skipTimeoutRestriction = Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.SKIP_ACCESSIBILITY_SHORTCUT_DIALOG_TIMEOUT_RESTRICTION, 0) != 0; + + assertThat(skipTimeoutRestriction).isTrue(); + } + @Test public void setupEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() { mContext.setTheme(R.style.Theme_AppCompat); From caa28b6e1fbf2c0762667194a4767ff597d8f41b Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Fri, 18 Mar 2022 18:01:36 +0800 Subject: [PATCH 02/14] Fix that the user has no way of knowing if the reset was successful. Goal: Added the new confirm dialog into to warn users. Bug: 220126995 Bug: 222419452 Test: make RunSettingsRoboTests ROBOTEST_FILTER=TextReadingResetControllerTest Change-Id: Id6e3ebdd6e9990996a5a4f12d9d19e28d3d58a13 --- ...ccessibility_text_reading_reset_button.xml | 13 +++-- .../AccessibilityDialogUtils.java | 5 ++ .../TextReadingPreferenceFragment.java | 51 +++++++++++++++++-- .../TextReadingResetController.java | 16 +++--- .../TextReadingResetControllerTest.java | 47 ++++------------- 5 files changed, 79 insertions(+), 53 deletions(-) diff --git a/res/layout/accessibility_text_reading_reset_button.xml b/res/layout/accessibility_text_reading_reset_button.xml index dd9128b4eda..f3691e1f816 100644 --- a/res/layout/accessibility_text_reading_reset_button.xml +++ b/res/layout/accessibility_text_reading_reset_button.xml @@ -27,9 +27,14 @@ android:id="@+id/reset_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" - android:paddingHorizontal="24dp" + android:layout_gravity="center|end" android:paddingVertical="14dp" - android:text="@string/accessibility_text_reading_reset_button_title" - style="@style/ActionPrimaryButton"/> + android:background="@null" + android:drawableStart="@drawable/ic_history" + android:drawablePadding="9dp" + android:drawableTint="?android:attr/colorAccent" + android:textColor="?android:attr/colorAccent" + android:textSize="16sp" + android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium" + android:text="@string/accessibility_text_reading_reset_button_title"/> diff --git a/src/com/android/settings/accessibility/AccessibilityDialogUtils.java b/src/com/android/settings/accessibility/AccessibilityDialogUtils.java index f06138f6ec2..c23ef353d7c 100644 --- a/src/com/android/settings/accessibility/AccessibilityDialogUtils.java +++ b/src/com/android/settings/accessibility/AccessibilityDialogUtils.java @@ -119,6 +119,11 @@ public class AccessibilityDialogUtils { * launch tutorial. */ int LAUNCH_ACCESSIBILITY_TUTORIAL = 1008; + + /** + * OPEN: Settings > Accessibility > Display size and text > Click 'Reset settings' button. + */ + int DIALOG_RESET_SETTINGS = 1009; } /** diff --git a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java index 7dd70aff596..da0287677f6 100644 --- a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java +++ b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java @@ -18,10 +18,15 @@ package com.android.settings.accessibility; import static com.android.settings.accessibility.TextReadingResetController.ResetStateListener; +import android.app.Dialog; import android.app.settings.SettingsEnums; import android.content.Context; +import android.content.DialogInterface; + +import androidx.appcompat.app.AlertDialog; import com.android.settings.R; +import com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums; import com.android.settings.dashboard.DashboardFragment; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settingslib.core.AbstractPreferenceController; @@ -88,16 +93,54 @@ public class TextReadingPreferenceFragment extends DashboardFragment { new HighTextContrastPreferenceController(context, HIGHT_TEXT_CONTRAST_KEY); controllers.add(highTextContrastController); - final List resetStateListeners = - controllers.stream().filter(c -> c instanceof ResetStateListener).map( - c -> (ResetStateListener) c).collect(Collectors.toList()); final TextReadingResetController resetController = - new TextReadingResetController(context, RESET_KEY, resetStateListeners); + new TextReadingResetController(context, RESET_KEY, + v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS)); controllers.add(resetController); return controllers; } + @Override + public Dialog onCreateDialog(int dialogId) { + if (dialogId == DialogEnums.DIALOG_RESET_SETTINGS) { + return new AlertDialog.Builder(getPrefContext()) + .setTitle(R.string.accessibility_text_reading_confirm_dialog_title) + .setMessage(R.string.accessibility_text_reading_confirm_dialog_message) + .setPositiveButton( + R.string.accessibility_text_reading_confirm_dialog_reset_button, + this::onPositiveButtonClicked) + .setNegativeButton(R.string.cancel, /* listener= */ null) + .create(); + } + + throw new IllegalArgumentException("Unsupported dialogId " + dialogId); + } + + @Override + public int getDialogMetricsCategory(int dialogId) { + if (dialogId == DialogEnums.DIALOG_RESET_SETTINGS) { + return SettingsEnums.DIALOG_RESET_SETTINGS; + } + + return super.getDialogMetricsCategory(dialogId); + } + + private void onPositiveButtonClicked(DialogInterface dialog, int which) { + // To avoid showing the dialog again, probably the onDetach() of SettingsDialogFragment + // was interrupted by unexpectedly recreating the activity. + removeDialog(DialogEnums.DIALOG_RESET_SETTINGS); + + getResetStateListeners().forEach(ResetStateListener::resetState); + } + + private List getResetStateListeners() { + final List controllers = new ArrayList<>(); + getPreferenceControllers().forEach(controllers::addAll); + return controllers.stream().filter(c -> c instanceof ResetStateListener).map( + c -> (ResetStateListener) c).collect(Collectors.toList()); + } + public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider(R.xml.accessibility_text_reading_options); } diff --git a/src/com/android/settings/accessibility/TextReadingResetController.java b/src/com/android/settings/accessibility/TextReadingResetController.java index f4752cb75fd..152ad5fe4f1 100644 --- a/src/com/android/settings/accessibility/TextReadingResetController.java +++ b/src/com/android/settings/accessibility/TextReadingResetController.java @@ -19,25 +19,23 @@ package com.android.settings.accessibility; import android.content.Context; import android.view.View; -import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.preference.PreferenceScreen; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; import com.android.settingslib.widget.LayoutPreference; -import java.util.List; - /** * The controller of the reset button in the text and reading options page. */ class TextReadingResetController extends BasePreferenceController { - private final List mListeners; + private final View.OnClickListener mOnResetClickListener; TextReadingResetController(Context context, String preferenceKey, - @NonNull List listeners) { + @Nullable View.OnClickListener listener) { super(context, preferenceKey); - mListeners = listeners; + mOnResetClickListener = listener; } @Override @@ -51,7 +49,11 @@ class TextReadingResetController extends BasePreferenceController { final LayoutPreference layoutPreference = screen.findPreference(getPreferenceKey()); final View view = layoutPreference.findViewById(R.id.reset_button); - view.setOnClickListener(v -> mListeners.forEach(ResetStateListener::resetState)); + view.setOnClickListener(v -> { + if (mOnResetClickListener != null) { + mOnResetClickListener.onClick(v); + } + }); } /** diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingResetControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/TextReadingResetControllerTest.java index 2ae8e242a1e..2e4566ceac0 100644 --- a/tests/robotests/src/com/android/settings/accessibility/TextReadingResetControllerTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingResetControllerTest.java @@ -16,10 +16,10 @@ package com.android.settings.accessibility; -import static com.android.settings.accessibility.TextReadingResetController.ResetStateListener; - import static com.google.common.truth.Truth.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.Context; @@ -29,7 +29,6 @@ import androidx.preference.PreferenceScreen; import androidx.test.core.app.ApplicationProvider; import com.android.settings.R; -import com.android.settings.core.BasePreferenceController; import com.android.settingslib.widget.LayoutPreference; import org.junit.Before; @@ -39,21 +38,18 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; -import java.util.ArrayList; -import java.util.List; - /** * Tests for {@link TextReadingResetController}. */ @RunWith(RobolectricTestRunner.class) public class TextReadingResetControllerTest { - private static final String TEST_KEY = "test"; private static final String RESET_KEY = "reset"; private final Context mContext = ApplicationProvider.getApplicationContext(); private final View mResetView = new View(mContext); - private final List mListeners = new ArrayList<>(); private TextReadingResetController mResetController; - private TestPreferenceController mPreferenceController; + + @Mock + private View.OnClickListener mOnResetButtonClickListener; @Mock private PreferenceScreen mPreferenceScreen; @@ -64,10 +60,8 @@ public class TextReadingResetControllerTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - - mPreferenceController = new TestPreferenceController(mContext, TEST_KEY); - mListeners.add(mPreferenceController); - mResetController = new TextReadingResetController(mContext, RESET_KEY, mListeners); + mResetController = new TextReadingResetController(mContext, RESET_KEY, + mOnResetButtonClickListener); } @Test @@ -80,40 +74,17 @@ public class TextReadingResetControllerTest { } @Test - public void triggerResetState_success() { + public void clickResetButtonAfterDisplayPreference_verifyClickListener() { setupResetButton(); mResetController.displayPreference(mPreferenceScreen); mResetView.callOnClick(); - assertThat(mPreferenceController.isReset()).isTrue(); + verify(mOnResetButtonClickListener).onClick(any(View.class)); } private void setupResetButton() { when(mPreferenceScreen.findPreference(RESET_KEY)).thenReturn(mLayoutPreference); when(mLayoutPreference.findViewById(R.id.reset_button)).thenReturn(mResetView); } - - private static class TestPreferenceController extends BasePreferenceController implements - ResetStateListener { - private boolean mIsReset = false; - - TestPreferenceController(Context context, String preferenceKey) { - super(context, preferenceKey); - } - - @Override - public void resetState() { - mIsReset = true; - } - - @Override - public int getAvailabilityStatus() { - return AVAILABLE; - } - - boolean isReset() { - return mIsReset; - } - } } From 1aa790501f5b67cc81539875d25af1965038f0c3 Mon Sep 17 00:00:00 2001 From: Ricky Wai Date: Thu, 17 Mar 2022 18:20:21 +0000 Subject: [PATCH 03/14] Update restricted setting dialog, unlock toast, and menu strings Bug: 224970895 Bug: 224992636 Bug: 224970884 Bug: 224988456 Test: Can see updated strings and toast in UI Change-Id: I29e257fcc15310558ae8e56cbc51de3c874471ed --- res/values/strings.xml | 8 +++++--- .../appinfo/AppInfoDashboardFragment.java | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 2d3532cc72b..80364e39d6d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -4689,8 +4689,8 @@ Clear storage Uninstall updates - - Unlock restricted settings + + Allow restricted settings Some activities you\u2019ve selected open in this app by default. @@ -12184,7 +12184,9 @@ Learn more - Restricted Settings + Restricted setting + + Restricted settings allowed for %s For your security, this setting is currently unavailable. diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java index 5bc4118bfef..ac5330c4f99 100755 --- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java +++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java @@ -48,6 +48,7 @@ import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.widget.Toast; import androidx.annotation.VisibleForTesting; @@ -443,14 +444,14 @@ public class AppInfoDashboardFragment extends DashboardFragment }; final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context) - .setTitle(context.getText(R.string.app_restricted_settings_lockscreen_title)); + .setUseDefaultTitle(); // use default title if title is null/empty - if (context.getSystemService(BiometricManager.class).canAuthenticate( - BiometricManager.Authenticators.DEVICE_CREDENTIAL - | BiometricManager.Authenticators.BIOMETRIC_WEAK) - == BiometricManager.BIOMETRIC_SUCCESS) { - builder.setAllowedAuthenticators(BiometricManager.Authenticators.DEVICE_CREDENTIAL - | BiometricManager.Authenticators.BIOMETRIC_WEAK); + final BiometricManager bm = context.getSystemService(BiometricManager.class); + final int authenticators = BiometricManager.Authenticators.DEVICE_CREDENTIAL + | BiometricManager.Authenticators.BIOMETRIC_WEAK; + if (bm.canAuthenticate(authenticators) == BiometricManager.BIOMETRIC_SUCCESS) { + builder.setAllowedAuthenticators(authenticators); + builder.setSubtitle(bm.getStrings(authenticators).getPromptMessage()); } final BiometricPrompt bp = builder.build(); @@ -481,6 +482,10 @@ public class AppInfoDashboardFragment extends DashboardFragment getPackageName(), AppOpsManager.MODE_ALLOWED); getActivity().invalidateOptionsMenu(); + final String toastString = getContext().getString( + R.string.toast_allows_restricted_settings_successfully, + mAppEntry.label); + Toast.makeText(getContext(), toastString, Toast.LENGTH_LONG).show(); }); return true; } From f1255b429859cc2e86092e58bba7ebe24bb7bf1e Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Wed, 23 Mar 2022 09:54:17 +0000 Subject: [PATCH 04/14] Enable Encryption & Creds UI for Secondary users Bug: 123211155 Test: Manual,m -j RunSettingsRoboTests Change-Id: Ic669102c72a5270423f000d5326b48c91901a0ed --- .../security/EncryptionAndCredential.java | 5 +--- .../EncryptionStatusPreferenceController.java | 4 ++-- .../security/EncryptionAndCredentialTest.java | 24 ------------------- ...ryptionStatusPreferenceControllerTest.java | 15 ------------ 4 files changed, 3 insertions(+), 45 deletions(-) diff --git a/src/com/android/settings/security/EncryptionAndCredential.java b/src/com/android/settings/security/EncryptionAndCredential.java index 5362ad0c92a..e3dd9d5ccf8 100644 --- a/src/com/android/settings/security/EncryptionAndCredential.java +++ b/src/com/android/settings/security/EncryptionAndCredential.java @@ -20,7 +20,6 @@ import static com.android.settings.security.EncryptionStatusPreferenceController import android.app.settings.SettingsEnums; import android.content.Context; -import android.os.UserManager; import com.android.settings.R; import com.android.settings.dashboard.DashboardFragment; @@ -96,9 +95,7 @@ public class EncryptionAndCredential extends DashboardFragment { @Override protected boolean isPageSearchEnabled(Context context) { - final UserManager um = (UserManager) context.getSystemService( - Context.USER_SERVICE); - return um.isAdminUser(); + return true; } }; } diff --git a/src/com/android/settings/security/EncryptionStatusPreferenceController.java b/src/com/android/settings/security/EncryptionStatusPreferenceController.java index d83579822d4..68d1181a0aa 100644 --- a/src/com/android/settings/security/EncryptionStatusPreferenceController.java +++ b/src/com/android/settings/security/EncryptionStatusPreferenceController.java @@ -44,11 +44,11 @@ public class EncryptionStatusPreferenceController extends BasePreferenceControll public int getAvailabilityStatus() { if (TextUtils.equals(getPreferenceKey(), PREF_KEY_ENCRYPTION_DETAIL_PAGE) && !mContext.getResources().getBoolean( - R.bool.config_show_encryption_and_credentials_encryption_status)) { + R.bool.config_show_encryption_and_credentials_encryption_status)) { return UNSUPPORTED_ON_DEVICE; } - return mUserManager.isAdminUser() ? AVAILABLE : DISABLED_FOR_USER; + return AVAILABLE; } @Override diff --git a/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java b/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java index 6f326ce6627..1d7a4a74547 100644 --- a/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java +++ b/tests/robotests/src/com/android/settings/security/EncryptionAndCredentialTest.java @@ -16,19 +16,13 @@ package com.android.settings.security; -import static com.android.settings.security.EncryptionAndCredential.SEARCH_INDEX_DATA_PROVIDER; - import static com.google.common.truth.Truth.assertThat; -import static org.mockito.Mockito.when; - import android.app.admin.DevicePolicyManager; import android.content.Context; import android.os.UserManager; -import android.provider.SearchIndexableResource; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; -import com.android.settings.search.BaseSearchIndexProvider; import org.junit.Before; import org.junit.Test; @@ -39,9 +33,6 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; import org.robolectric.shadows.ShadowApplication; -import java.util.ArrayList; -import java.util.List; - @RunWith(RobolectricTestRunner.class) public class EncryptionAndCredentialTest { @@ -67,19 +58,4 @@ public class EncryptionAndCredentialTest { assertThat(fragment.getMetricsCategory()).isEqualTo(MetricsEvent.ENCRYPTION_AND_CREDENTIAL); } - @Test - public void getNonIndexableKeys_pageIsDisabled_shouldReturnAllKeysAsNonIndexable() { - when(mUserManager.isAdminUser()).thenReturn(false); - - final List index = - SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(mContext, true /* enabled */); - final List expectedKeys = new ArrayList<>(); - for (SearchIndexableResource res : index) { - expectedKeys.addAll(((BaseSearchIndexProvider) SEARCH_INDEX_DATA_PROVIDER) - .getNonIndexableKeysFromXml(mContext, res.xmlResId, true /* suppressAll */)); - } - final List keys = SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext); - - assertThat(keys).containsExactlyElementsIn(expectedKeys); - } } diff --git a/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java index 970564aa04f..410198bf796 100644 --- a/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/security/EncryptionStatusPreferenceControllerTest.java @@ -56,20 +56,6 @@ public class EncryptionStatusPreferenceControllerTest { mPreference = new Preference(mContext); } - @Test - public void isAvailable_admin_true() { - mShadowUserManager.setIsAdminUser(true); - - assertThat(mController.isAvailable()).isTrue(); - } - - @Test - public void isAvailable_notAdmin_false() { - mShadowUserManager.setIsAdminUser(false); - - assertThat(mController.isAvailable()).isFalse(); - } - @Test @Config(qualifiers = "mcc999") public void isAvailable_notVisible_false() { @@ -82,7 +68,6 @@ public class EncryptionStatusPreferenceControllerTest { mController = new EncryptionStatusPreferenceController(mContext, PREF_KEY_ENCRYPTION_SECURITY_PAGE); - mShadowUserManager.setIsAdminUser(true); assertThat(mController.isAvailable()).isTrue(); } From 2f2b648693b603eda6e4879b18ab6cc782420b20 Mon Sep 17 00:00:00 2001 From: Alan Huang Date: Wed, 23 Mar 2022 22:33:25 +0000 Subject: [PATCH 05/14] Fix group cast volume slider not disabled after switching to group devices. Test: manual build and verify Bug: 222443976 Change-Id: Ie9f126bb2f4cbc3c6148f41092ada4bfdfa29f99 --- .../settings/notification/RemoteVolumeGroupController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/android/settings/notification/RemoteVolumeGroupController.java b/src/com/android/settings/notification/RemoteVolumeGroupController.java index 3d8d261aa08..47a12d0aab8 100644 --- a/src/com/android/settings/notification/RemoteVolumeGroupController.java +++ b/src/com/android/settings/notification/RemoteVolumeGroupController.java @@ -119,6 +119,7 @@ public class RemoteVolumeGroupController extends BasePreferenceController implem if (seekBarPreference.getProgress() != info.getVolume()) { seekBarPreference.setProgress(info.getVolume()); } + seekBarPreference.setEnabled(mLocalMediaManager.shouldEnableVolumeSeekBar(info)); } else { // Add slider seekBarPreference = new RemoteVolumeSeekBarPreference(mContext); From b844a7a9201d2335832f2f788f8aa176fd22b4ad Mon Sep 17 00:00:00 2001 From: Weng Su Date: Thu, 24 Mar 2022 20:09:29 +0800 Subject: [PATCH 06/14] Fix Wi-Fi hotspot switch UI issue - The Wi-Fi hotspot switch only handles the click event from the UI. - Use the onSwitchChanged callback to handle click and swipe events. Bug: 218891956 Test: manual test make RunSettingsRoboTests \ ROBOTEST_FILTER=WifiTetherSwitchBarControllerTest Change-Id: Ie4136443845489be295a8ee0f3058f493a3b5829 --- .../tether/WifiTetherSwitchBarController.java | 10 +++---- .../WifiTetherSwitchBarControllerTest.java | 28 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java index cad56e3b3ee..6f86ddd1832 100644 --- a/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java +++ b/src/com/android/settings/wifi/tether/WifiTetherSwitchBarController.java @@ -26,7 +26,6 @@ import android.net.ConnectivityManager; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.Looper; -import android.view.View; import android.widget.Switch; import androidx.annotation.VisibleForTesting; @@ -36,12 +35,13 @@ import com.android.settings.widget.SettingsMainSwitchBar; import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStop; +import com.android.settingslib.widget.OnMainSwitchChangeListener; /** * Controller for logic pertaining to switch Wi-Fi tethering. */ public class WifiTetherSwitchBarController implements - LifecycleObserver, OnStart, OnStop, DataSaverBackend.Listener, View.OnClickListener { + LifecycleObserver, OnStart, OnStop, DataSaverBackend.Listener, OnMainSwitchChangeListener { private static final IntentFilter WIFI_INTENT_FILTER; private final Context mContext; @@ -82,7 +82,7 @@ public class WifiTetherSwitchBarController implements @Override public void onStart() { mDataSaverBackend.addListener(this); - mSwitch.setOnClickListener(this); + mSwitchBar.addOnSwitchChangeListener(this); mContext.registerReceiver(mReceiver, WIFI_INTENT_FILTER, Context.RECEIVER_EXPORTED_UNAUDITED); } @@ -94,8 +94,8 @@ public class WifiTetherSwitchBarController implements } @Override - public void onClick(View v) { - if (((Switch) v).isChecked()) { + public void onSwitchChanged(Switch switchView, boolean isChecked) { + if (isChecked) { startTether(); } else { stopTether(); diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSwitchBarControllerTest.java index b0bd8bc86ab..a27743e2bd7 100644 --- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSwitchBarControllerTest.java +++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSwitchBarControllerTest.java @@ -16,15 +16,14 @@ package com.android.settings.wifi.tether; +import static android.net.ConnectivityManager.TETHERING_WIFI; + import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -52,6 +51,8 @@ public class WifiTetherSwitchBarControllerTest { private ConnectivityManager mConnectivityManager; @Mock private NetworkPolicyManager mNetworkPolicyManager; + @Mock + private Switch mSwitch; private Context mContext; private SettingsMainSwitchBar mSwitchBar; @@ -99,23 +100,20 @@ public class WifiTetherSwitchBarControllerTest { } @Test - public void onSwitchToggled_switchOff_noStartTethering() { - final Switch mockSwitch = mock(Switch.class); - when(mockSwitch.isChecked()).thenReturn(false); + public void onSwitchChanged_isChecked_startTethering() { + when(mSwitch.isChecked()).thenReturn(true); - mController.onClick(mockSwitch); + mController.onSwitchChanged(mSwitch, mSwitch.isChecked()); - verify(mConnectivityManager, never()).startTethering(anyInt(), anyBoolean(), any(), any()); + verify(mConnectivityManager).startTethering(eq(TETHERING_WIFI), anyBoolean(), any(), any()); } @Test - public void onSwitchToggled_switchOn_startTethering() { - final Switch mockSwitch = mock(Switch.class); - when(mockSwitch.isChecked()).thenReturn(true); + public void onSwitchChanged_isNotChecked_stopTethering() { + when(mSwitch.isChecked()).thenReturn(false); - mController.onClick(mockSwitch); + mController.onSwitchChanged(mSwitch, mSwitch.isChecked()); - verify(mConnectivityManager, times(1)) - .startTethering(anyInt(), anyBoolean(), any(), any()); + verify(mConnectivityManager).stopTethering(TETHERING_WIFI); } } From 9fdbd6501c40708771831344ca77b9bfc2cb9296 Mon Sep 17 00:00:00 2001 From: Joshua Mccloskey Date: Tue, 22 Mar 2022 06:39:00 +0000 Subject: [PATCH 07/14] Only play fp vibration if accessibility is enabled. Fixes: 222593183 Test: Verified haptic no longer comes unless accessibility is enabled. Change-Id: Ica04acfe9501bc4ab1afacd77b8ea7cbf725281e --- .../fingerprint/FingerprintEnrollEnrolling.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java index 70140c42c8c..f41316a75c7 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java @@ -32,8 +32,9 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintSensorPropertiesInternal; -import android.media.AudioAttributes; import android.os.Bundle; +import android.os.Process; +import android.os.VibrationAttributes; import android.os.VibrationEffect; import android.os.Vibrator; import android.text.TextUtils; @@ -108,11 +109,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { private static final VibrationEffect VIBRATE_EFFECT_ERROR = VibrationEffect.createWaveform(new long[] {0, 5, 55, 60}, -1); - private static final AudioAttributes FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES = - new AudioAttributes.Builder() - .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) - .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) - .build(); + private static final VibrationAttributes FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES = + VibrationAttributes.createForUsage(VibrationAttributes.USAGE_ACCESSIBILITY); private FingerprintManager mFingerprintManager; private boolean mCanAssumeUdfps; @@ -582,8 +580,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling { mErrorText.setTranslationY(0f); } } - if (isResumed()) { - mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES); + if (isResumed() && (mIsAccessibilityEnabled || !mCanAssumeUdfps)) { + mVibrator.vibrate(Process.myUid(), getApplicationContext().getOpPackageName(), + VIBRATE_EFFECT_ERROR, "FingerprintEnrollEnrolling:showError", + FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES); } } From 64f9d41ee3d56c518483cfa38a6fe95939ceb70c Mon Sep 17 00:00:00 2001 From: Roopa Sattiraju Date: Thu, 24 Mar 2022 10:30:03 -0700 Subject: [PATCH 08/14] Changing apk name in the manifest and the corresponding packages. BUG: 226403247 Test: TH Change-Id: I49ad1169899ffbb76ad00f7d5d02f815ace295e7 --- .../settings/bluetooth/BluetoothPermissionRequest.java | 2 +- ...BluetoothMaxConnectedAudioDevicesPreferenceController.java | 4 ++-- ...toothMaxConnectedAudioDevicesPreferenceControllerTest.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java index 8542fcd2461..7d27a37924f 100644 --- a/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java +++ b/src/com/android/settings/bluetooth/BluetoothPermissionRequest.java @@ -126,7 +126,7 @@ public final class BluetoothPermissionRequest extends BroadcastReceiver { // "Clear All Notifications" button Intent deleteIntent = new Intent(BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY); - deleteIntent.setPackage("com.android.bluetooth"); + deleteIntent.setPackage("com.android.bluetooth.services"); deleteIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice); deleteIntent.putExtra(BluetoothDevice.EXTRA_CONNECTION_ACCESS_RESULT, BluetoothDevice.CONNECTION_ACCESS_NO); diff --git a/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java index bd8169a80fe..af9a29587a2 100644 --- a/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java +++ b/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceController.java @@ -47,10 +47,10 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends try { Resources res = context.getPackageManager().getResourcesForApplication( - "com.android.bluetooth"); + "com.android.bluetooth.services"); mDefaultMaxConnectedAudioDevices = res.getInteger(res.getIdentifier( "config_bluetooth_max_connected_audio_devices", - "integer", "com.android.bluetooth")); + "integer", "com.android.bluetooth.services")); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } diff --git a/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java index 72477b94585..53494ab5d23 100644 --- a/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/BluetoothMaxConnectedAudioDevicesPreferenceControllerTest.java @@ -70,8 +70,8 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceControllerTest { mPreference.setEntryValues(R.array.bluetooth_max_connected_audio_devices_values); // Retrieve default max connected audio devices to a test controlled value try { - Resources res = mSpyContext.getPackageManager().getResourcesForApplication("com.android.bluetooth"); - TEST_MAX_CONNECTED_AUDIO_DEVICES = res.getInteger(res.getIdentifier("config_bluetooth_max_connected_audio_devices", "integer", "com.android.bluetooth")); + Resources res = mSpyContext.getPackageManager().getResourcesForApplication("com.android.bluetooth.services"); + TEST_MAX_CONNECTED_AUDIO_DEVICES = res.getInteger(res.getIdentifier("config_bluetooth_max_connected_audio_devices", "integer", "com.android.bluetooth.services")); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } From 34704f4108d8a4a29e031bdacd7ed1c6f02f5870 Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Thu, 24 Mar 2022 00:39:20 +0000 Subject: [PATCH 09/14] Set exported flag to false. It was set to true when the attribute became required in I878adb9108c95f06ddd059b23a542b61210edfa4 Bug: 222684510 Test: manual (see bug) Change-Id: I8f67a5c3ac92f4813dc503cada8888833d7dbfbf --- AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c84132fd437..cbb4e752f96 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2236,7 +2236,7 @@ From 5290a8040c857897a832e937f494595e2e2d971b Mon Sep 17 00:00:00 2001 From: Kevin Han Date: Thu, 24 Mar 2022 13:52:28 -0700 Subject: [PATCH 10/14] Update category title for unused apps Forgot to update "Unused apps" category title to "Unused app settings" in previous CL so do that here. Bug: 201759939 Test: manual Change-Id: I67b9668f8b9caae9f144afce0e3e6d201d9b8f41 --- res/xml/app_info_settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml index 95fefb63a12..0726c208e09 100644 --- a/res/xml/app_info_settings.xml +++ b/res/xml/app_info_settings.xml @@ -141,7 +141,7 @@ From 8cf82f41d5628867882b24fc51a7360b9a8d102d Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Thu, 24 Mar 2022 16:17:23 -0700 Subject: [PATCH 11/14] Increase WifiEntryPreference summary max lines for verbose logging If Wifi verbose logging is on, increase the max lines for WifiEntryPreference's summary to 100 in order to fit the extra verbose logging information. Bug: 222337006 Test: manually build and verify verbose summary fits Change-Id: I919ae1bcfb26ea8c2548ebdcd3387c90e1d17ea9 --- src/com/android/settings/wifi/WifiEntryPreference.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/com/android/settings/wifi/WifiEntryPreference.java b/src/com/android/settings/wifi/WifiEntryPreference.java index a9b307c8e51..e74f269ae8d 100644 --- a/src/com/android/settings/wifi/WifiEntryPreference.java +++ b/src/com/android/settings/wifi/WifiEntryPreference.java @@ -25,6 +25,7 @@ import android.text.TextUtils; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; +import android.widget.TextView; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; @@ -35,6 +36,7 @@ import androidx.preference.PreferenceViewHolder; import com.android.settingslib.R; import com.android.settingslib.Utils; import com.android.settingslib.wifi.WifiUtils; +import com.android.wifitrackerlib.BaseWifiTracker; import com.android.wifitrackerlib.WifiEntry; /** @@ -94,6 +96,12 @@ public class WifiEntryPreference extends Preference implements WifiEntry.WifiEnt @Override public void onBindViewHolder(final PreferenceViewHolder view) { super.onBindViewHolder(view); + if (BaseWifiTracker.isVerboseLoggingEnabled()) { + TextView summary = (TextView) view.findViewById(android.R.id.summary); + if (summary != null) { + summary.setMaxLines(100); + } + } final Drawable drawable = getIcon(); if (drawable != null) { drawable.setLevel(mLevel); From 9ecda98adacbed1af8257922bfd607107c0b3769 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Tue, 29 Jun 2021 15:08:00 -0700 Subject: [PATCH 12/14] Add a cancel string for ToggleSubscriptionDialog to handle Tamil translation Bug: 185553806 Test: Build Change-Id: I90149c9e4459747d8cd1c35d00c29f81710eb6f4 Merged-In: I90149c9e4459747d8cd1c35d00c29f81710eb6f4 Merged-In: Id7f6042e0f7c70a3a8ca951fb80bb7f30acedcb9 --- res/values/strings.xml | 2 ++ .../telephony/ToggleSubscriptionDialogActivity.java | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index fce8a2ff067..ecd83016bd7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12779,6 +12779,8 @@ Restart No thanks + + Cancel Switch diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java index 65d8cd7eaed..65735d96df1 100644 --- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java +++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java @@ -338,7 +338,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getString(R.string.sim_action_restart_title), getString(R.string.sim_action_enable_dsds_text), getString(R.string.sim_action_reboot), - getString(R.string.cancel)); + getString(R.string.sim_action_cancel)); } /* Displays the SIM toggling confirmation dialog. */ @@ -359,7 +359,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc title, null, getString(R.string.yes), - getString(R.string.cancel)); + getString(R.string.sim_action_cancel)); } private void showEnableSimConfirmDialog() { @@ -384,7 +384,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getSwitchSubscriptionTitle(), getSwitchDialogBodyMsg(activeSub, isBetweenEsim), getSwitchDialogPosBtnText(), - getString(android.R.string.cancel)); + getString(R.string.sim_action_cancel)); } private void showNonSwitchSimConfirmDialog() { @@ -395,7 +395,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getEnableSubscriptionTitle(), null /* msg */, getString(R.string.yes), - getString(android.R.string.cancel)); + getString(R.string.sim_action_cancel)); } private String getSwitchDialogPosBtnText() { From 0f77d567b46d5046693cf6b094afa8cd71bca272 Mon Sep 17 00:00:00 2001 From: SongFerng Wang Date: Fri, 25 Mar 2022 14:03:29 +0000 Subject: [PATCH 13/14] Revert "Add a cancel string for ToggleSubscriptionDialog to handle Tamil" This reverts commit 9ecda98adacbed1af8257922bfd607107c0b3769. Reason for revert: It should not add"Merged-In: Id7f6042e0f7c70a3a8ca951fb80bb7f30acedcb9", so do revert and CP it again. Change-Id: I6c62e2a02e62f16c45771daee5040753ab14a4b8 --- res/values/strings.xml | 2 -- .../telephony/ToggleSubscriptionDialogActivity.java | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index ecd83016bd7..fce8a2ff067 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12779,8 +12779,6 @@ Restart No thanks - - Cancel Switch diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java index 65735d96df1..65d8cd7eaed 100644 --- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java +++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java @@ -338,7 +338,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getString(R.string.sim_action_restart_title), getString(R.string.sim_action_enable_dsds_text), getString(R.string.sim_action_reboot), - getString(R.string.sim_action_cancel)); + getString(R.string.cancel)); } /* Displays the SIM toggling confirmation dialog. */ @@ -359,7 +359,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc title, null, getString(R.string.yes), - getString(R.string.sim_action_cancel)); + getString(R.string.cancel)); } private void showEnableSimConfirmDialog() { @@ -384,7 +384,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getSwitchSubscriptionTitle(), getSwitchDialogBodyMsg(activeSub, isBetweenEsim), getSwitchDialogPosBtnText(), - getString(R.string.sim_action_cancel)); + getString(android.R.string.cancel)); } private void showNonSwitchSimConfirmDialog() { @@ -395,7 +395,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getEnableSubscriptionTitle(), null /* msg */, getString(R.string.yes), - getString(R.string.sim_action_cancel)); + getString(android.R.string.cancel)); } private String getSwitchDialogPosBtnText() { From aa042c2d6c8195df20c65628c98bdd7f474c3c82 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Tue, 29 Jun 2021 15:08:00 -0700 Subject: [PATCH 14/14] Add a cancel string for the dialog to handle Tamil translation Bug: 185553806 Test: Build Merged-In: I90149c9e4459747d8cd1c35d00c29f81710eb6f4 Change-Id: Ie8e9d150bf7868b462176c5cb5ed65beb187cc0e --- res/values/strings.xml | 2 ++ .../telephony/ToggleSubscriptionDialogActivity.java | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index fce8a2ff067..ecd83016bd7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12779,6 +12779,8 @@ Restart No thanks + + Cancel Switch diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java index 65d8cd7eaed..65735d96df1 100644 --- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java +++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java @@ -338,7 +338,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getString(R.string.sim_action_restart_title), getString(R.string.sim_action_enable_dsds_text), getString(R.string.sim_action_reboot), - getString(R.string.cancel)); + getString(R.string.sim_action_cancel)); } /* Displays the SIM toggling confirmation dialog. */ @@ -359,7 +359,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc title, null, getString(R.string.yes), - getString(R.string.cancel)); + getString(R.string.sim_action_cancel)); } private void showEnableSimConfirmDialog() { @@ -384,7 +384,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getSwitchSubscriptionTitle(), getSwitchDialogBodyMsg(activeSub, isBetweenEsim), getSwitchDialogPosBtnText(), - getString(android.R.string.cancel)); + getString(R.string.sim_action_cancel)); } private void showNonSwitchSimConfirmDialog() { @@ -395,7 +395,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getEnableSubscriptionTitle(), null /* msg */, getString(R.string.yes), - getString(android.R.string.cancel)); + getString(R.string.sim_action_cancel)); } private String getSwitchDialogPosBtnText() {