From 1a83638592c343055d40ca5785d29a31f714d7f8 Mon Sep 17 00:00:00 2001 From: menghanli Date: Tue, 25 May 2021 15:34:55 +0800 Subject: [PATCH 01/20] Fix the link text "Learn more" in the accessibility pages with help links could not convey the link's purpose clearly Root cause: A long content textview shows the accessibility service info and learn more link. User cannot double click to open help link. They need to swipe up and right to pops up dialog to move to next page. But, the dialog show the "Learn more", it is not clear for user to idendify what the link page. Solution: Add another textview to show the "Learn more" and provides more clear content description for this link. Also, user just need to double click to activate it. Bug: 188603037 Test: make RunSettingsRoboTests -j52 ROBOTEST_FILTER=AccessibilityFooterPreferenceTest Change-Id: Ia9a56f11bbd235ae3a698fcb2e1a2fcff64ef940 --- res/values/strings.xml | 4 +- .../AccessibilityFooterPreference.java | 58 +--------------- ...cessibilityFooterPreferenceController.java | 23 +++++-- .../ToggleFeaturePreferenceFragment.java | 41 +++++++++-- ...yButtonFooterPreferenceControllerTest.java | 67 ------------------ ...TimeoutFooterPreferenceControllerTest.java | 69 ------------------- .../AccessibilityFooterPreferenceTest.java | 50 ++++---------- ...CaptionFooterPreferenceControllerTest.java | 67 ------------------ ...toclickFooterPreferenceControllerTest.java | 68 ------------------ .../ToggleFeaturePreferenceFragmentTest.java | 2 - 10 files changed, 70 insertions(+), 379 deletions(-) delete mode 100644 tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java delete mode 100644 tests/robotests/src/com/android/settings/accessibility/AccessibilityControlTimeoutFooterPreferenceControllerTest.java delete mode 100644 tests/robotests/src/com/android/settings/accessibility/CaptionFooterPreferenceControllerTest.java delete mode 100644 tests/robotests/src/com/android/settings/accessibility/ToggleAutoclickFooterPreferenceControllerTest.java diff --git a/res/values/strings.xml b/res/values/strings.xml index 0b4b7057fd5..4df054df23e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5335,8 +5335,8 @@ Swipe up from the bottom of the screen with 3 fingers.\n\nTo switch between features, swipe up with 3 fingers and hold. Customize accessibility button - - Learn more + + Learn more about %1$s Hold volume keys diff --git a/src/com/android/settings/accessibility/AccessibilityFooterPreference.java b/src/com/android/settings/accessibility/AccessibilityFooterPreference.java index d68538e38cb..67b78273e3b 100644 --- a/src/com/android/settings/accessibility/AccessibilityFooterPreference.java +++ b/src/com/android/settings/accessibility/AccessibilityFooterPreference.java @@ -17,29 +17,19 @@ package com.android.settings.accessibility; import android.content.Context; -import android.content.Intent; -import android.text.SpannableStringBuilder; -import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.AttributeSet; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.preference.PreferenceViewHolder; -import com.android.settings.R; -import com.android.settings.utils.AnnotationSpan; -import com.android.settingslib.HelpUtils; import com.android.settingslib.widget.FooterPreference; /** - * A custom preference acting as footer of a page. It has a field for icon and text. It is added - * to screen as the last preference and groups of icon and text content in accessibility-focusable - * {@link android.view.accessibility.AccessibilityNodeInfo} for TalkBack to use. + * A custom preference acting as footer of a page. Disables the movement method by default. */ public final class AccessibilityFooterPreference extends FooterPreference { - private CharSequence mIconContentDescription; private boolean mLinkEnabled; public AccessibilityFooterPreference(Context context, AttributeSet attrs) { @@ -65,33 +55,6 @@ public final class AccessibilityFooterPreference extends FooterPreference { } else { title.setMovementMethod(/* movement= */ null); } - - final LinearLayout infoFrame = holder.itemView.findViewById(R.id.icon_frame); - if (!TextUtils.isEmpty(mIconContentDescription)) { - // Groups related content. - infoFrame.setContentDescription(mIconContentDescription); - title.setFocusable(false); - } else { - infoFrame.setContentDescription(null); - title.setFocusable(true); - } - } - - /** - * Sets the content description of the icon. - */ - public void setIconContentDescription(CharSequence iconContentDescription) { - if (!TextUtils.equals(iconContentDescription, mIconContentDescription)) { - mIconContentDescription = iconContentDescription; - notifyChanged(); - } - } - - /** - * Gets the content description of the icon. - */ - public CharSequence getIconContentDescription() { - return mIconContentDescription; } /** @@ -110,23 +73,4 @@ public final class AccessibilityFooterPreference extends FooterPreference { public boolean isLinkEnabled() { return mLinkEnabled; } - - /** - * Appends {@link AnnotationSpan} with learn more link apart from the other text. - * - * @param helpLinkRes The Help Uri Resource key - */ - public void appendHelpLink(int helpLinkRes) { - final SpannableStringBuilder sb = new SpannableStringBuilder(); - sb.append(getTitle()).append("\n\n").append(getLearnMoreLink(getContext(), helpLinkRes)); - setTitle(sb); - } - - private CharSequence getLearnMoreLink(Context context, int helpLinkRes) { - final Intent helpIntent = HelpUtils.getHelpIntent( - context, context.getString(helpLinkRes), context.getClass().getName()); - final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo( - context, AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, helpIntent); - return AnnotationSpan.linkify(context.getText(R.string.footer_learn_more), linkInfo); - } } diff --git a/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java index 9fe4b3ab804..e3422e43fbd 100644 --- a/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java +++ b/src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java @@ -17,11 +17,13 @@ package com.android.settings.accessibility; import android.content.Context; +import android.content.Intent; import androidx.preference.PreferenceScreen; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; +import com.android.settingslib.HelpUtils; /** * Base class for accessibility preference footer. @@ -59,13 +61,24 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer protected abstract String getLabelName(); private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) { - final String iconContentDescription = mContext.getString( - R.string.accessibility_introduction_title, getLabelName()); - footerPreference.setIconContentDescription(iconContentDescription); + final StringBuffer sb = new StringBuffer(); + sb.append(mContext.getString( + R.string.accessibility_introduction_title, getLabelName())) + .append("\n\n") + .append(footerPreference.getTitle()); + footerPreference.setContentDescription(sb); if (getHelpResource() != 0) { - footerPreference.appendHelpLink(getHelpResource()); - footerPreference.setLinkEnabled(true); + footerPreference.setLearnMoreAction(view -> { + final Intent helpIntent = HelpUtils.getHelpIntent( + mContext, mContext.getString(getHelpResource()), + mContext.getClass().getName()); + view.startActivityForResult(helpIntent, 0); + }); + + final String learnMoreContentDescription = mContext.getString( + R.string.footer_learn_more_content_description, getLabelName()); + footerPreference.setLearnMoreContentDescription(learnMoreContentDescription); } } } diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index 4b1725ffe63..7c189436b60 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -55,6 +55,7 @@ import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType; import com.android.settings.utils.LocaleUtils; import com.android.settings.widget.SettingsMainSwitchBar; import com.android.settings.widget.SettingsMainSwitchPreference; +import com.android.settingslib.HelpUtils; import com.android.settingslib.accessibility.AccessibilityUtils; import com.android.settingslib.widget.OnMainSwitchChangeListener; @@ -520,14 +521,25 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference new AccessibilityFooterPreference(screen.getContext()); htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE); htmlFooterPreference.setSummary(htmlDescription); + htmlFooterPreference.setContentDescription( + generateFooterContentDescription(htmlDescription)); + // Only framework tools support help link if (getHelpResource() != 0) { - htmlFooterPreference.appendHelpLink(getHelpResource()); + htmlFooterPreference.setLearnMoreAction(view -> { + final Intent helpIntent = HelpUtils.getHelpIntent( + getContext(), getContext().getString(getHelpResource()), + getContext().getClass().getName()); + view.startActivityForResult(helpIntent, 0); + }); + + final String learnMoreContentDescription = getPrefContext().getString( + R.string.footer_learn_more_content_description, mPackageName); + htmlFooterPreference.setLearnMoreContentDescription(learnMoreContentDescription); htmlFooterPreference.setLinkEnabled(true); } else { htmlFooterPreference.setLinkEnabled(false); } - htmlFooterPreference.setIconContentDescription(iconContentDescription); screen.addPreference(htmlFooterPreference); } @@ -559,14 +571,33 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference final AccessibilityFooterPreference footerPreference = new AccessibilityFooterPreference(screen.getContext()); footerPreference.setSummary(summary); - footerPreference.setIconContentDescription(iconContentDescription); + footerPreference.setContentDescription( + generateFooterContentDescription(summary)); + + // Only framework tools support help link if (getHelpResource() != 0) { - footerPreference.appendHelpLink(getHelpResource()); - footerPreference.setLinkEnabled(true); + footerPreference.setLearnMoreAction(view -> { + final Intent helpIntent = HelpUtils.getHelpIntent( + getContext(), getContext().getString(getHelpResource()), + getContext().getClass().getName()); + view.startActivityForResult(helpIntent, 0); + }); + + final String learnMoreContentDescription = getPrefContext().getString( + R.string.footer_learn_more_content_description, mPackageName); + footerPreference.setLearnMoreContentDescription(learnMoreContentDescription); } screen.addPreference(footerPreference); } + private CharSequence generateFooterContentDescription(CharSequence footerContent) { + final StringBuffer sb = new StringBuffer(); + sb.append(getPrefContext().getString( + R.string.accessibility_introduction_title, mPackageName)) + .append("\n\n") + .append(footerContent); + return sb; + } @VisibleForTesting void setupEditShortcutDialog(Dialog dialog) { final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut); diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java deleted file mode 100644 index 2640c813810..00000000000 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFooterPreferenceControllerTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2021 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.accessibility; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; - -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceScreen; -import androidx.test.core.app.ApplicationProvider; - -import com.android.settings.R; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; - -/** Tests for {@link AccessibilityButtonFooterPreferenceController}. */ -@RunWith(RobolectricTestRunner.class) -public class AccessibilityButtonFooterPreferenceControllerTest { - - private static final String TEST_KEY = "test_key"; - private static final String TEST_TITLE = "test_title"; - private final Context mContext = ApplicationProvider.getApplicationContext(); - private PreferenceScreen mScreen; - private AccessibilityButtonFooterPreferenceController mController; - - @Before - public void setUp() { - final PreferenceManager preferenceManager = new PreferenceManager(mContext); - mScreen = preferenceManager.createPreferenceScreen(mContext); - final AccessibilityFooterPreference footerPreference = - new AccessibilityFooterPreference(mContext); - footerPreference.setKey(TEST_KEY); - footerPreference.setTitle(TEST_TITLE); - mScreen.addPreference(footerPreference); - mController = new AccessibilityButtonFooterPreferenceController(mContext, TEST_KEY); - } - - @Test - public void onPreferenceChange_shouldSetCorrectIconContentDescription() { - mController.displayPreference(mScreen); - - final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY); - final String packageName = mContext.getString(R.string.accessibility_button_title); - final String iconContentDescription = mContext.getString( - R.string.accessibility_introduction_title, - packageName); - assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription); - } -} diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityControlTimeoutFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityControlTimeoutFooterPreferenceControllerTest.java deleted file mode 100644 index 23e479be539..00000000000 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityControlTimeoutFooterPreferenceControllerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2021 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.accessibility; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; - -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceScreen; -import androidx.test.core.app.ApplicationProvider; - -import com.android.settings.R; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; - -/** Tests for {@link AccessibilityControlTimeoutFooterPreferenceController}. */ -@RunWith(RobolectricTestRunner.class) -public class AccessibilityControlTimeoutFooterPreferenceControllerTest { - - private static final String TEST_KEY = "test_key"; - private static final String TEST_TITLE = "test_title"; - private final Context mContext = ApplicationProvider.getApplicationContext(); - private PreferenceScreen mScreen; - private AccessibilityControlTimeoutFooterPreferenceController mController; - - @Before - public void setUp() { - final PreferenceManager preferenceManager = new PreferenceManager(mContext); - mScreen = preferenceManager.createPreferenceScreen(mContext); - final AccessibilityFooterPreference footerPreference = - new AccessibilityFooterPreference(mContext); - footerPreference.setKey(TEST_KEY); - footerPreference.setTitle(TEST_TITLE); - mScreen.addPreference(footerPreference); - mController = new AccessibilityControlTimeoutFooterPreferenceController(mContext, TEST_KEY); - } - - @Test - public void onPreferenceChange_shouldSetCorrectIconContentDescription() { - mController.displayPreference(mScreen); - - final AccessibilityFooterPreference footerPreference = - mScreen.findPreference(TEST_KEY); - final String packageName = - mContext.getString(R.string.accessibility_setting_item_control_timeout_title); - final String iconContentDescription = mContext.getString( - R.string.accessibility_introduction_title, - packageName); - assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription); - } -} diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java index b8f97c7a3ea..14c56e84726 100644 --- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java @@ -19,13 +19,12 @@ package com.android.settings.accessibility; import static com.google.common.truth.Truth.assertThat; import android.content.Context; +import android.text.method.MovementMethod; import android.view.LayoutInflater; import android.view.View; -import android.widget.LinearLayout; import android.widget.TextView; import androidx.preference.PreferenceViewHolder; -import androidx.test.core.app.ApplicationProvider; import com.android.settings.R; @@ -39,10 +38,6 @@ import org.robolectric.RuntimeEnvironment; @RunWith(RobolectricTestRunner.class) public final class AccessibilityFooterPreferenceTest { - private static final String DEFAULT_SUMMARY = "default summary"; - private static final String DEFAULT_DESCRIPTION = "default description"; - - private Context mContext = ApplicationProvider.getApplicationContext(); private AccessibilityFooterPreference mAccessibilityFooterPreference; private PreferenceViewHolder mPreferenceViewHolder; @@ -58,41 +53,22 @@ public final class AccessibilityFooterPreferenceTest { } @Test - public void onBindViewHolder_initTextConfig_parseTextAndFocusable() { - mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY); + public void onBindViewHolder_LinkDisabledByDefault_notReturnLinkMovement() { + mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder); + + final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById( + android.R.id.title); + assertThat(summaryView.getMovementMethod()).isNull(); + } + + @Test + public void onBindViewHolder_setLinkEnabled_returnLinkMovement() { + mAccessibilityFooterPreference.setLinkEnabled(true); mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder); final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById( android.R.id.title); - assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY); - assertThat(summaryView.isFocusable()).isEqualTo(true); - } - - @Test - public void onBindViewHolder_initTextConfigAndAccessibleIcon_groupContentForAccessible() { - mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY); - mAccessibilityFooterPreference.setIconContentDescription(DEFAULT_DESCRIPTION); - - mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder); - - final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById( - android.R.id.title); - assertThat(summaryView.getText().toString()).isEqualTo(DEFAULT_SUMMARY); - assertThat(summaryView.isFocusable()).isEqualTo(false); - final LinearLayout infoFrame = (LinearLayout) mPreferenceViewHolder.findViewById( - R.id.icon_frame); - assertThat(infoFrame.getContentDescription()).isEqualTo(DEFAULT_DESCRIPTION); - assertThat(infoFrame.isFocusable()).isEqualTo(false); - } - - @Test - public void appendHelpLink_timeoutHelpUri_updateSummary() { - mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY); - - mAccessibilityFooterPreference.appendHelpLink(R.string.help_url_timeout); - - final String title = mAccessibilityFooterPreference.getTitle().toString(); - assertThat(title.contains(mContext.getString(R.string.footer_learn_more))).isTrue(); + assertThat(summaryView.getMovementMethod()).isInstanceOf(MovementMethod.class); } } diff --git a/tests/robotests/src/com/android/settings/accessibility/CaptionFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/CaptionFooterPreferenceControllerTest.java deleted file mode 100644 index e5f67c5f308..00000000000 --- a/tests/robotests/src/com/android/settings/accessibility/CaptionFooterPreferenceControllerTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2021 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.accessibility; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; - -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceScreen; -import androidx.test.core.app.ApplicationProvider; - -import com.android.settings.R; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; - -/** Tests for {@link CaptionFooterPreferenceController}. */ -@RunWith(RobolectricTestRunner.class) -public class CaptionFooterPreferenceControllerTest { - - private static final String TEST_KEY = "test_key"; - private static final String TEST_TITLE = "test_title"; - private final Context mContext = ApplicationProvider.getApplicationContext(); - private PreferenceScreen mScreen; - private CaptionFooterPreferenceController mController; - - @Before - public void setUp() { - final PreferenceManager preferenceManager = new PreferenceManager(mContext); - mScreen = preferenceManager.createPreferenceScreen(mContext); - final AccessibilityFooterPreference footerPreference = - new AccessibilityFooterPreference(mContext); - footerPreference.setKey(TEST_KEY); - footerPreference.setTitle(TEST_TITLE); - mScreen.addPreference(footerPreference); - mController = new CaptionFooterPreferenceController(mContext, TEST_KEY); - } - - @Test - public void onPreferenceChange_shouldSetCorrectIconContentDescription() { - mController.displayPreference(mScreen); - - final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY); - final String packageName = mContext.getString(R.string.accessibility_captioning_title); - final String iconContentDescription = mContext.getString( - R.string.accessibility_introduction_title, - packageName); - assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription); - } -} diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleAutoclickFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleAutoclickFooterPreferenceControllerTest.java deleted file mode 100644 index 2be4752b4f5..00000000000 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleAutoclickFooterPreferenceControllerTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2021 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.accessibility; - -import static com.google.common.truth.Truth.assertThat; - -import android.content.Context; - -import androidx.preference.PreferenceManager; -import androidx.preference.PreferenceScreen; -import androidx.test.core.app.ApplicationProvider; - -import com.android.settings.R; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; - -/** Tests for {@link ToggleAutoclickFooterPreferenceController}. */ -@RunWith(RobolectricTestRunner.class) -public class ToggleAutoclickFooterPreferenceControllerTest { - - private static final String TEST_KEY = "test_key"; - private static final String TEST_TITLE = "test_title"; - private final Context mContext = ApplicationProvider.getApplicationContext(); - private PreferenceScreen mScreen; - private ToggleAutoclickFooterPreferenceController mController; - - @Before - public void setUp() { - final PreferenceManager preferenceManager = new PreferenceManager(mContext); - mScreen = preferenceManager.createPreferenceScreen(mContext); - final AccessibilityFooterPreference footerPreference = - new AccessibilityFooterPreference(mContext); - footerPreference.setKey(TEST_KEY); - footerPreference.setTitle(TEST_TITLE); - mScreen.addPreference(footerPreference); - mController = new ToggleAutoclickFooterPreferenceController(mContext, TEST_KEY); - } - - @Test - public void onPreferenceChange_shouldSetCorrectIconContentDescription() { - mController.displayPreference(mScreen); - - final AccessibilityFooterPreference footerPreference = mScreen.findPreference(TEST_KEY); - final String packageName = mContext.getString( - R.string.accessibility_autoclick_preference_title); - final String iconContentDescription = mContext.getString( - R.string.accessibility_introduction_title, - packageName); - assertThat(footerPreference.getIconContentDescription()).isEqualTo(iconContentDescription); - } -} diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java index 01e9b38440d..4f4185cb81c 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java @@ -215,8 +215,6 @@ public class ToggleFeaturePreferenceFragmentTest { (AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference( mFragment.getPreferenceScreen().getPreferenceCount() - 1); assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY); - assertThat(accessibilityFooterPreference.getIconContentDescription()).isEqualTo( - DEFAULT_DESCRIPTION); assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true); assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1); } From 2377927d51db6eadb8da2140d980330357c1dc36 Mon Sep 17 00:00:00 2001 From: Mill Chen Date: Thu, 27 May 2021 20:01:57 +0800 Subject: [PATCH 02/20] Remove the face unlock category Fix: 189232241 Test: visual verified Change-Id: Ic100a46eefd7d768b5e73f18d8e4e94823b8a52e --- res/xml/security_settings_face.xml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml index 229c9df78a4..6d7c0ba8d4b 100644 --- a/res/xml/security_settings_face.xml +++ b/res/xml/security_settings_face.xml @@ -70,21 +70,17 @@ settings:controller="com.android.settings.biometrics.face.FaceSettingsLockscreenBypassPreferenceController" /> - - + - - + Date: Mon, 24 May 2021 19:06:53 -0700 Subject: [PATCH 03/20] Further refactoring on ActionDisabledByAdminDialog classes. Bug: 184107103 Bug: 188836559 Test: m -j RunSettingsRoboTests ROBOTEST_FILTER=ActionDisabledByAdminDialogHelperTest Test: atest ActionDisabledLearnMoreButtonLauncherImplTest Test: adb shell am start -e android.app.extra.RESTRICTION no_install_unknown-sources -a android.settings.SHOW_ADMIN_SUPPORT_DETAILS Test: manual verification with CtsVerifier Change-Id: I3c4056d82834b5e2a4afbd958be7c9d0b9af543e --- .../ActionDisabledByAdminDialogHelper.java | 55 ++++----- ...onDisabledLearnMoreButtonLauncherImpl.java | 111 ++++++------------ ...ActionDisabledByAdminDialogHelperTest.java | 13 +- ...sabledLearnMoreButtonLauncherImplTest.java | 98 +++++++++------- 4 files changed, 126 insertions(+), 151 deletions(-) diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java index 2a5eda217a6..b6ffc5f719c 100644 --- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java +++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java @@ -45,30 +45,25 @@ import java.util.Objects; /** * Helper class for {@link ActionDisabledByAdminDialog} which sets up the dialog. */ -public class ActionDisabledByAdminDialogHelper { +public final class ActionDisabledByAdminDialogHelper { private static final String TAG = ActionDisabledByAdminDialogHelper.class.getName(); @VisibleForTesting EnforcedAdmin mEnforcedAdmin; private ViewGroup mDialogView; - private String mRestriction = null; - private final Activity mActivity; + private String mRestriction; private final ActionDisabledByAdminController mActionDisabledByAdminController; + private final Activity mActivity; public ActionDisabledByAdminDialogHelper(Activity activity) { mActivity = activity; - mActionDisabledByAdminController = - ActionDisabledByAdminControllerFactory.createInstance( - mActivity.getSystemService(DevicePolicyManager.class), - new ActionDisabledLearnMoreButtonLauncherImpl(), - new DeviceAdminStringProviderImpl(mActivity)); + mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate( + R.layout.admin_support_details_dialog, null); + mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory + .createInstance(mActivity, new DeviceAdminStringProviderImpl(mActivity)); } private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) { - if (admin.user == null) { - return UserHandle.USER_NULL; - } else { - return admin.user.getIdentifier(); - } + return admin.user == null ? UserHandle.USER_NULL : admin.user.getIdentifier(); } private @UserIdInt int getEnforcementAdminUserId() { @@ -77,21 +72,24 @@ public class ActionDisabledByAdminDialogHelper { public AlertDialog.Builder prepareDialogBuilder(String restriction, EnforcedAdmin enforcedAdmin) { - mEnforcedAdmin = enforcedAdmin; - mRestriction = restriction; - final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); - mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate( - R.layout.admin_support_details_dialog, null); - initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(), - mRestriction, mActionDisabledByAdminController); - builder.setPositiveButton(R.string.okay, null).setView(mDialogView); - maybeSetLearnMoreButton(builder); + AlertDialog.Builder builder = new AlertDialog.Builder(mActivity) + .setPositiveButton(R.string.okay, null) + .setView(mDialogView); + prepareDialogBuilder(builder, restriction, enforcedAdmin); return builder; } @VisibleForTesting - void maybeSetLearnMoreButton(AlertDialog.Builder builder) { - mActionDisabledByAdminController.setupLearnMoreButton(mActivity, builder); + void prepareDialogBuilder(AlertDialog.Builder builder, String restriction, + EnforcedAdmin enforcedAdmin) { + mActionDisabledByAdminController.initialize( + new ActionDisabledLearnMoreButtonLauncherImpl(mActivity, builder)); + + mEnforcedAdmin = enforcedAdmin; + mRestriction = restriction; + initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(), + mRestriction); + mActionDisabledByAdminController.setupLearnMoreButton(mActivity); } public void updateDialog(String restriction, EnforcedAdmin admin) { @@ -101,17 +99,17 @@ public class ActionDisabledByAdminDialogHelper { mEnforcedAdmin = admin; mRestriction = restriction; initializeDialogViews(mDialogView, mEnforcedAdmin, getEnforcementAdminUserId(), - mRestriction, mActionDisabledByAdminController); + mRestriction); } private void initializeDialogViews(View root, EnforcedAdmin enforcedAdmin, int userId, - String restriction, ActionDisabledByAdminController controller) { + String restriction) { ComponentName admin = enforcedAdmin.component; if (admin == null) { return; } - controller.updateEnforcedAdmin(enforcedAdmin, userId); + mActionDisabledByAdminController.updateEnforcedAdmin(enforcedAdmin, userId); setAdminSupportIcon(root, admin, userId); if (isNotCurrentUserOrProfile(admin, userId)) { @@ -148,8 +146,7 @@ public class ActionDisabledByAdminDialogHelper { if (titleView == null) { return; } - titleView.setText( - mActionDisabledByAdminController.getAdminSupportTitle(restriction)); + titleView.setText(mActionDisabledByAdminController.getAdminSupportTitle(restriction)); } @VisibleForTesting diff --git a/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImpl.java b/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImpl.java index 98cad65b5d8..09337993d86 100644 --- a/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImpl.java +++ b/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImpl.java @@ -20,104 +20,67 @@ import static java.util.Objects.requireNonNull; import android.app.Activity; import android.app.admin.DevicePolicyManager; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; -import android.net.Uri; import android.os.UserHandle; -import android.os.UserManager; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; import com.android.settings.Settings; import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd; -import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import com.android.settingslib.enterprise.ActionDisabledLearnMoreButtonLauncher; -import java.util.function.BiConsumer; - /** * Helper class to set up the "Learn more" button in the action disabled dialog. */ -public class ActionDisabledLearnMoreButtonLauncherImpl - implements ActionDisabledLearnMoreButtonLauncher { +public final class ActionDisabledLearnMoreButtonLauncherImpl + extends ActionDisabledLearnMoreButtonLauncher { - static final BiConsumer SHOW_ADMIN_POLICIES = - (activity, enforcedAdmin) -> { - showAdminPolicies(enforcedAdmin, activity); - activity.finish(); - }; + private final Activity mActivity; + private final AlertDialog.Builder mBuilder; - static final BiConsumer LAUNCH_HELP_PAGE = (activity, url) -> { - launchLearnMoreHelpPage(activity, url); - activity.finish(); - }; - - @Override - public void setupLearnMoreButtonToShowAdminPolicies( - Context context, - Object alertDialogBuilder, - int enforcementAdminUserId, - EnforcedAdmin enforcedAdmin) { - requireNonNull(context); - requireNonNull(alertDialogBuilder); - requireNonNull(enforcedAdmin); - // The "Learn more" button appears only if the restriction is enforced by an admin in the - // same profile group. Otherwise the admin package and its policies are not accessible to - // the current user. - final UserManager um = UserManager.get(context); - if (um.isSameProfileGroup(enforcementAdminUserId, um.getUserHandle())) { - setupLearnMoreButton((AlertDialog.Builder) alertDialogBuilder, () -> - SHOW_ADMIN_POLICIES.accept((Activity) context, enforcedAdmin)); - } + ActionDisabledLearnMoreButtonLauncherImpl(Activity activity, AlertDialog.Builder builder) { + mActivity = requireNonNull(activity, "activity cannot be null"); + mBuilder = requireNonNull(builder, "builder cannot be null"); } @Override - public void setupLearnMoreButtonToLaunchHelpPage( - Context context, - Object alertDialogBuilder, - String url) { - requireNonNull(context); - requireNonNull(alertDialogBuilder); - requireNonNull(url); - setupLearnMoreButton((AlertDialog.Builder) alertDialogBuilder, - () -> LAUNCH_HELP_PAGE.accept((Activity) context, url)); + public void setLearnMoreButton(Runnable action) { + requireNonNull(action, "action cannot be null"); + + mBuilder.setNeutralButton(R.string.learn_more, (dialog, which) -> action.run()); } - private void setupLearnMoreButton(AlertDialog.Builder builder, Runnable runnable) { - builder.setNeutralButton(R.string.learn_more, (dialog, which) -> { - runnable.run(); - }); + @Override + protected void launchShowAdminPolicies(Context context, UserHandle user, ComponentName admin) { + requireNonNull(context, "context cannot be null"); + requireNonNull(user, "user cannot be null"); + requireNonNull(admin, "admin cannot be null"); + + Intent intent = new Intent() + .setClass(mActivity, DeviceAdminAdd.class) + .putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, admin) + .putExtra(DeviceAdminAdd.EXTRA_CALLED_FROM_SUPPORT_DIALOG, true); + // DeviceAdminAdd class may need to run as managed profile. + mActivity.startActivityAsUser(intent, user); } - private static void launchLearnMoreHelpPage(Activity activity, String url) { - activity.startActivityAsUser(createLearnMoreIntent(url), UserHandle.SYSTEM); + @Override + protected void launchShowAdminSettings(Context context) { + requireNonNull(context, "context cannot be null"); + + Intent intent = new Intent() + .setClass(mActivity, Settings.DeviceAdminSettingsActivity.class) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // Activity merges both managed profile and parent users + // admins so show as same user as this activity. + mActivity.startActivity(intent); } - private static Intent createLearnMoreIntent(String url) { - final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); - return intent; - } - - private static void showAdminPolicies( - EnforcedAdmin enforcedAdmin, - Activity activity) { - final Intent intent = new Intent(); - if (enforcedAdmin.component != null) { - intent.setClass(activity, DeviceAdminAdd.class); - intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, - enforcedAdmin.component); - intent.putExtra(DeviceAdminAdd.EXTRA_CALLED_FROM_SUPPORT_DIALOG, true); - // DeviceAdminAdd class may need to run as managed profile. - activity.startActivityAsUser(intent, enforcedAdmin.user); - } else { - intent.setClass(activity, Settings.DeviceAdminSettingsActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - // Activity merges both managed profile and parent users - // admins so show as same user as this activity. - activity.startActivity(intent); - } + @Override + protected void finishSelf() { + mActivity.finish(); } } diff --git a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java index 6acc72fcf79..908864166f8 100644 --- a/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java +++ b/tests/robotests/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelperTest.java @@ -200,24 +200,21 @@ public class ActionDisabledByAdminDialogHelperTest { @Test public void testMaybeSetLearnMoreButton() { - final UserManager userManager = RuntimeEnvironment.application.getSystemService( - UserManager.class); - final ShadowUserManager userManagerShadow = Shadow.extract(userManager); - mHelper.prepareDialogBuilder( - /* restriction= */ null, ENFORCED_ADMIN); - + UserManager userManager = RuntimeEnvironment.application + .getSystemService(UserManager.class); + ShadowUserManager userManagerShadow = Shadow.extract(userManager); // Set up for shadow call. userManagerShadow.getSameProfileGroupIds().put(USER_ID, 0); // Test that the button is shown when user IDs are in the same profile group AlertDialog.Builder builder = mock(AlertDialog.Builder.class); - mHelper.maybeSetLearnMoreButton(builder); + mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN); verify(builder).setNeutralButton(anyInt(), any()); // Test that the button is not shown when user IDs are not in the same profile group userManagerShadow.getSameProfileGroupIds().clear(); builder = mock(AlertDialog.Builder.class); - mHelper.maybeSetLearnMoreButton(builder); + mHelper.prepareDialogBuilder(builder, /* restriction= */ null, ENFORCED_ADMIN); verify(builder, never()).setNeutralButton(anyInt(), any()); } diff --git a/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java b/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java index 68468ed4162..4f7ecc8904e 100644 --- a/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java +++ b/tests/unit/src/com/android/settings/enterprise/ActionDisabledLearnMoreButtonLauncherImplTest.java @@ -24,86 +24,104 @@ import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import android.app.Activity; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.UserHandle; +import android.os.UserManager; +import androidx.appcompat.app.AlertDialog; import androidx.test.runner.AndroidJUnit4; import com.android.settings.Settings; import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd; -import com.android.settingslib.RestrictedLockUtils; -import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - +import org.mockito.junit.MockitoJUnit; +import org.mockito.junit.MockitoRule; @RunWith(AndroidJUnit4.class) public class ActionDisabledLearnMoreButtonLauncherImplTest { private static final int ENFORCED_ADMIN_USER_ID = 123; + private static final UserHandle ENFORCED_ADMIN_USER = UserHandle.of(ENFORCED_ADMIN_USER_ID); + + private static final int CONTEXT_USER_ID = -ENFORCED_ADMIN_USER_ID; + private static final UserHandle CONTEXT_USER = UserHandle.of(CONTEXT_USER_ID); + private static final ComponentName ADMIN_COMPONENT = new ComponentName("some.package.name", "some.package.name.SomeClass"); private static final String URL = "https://testexample.com"; private static final Uri URI = Uri.parse(URL); + @Rule + public final MockitoRule mMockitoRule = MockitoJUnit.rule(); + @Mock private Activity mActivity; + @Captor + private ArgumentCaptor mIntentCaptor; + + @Mock + private AlertDialog.Builder mBuilder; + + private ActionDisabledLearnMoreButtonLauncherImpl mImpl; + + @Mock + private UserManager mUserManager; + @Before public void setUp() { - MockitoAnnotations.initMocks(this); + // Can't mock getSystemService(Class) directly because it's final + when(mActivity.getSystemServiceName(UserManager.class)).thenReturn(Context.USER_SERVICE); + when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager); + + when(mActivity.getUserId()).thenReturn(CONTEXT_USER_ID); + when(mUserManager.getUserHandle()).thenReturn(CONTEXT_USER_ID); + + mImpl = new ActionDisabledLearnMoreButtonLauncherImpl(mActivity, mBuilder); } @Test - public void showAdminPolicies_noComponent_works() { - final EnforcedAdmin enforcedAdmin = createEnforcedAdmin(/* component= */ null); + public void launchShowAdminSettings_works() { + mImpl.launchShowAdminSettings(mActivity); - ActionDisabledLearnMoreButtonLauncherImpl.SHOW_ADMIN_POLICIES - .accept(mActivity, enforcedAdmin); + verify(mActivity).startActivity(mIntentCaptor.capture()); + assertDeviceAdminSettingsActivity(mIntentCaptor.getValue()); + } - final ArgumentCaptor captor = ArgumentCaptor.forClass(Intent.class); - verify(mActivity).startActivity(captor.capture()); - assertThat(captor.getValue().getComponent().getClassName()) + @Test + public void launchShowAdminPolicies_works() { + mImpl.launchShowAdminPolicies(mActivity, ENFORCED_ADMIN_USER, ADMIN_COMPONENT); + + verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(ENFORCED_ADMIN_USER)); + assertDeviceAdminAddIntent(mIntentCaptor.getValue()); + } + + @Test + public void showHelpPage_works() { + mImpl.showHelpPage(mActivity, URL); + + verify(mActivity).startActivityAsUser(mIntentCaptor.capture(), eq(CONTEXT_USER)); + assertActionViewIntent(mIntentCaptor.getValue()); + } + + private void assertDeviceAdminSettingsActivity(Intent intent) { + assertThat(intent.getComponent().getClassName()) .isEqualTo(Settings.DeviceAdminSettingsActivity.class.getName()); } - @Test - public void showAdminPolicies_withComponent_works() { - final EnforcedAdmin enforcedAdmin = createEnforcedAdmin(ADMIN_COMPONENT); - - ActionDisabledLearnMoreButtonLauncherImpl.SHOW_ADMIN_POLICIES - .accept(mActivity, enforcedAdmin); - - final ArgumentCaptor captor = ArgumentCaptor.forClass(Intent.class); - verify(mActivity).startActivityAsUser( - captor.capture(), - eq(UserHandle.of(ENFORCED_ADMIN_USER_ID))); - assertDeviceAdminAddIntent(captor.getValue()); - } - - @Test - public void launchHelpPage_works() { - ActionDisabledLearnMoreButtonLauncherImpl.LAUNCH_HELP_PAGE.accept(mActivity, URL); - - final ArgumentCaptor captor = ArgumentCaptor.forClass(Intent.class); - verify(mActivity).startActivityAsUser(captor.capture(), eq(UserHandle.SYSTEM)); - assertActionViewIntent(captor.getValue()); - } - - private EnforcedAdmin createEnforcedAdmin(ComponentName component) { - return new RestrictedLockUtils.EnforcedAdmin( - component, UserHandle.of(ENFORCED_ADMIN_USER_ID)); - } - private void assertDeviceAdminAddIntent(Intent intent) { assertThat(intent.getComponent().getClassName()) .isEqualTo(DeviceAdminAdd.class.getName()); From 2906b4b6752197a4e1dae52d789b0787f67bc2ba Mon Sep 17 00:00:00 2001 From: Abel Tesfaye Date: Tue, 11 May 2021 20:55:09 +0000 Subject: [PATCH 04/20] Update smart auto rotate string Bug: 187254875 Test: none Change-Id: I17de912713767af8391163e6053515bce10fa79a --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 9f869017b43..249282b5c5f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -103,7 +103,7 @@ Face Detection uses the front-facing camera to improve Auto-rotate accuracy. Images are never stored or sent to Google.<br><br> - <a href="http://support.google.com/mobile?p=telephony_rtt">Learn more</a> + <a href="http://support.google.com/mobile?p=telephony_rtt">Learn more about Auto-rotate screen</a> Sample text Date: Sat, 29 May 2021 20:27:38 +0800 Subject: [PATCH 05/20] SettingsMainSwitchPreference should display the restricted icon if it is restricted. - Use the RestrictedPreferenceHelper to check the restricted state. Fix: 179245126 Test: rebotest and see the UI Change-Id: I3c0e3bd0f3596d6fa548b6f8f10e4d12e7e50c9a --- res/xml/auto_brightness_detail.xml | 3 +- ...oBrightnessDetailPreferenceController.java | 4 +- .../widget/SettingsMainSwitchBar.java | 6 +- .../widget/SettingsMainSwitchPreference.java | 26 +++++--- .../SettingsMainSwitchPreferenceTest.java | 63 +++++++++++++++++++ 5 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java diff --git a/res/xml/auto_brightness_detail.xml b/res/xml/auto_brightness_detail.xml index d0bf3348666..a7c85e8759b 100644 --- a/res/xml/auto_brightness_detail.xml +++ b/res/xml/auto_brightness_detail.xml @@ -27,10 +27,11 @@ settings:preview="@drawable/aab_brightness" settings:controller="com.android.settings.widget.VideoPreferenceController"/> - mBeforeCheckedChangeListeners = new ArrayList<>(); private final List mSwitchChangeListeners = new ArrayList<>(); @@ -46,8 +51,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference { private SettingsMainSwitchBar mMainSwitchBar; private CharSequence mTitle; private boolean mIsVisible; - - private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin; + private EnforcedAdmin mEnforcedAdmin; + private RestrictedPreferenceHelper mRestrictedHelper; public SettingsMainSwitchPreference(Context context) { super(context); @@ -78,8 +83,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference { holder.setDividerAllowedBelow(false); mMainSwitchBar = (SettingsMainSwitchBar) holder.findViewById(R.id.main_switch_bar); - mMainSwitchBar.show(); + mEnforcedAdmin = mRestrictedHelper.checkRestrictionEnforced(); updateStatus(isChecked()); registerListenerToSwitchBar(); @@ -90,6 +95,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference { private void init(Context context, AttributeSet attrs) { setLayoutResource(R.layout.preference_widget_main_switch); + mSwitchChangeListeners.add(this); mIsVisible = true; if (attrs != null) { @@ -103,6 +109,8 @@ public class SettingsMainSwitchPreference extends TwoStatePreference { setTitle(title.toString()); } a.recycle(); + + mRestrictedHelper = new RestrictedPreferenceHelper(context, this, attrs); } } @@ -129,13 +137,17 @@ public class SettingsMainSwitchPreference extends TwoStatePreference { } } + @Override + public void onSwitchChanged(Switch switchView, boolean isChecked) { + super.setChecked(isChecked); + } + /** * Update the switch status of preference */ public void updateStatus(boolean checked) { setChecked(checked); if (mMainSwitchBar != null) { - mMainSwitchBar.setChecked(checked); mMainSwitchBar.setTitle(mTitle); mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin); mMainSwitchBar.show(); @@ -230,7 +242,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference { * Otherwise, calls setEnabled which will enables the entire view including * the text and switch. */ - public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) { + public void setDisabledByAdmin(EnforcedAdmin admin) { mEnforcedAdmin = admin; if (mMainSwitchBar != null) { mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin); diff --git a/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java new file mode 100644 index 00000000000..cb53805cc99 --- /dev/null +++ b/tests/robotests/src/com/android/settings/widget/SettingsMainSwitchPreferenceTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.widget; + +import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; +import android.view.View; +import android.widget.ImageView; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.util.ReflectionHelpers; + +@RunWith(RobolectricTestRunner.class) +public class SettingsMainSwitchPreferenceTest { + + @Mock + private EnforcedAdmin mEnforcedAdmin; + private SettingsMainSwitchPreference mPreference; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + final Context context = RuntimeEnvironment.application; + final SettingsMainSwitchBar switchBar = new SettingsMainSwitchBar(context); + mPreference = new SettingsMainSwitchPreference(context); + ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin); + ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar); + } + + @Test + public void updateStatus_isRestricted_restrictIconShouldDisplay() { + mPreference.updateStatus(true); + + final SettingsMainSwitchBar switchBar = mPreference.getSwitchBar(); + final ImageView restrictedIcon = switchBar.findViewById( + com.android.settingslib.widget.R.id.restricted_icon); + + assertThat(restrictedIcon.getVisibility() == View.VISIBLE).isTrue(); + } +} From e7c769fe0258b83206d682717dc4ee80a8fd2c77 Mon Sep 17 00:00:00 2001 From: Yi-Ling Chuang Date: Tue, 1 Jun 2021 16:39:13 +0800 Subject: [PATCH 06/20] Apply sliding transition to trust agent. - Also rename the extra of page transition. - Remove useless code while starting activity from fragment. Bug: 187542491 Test: robotest and manually went through trust agent flow. Change-Id: I55419f23db7fa77281039e642bde5558c17dce0f --- .../android/settings/core/SettingsBaseActivity.java | 2 +- .../android/settings/core/SubSettingLauncher.java | 13 ------------- .../TrustAgentListPreferenceController.java | 4 ++++ .../settings/core/SubSettingLauncherTest.java | 2 -- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/com/android/settings/core/SettingsBaseActivity.java b/src/com/android/settings/core/SettingsBaseActivity.java index c5d86e1cacd..fb9780f124c 100644 --- a/src/com/android/settings/core/SettingsBaseActivity.java +++ b/src/com/android/settings/core/SettingsBaseActivity.java @@ -67,7 +67,7 @@ public class SettingsBaseActivity extends FragmentActivity { /** * What type of page transition should be apply. */ - public static final String EXTRA_PAGE_TRANSITION_TYPE = "extra_page_transition_type"; + public static final String EXTRA_PAGE_TRANSITION_TYPE = "page_transition_type"; protected static final boolean DEBUG_TIMING = false; private static final String TAG = "SettingsBaseActivity"; diff --git a/src/com/android/settings/core/SubSettingLauncher.java b/src/com/android/settings/core/SubSettingLauncher.java index 2ee404b418c..893d592fe78 100644 --- a/src/com/android/settings/core/SubSettingLauncher.java +++ b/src/com/android/settings/core/SubSettingLauncher.java @@ -17,22 +17,17 @@ package com.android.settings.core; import android.annotation.StringRes; -import android.app.Activity; -import android.app.ActivityOptions; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.UserHandle; import android.text.TextUtils; -import android.widget.Toolbar; import androidx.annotation.VisibleForTesting; import androidx.fragment.app.Fragment; -import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.SubSettings; -import com.android.settings.Utils; import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType; @@ -199,14 +194,6 @@ public class SubSettingLauncher { @VisibleForTesting void launchForResult(Fragment listener, Intent intent, int requestCode) { - if (Utils.isPageTransitionEnabled(mContext)) { - final Activity activity = listener.getActivity(); - final Toolbar toolbar = activity.findViewById(R.id.action_bar); - final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity, toolbar, - "shared_element_view").toBundle(); - listener.startActivityForResult(intent, requestCode, bundle); - return; - } listener.startActivityForResult(intent, requestCode); } diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java index dd1d63ae339..4f235e18d85 100644 --- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java +++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java @@ -33,6 +33,7 @@ import com.android.internal.widget.LockPatternUtils; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.core.PreferenceControllerMixin; +import com.android.settings.core.SettingsBaseActivity; import com.android.settings.overlay.FeatureFactory; import com.android.settings.password.ChooseLockSettingsHelper; import com.android.settings.security.SecurityFeatureProvider; @@ -44,6 +45,7 @@ import com.android.settingslib.core.lifecycle.events.OnCreate; import com.android.settingslib.core.lifecycle.events.OnResume; import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState; import com.android.settingslib.search.SearchIndexableRaw; +import com.android.settingslib.transition.SettingsTransitionHelper; import java.util.ArrayList; import java.util.List; @@ -128,6 +130,8 @@ public class TrustAgentListPreferenceController extends AbstractPreferenceContro .show(); mTrustAgentClickIntent = preference.getIntent(); + mTrustAgentClickIntent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE, + SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE); if (!confirmationLaunched && mTrustAgentClickIntent != null) { // If this returns false, it means no password confirmation is required. diff --git a/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java b/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java index a74c01e9737..2a0d3df95cc 100644 --- a/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java +++ b/tests/robotests/src/com/android/settings/core/SubSettingLauncherTest.java @@ -50,7 +50,6 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; @RunWith(RobolectricTestRunner.class) -@Config(shadows = ShadowUtils.class) public class SubSettingLauncherTest { @Mock @@ -117,7 +116,6 @@ public class SubSettingLauncherTest { @Test public void launch_hasRequestListener_shouldStartActivityForResult() { - ShadowUtils.setIsPageTransitionEnabled(true); final int requestCode = 123123; when(mFragment.getActivity()).thenReturn(mActivity); From 833462baa3de791cd831b58cc7340ceef92cb929 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Tue, 1 Jun 2021 18:20:38 +0800 Subject: [PATCH 07/20] Remove all dividers in privacy page Based on ux rules, remove the dividers for Android S. Test: See the screen Fix: 183174009 Change-Id: I7850c37387ccc18964f2c491ec696307f3ad9d4e --- res/xml/privacy_dashboard_settings.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml index 7c4966b7707..954d3ef74d0 100644 --- a/res/xml/privacy_dashboard_settings.xml +++ b/res/xml/privacy_dashboard_settings.xml @@ -21,13 +21,11 @@ android:key="privacy_dashboard_page" android:title="@string/privacy_dashboard_title"> - @@ -42,7 +40,6 @@ @@ -52,7 +49,6 @@ android:key="privacy_permissions_usage" android:title="@string/permissions_usage_title" android:summary="@string/permissions_usage_summary" - settings:allowDividerAbove="true" settings:searchable="false" settings:controller="com.android.settings.privacy.PrivacyHubPreferenceController"> From 5012cef58f5f9aefdae3f6d066bf48bc462de483 Mon Sep 17 00:00:00 2001 From: lesl Date: Thu, 6 May 2021 12:44:21 +0800 Subject: [PATCH 08/20] wifi: Use new API for data usage function For mobile, a old API: buildTemplateMobileAll doesn't includes the merged wifi network, call the new API: buildTemplateCarrierMetered to replace the old one. PS: Not only usage functionality but also apply to network policy control since the default policy is changing to use new API: buildTemplateCarrier now. Test: make RunSettingsRoboTests ROBOTEST_FILTER=SettingsDumpServiceTest Test: make RunSettingsRoboTests ROBOTEST_FILTER=DataUsageLibTest Test: Manual Test, modify the mobile usage warming and limit bytes and check the data via adb shell dumpsys netpolicy Bug: 176396812 Merged-In: I6fbec14e7be4dc4b5c2fd3659a801521c81b233c Change-Id: I6fbec14e7be4dc4b5c2fd3659a801521c81b233c --- src/com/android/settings/SettingsDumpService.java | 4 ++-- src/com/android/settings/datausage/lib/DataUsageLib.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/SettingsDumpService.java b/src/com/android/settings/SettingsDumpService.java index a935c18be01..2a041f33772 100644 --- a/src/com/android/settings/SettingsDumpService.java +++ b/src/com/android/settings/SettingsDumpService.java @@ -111,9 +111,9 @@ public class SettingsDumpService extends Service { for (SubscriptionInfo info : manager.getAvailableSubscriptionInfoList()) { telephonyManager = telephonyManager .createForSubscriptionId(info.getSubscriptionId()); - NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll( + NetworkTemplate carrier = NetworkTemplate.buildTemplateCarrierMetered( telephonyManager.getSubscriberId()); - final JSONObject usage = dumpDataUsage(mobileAll, controller); + final JSONObject usage = dumpDataUsage(carrier, controller); usage.put("subId", info.getSubscriptionId()); array.put(usage); } diff --git a/src/com/android/settings/datausage/lib/DataUsageLib.java b/src/com/android/settings/datausage/lib/DataUsageLib.java index 786f0ecee2e..93907aade62 100644 --- a/src/com/android/settings/datausage/lib/DataUsageLib.java +++ b/src/com/android/settings/datausage/lib/DataUsageLib.java @@ -73,7 +73,7 @@ public class DataUsageLib { private static NetworkTemplate getMobileTemplateForSubId( TelephonyManager telephonyManager, int subId) { - return NetworkTemplate.buildTemplateMobileAll( + return NetworkTemplate.buildTemplateCarrierMetered( telephonyManager.getSubscriberId(subId)); } } From 645e28e31bacc95ec1998efc5ec91b6b84ed7b10 Mon Sep 17 00:00:00 2001 From: "Wesley.CW Wang" Date: Fri, 28 May 2021 21:44:28 +0800 Subject: [PATCH 09/20] Update battery error layout - Update font - Add importantForAccessibility to make whole layout selectable Screenshot: https://screenshot.googleplex.com/9nJxzD47xeaB6ea.png Bug: 187612897 Test: make RunSettingsRoboTests Change-Id: I15bbee6780d8e2c0a01995c6dbb91b933abda274 --- res/layout/preference_battery_error.xml | 9 +++++---- res/values/strings.xml | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/res/layout/preference_battery_error.xml b/res/layout/preference_battery_error.xml index 4efd13af012..68ac6a2ee54 100644 --- a/res/layout/preference_battery_error.xml +++ b/res/layout/preference_battery_error.xml @@ -24,6 +24,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp" + android:importantForAccessibility="yes" style="@style/ContextualCardStyle"> + android:textAppearance="?android:attr/textAppearanceListItem" /> + android:textAppearance="?android:attr/textAppearanceListItemSecondary" + android:textColor="@*android:color/material_red_A700" + android:contentDescription="@string/battery_missing_link_a11y_message" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index c6ea2d273ba..7e1420abc97 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6204,6 +6204,8 @@ Can’t update battery info + + Tap to learn more about this error Stop app? From adf36b5014acd71a5d571292912e010d657618a3 Mon Sep 17 00:00:00 2001 From: "Wesley.CW Wang" Date: Tue, 1 Jun 2021 22:13:18 +0800 Subject: [PATCH 10/20] Update battery settings string - Update App info battery usage entry subtext - Update battery settings battery usage title - Update battery error card text Bug: 187612897 Bug: 189785077 Bug: 178197718 Test: make RunSettingsRoboTests Change-Id: I101d56ab21abe0554964d5a4f1f7aceeacffb588 --- res/values/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 7e1420abc97..9be0960ff46 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6052,7 +6052,7 @@ History details - View battery usage + Battery Usage View usage for past 24 hours @@ -6201,7 +6201,7 @@ ^1 % - Can’t update battery info + Problem reading the battery meter. @@ -10475,13 +10475,13 @@ Allowing %1$s to always run in the background may reduce battery life. \n\nYou can change this later from Settings > Apps & notifications. - %1$s use since last full charge + %1$s use for past 24 hours Power management - No battery use since last full charge + No battery use for past 24 hours App settings From fae7509721bff58de9857aeaa8b2d9a3c3b672e0 Mon Sep 17 00:00:00 2001 From: Janis Danisevskis Date: Tue, 1 Jun 2021 11:44:16 -0700 Subject: [PATCH 11/20] Enable the clear credentials buttons when wifi keys are installed. This patch updates the ResetCredentialsPreferenceController to check the WIFI keystore namespace if called by the primary user. Test: Install a WIFI certificate or key and watch the "Clear credentials" button become enabled in the credential storage dialog of Settings. Bug: 189601008 Change-Id: I69828b64a7e3c707c27b4582d64ff0ddb863a4ff --- .../ResetCredentialsPreferenceController.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/security/ResetCredentialsPreferenceController.java b/src/com/android/settings/security/ResetCredentialsPreferenceController.java index 48e7f847ea0..5234ba8eab3 100644 --- a/src/com/android/settings/security/ResetCredentialsPreferenceController.java +++ b/src/com/android/settings/security/ResetCredentialsPreferenceController.java @@ -18,6 +18,8 @@ package com.android.settings.security; import android.content.Context; import android.os.UserManager; +import android.security.keystore.KeyProperties; +import android.security.keystore2.AndroidKeyStoreLoadStoreParameter; import androidx.preference.PreferenceScreen; @@ -35,6 +37,7 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr private static final String KEY_RESET_CREDENTIALS = "credentials_reset"; private final KeyStore mKeyStore; + private final KeyStore mWifiKeyStore; private RestrictedPreference mPreference; @@ -45,8 +48,19 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr keyStore = KeyStore.getInstance("AndroidKeyStore"); keyStore.load(null); } catch (Exception e) { + keyStore = null; } mKeyStore = keyStore; + keyStore = null; + if (context.getUser().isSystem()) { + try { + keyStore = KeyStore.getInstance("AndroidKeyStore"); + keyStore.load(new AndroidKeyStoreLoadStoreParameter(KeyProperties.NAMESPACE_WIFI)); + } catch (Exception e) { + keyStore = null; + } + } + mWifiKeyStore = keyStore; if (lifecycle != null) { lifecycle.addObserver(this); } @@ -68,9 +82,11 @@ public class ResetCredentialsPreferenceController extends RestrictedEncryptionPr if (mPreference != null && !mPreference.isDisabledByAdmin()) { boolean isEnabled = false; try { - if (mKeyStore != null) { - isEnabled = mKeyStore.aliases().hasMoreElements(); - } + isEnabled = (mKeyStore != null + && mKeyStore.aliases().hasMoreElements()) + || (mWifiKeyStore != null + && mWifiKeyStore.aliases().hasMoreElements()); + } catch (KeyStoreException e) { // If access to keystore fails, treat as disabled. } From af149b11fcb9a33722c6b50628057650e50c00c7 Mon Sep 17 00:00:00 2001 From: Curtis Belmonte Date: Thu, 27 May 2021 16:48:33 -0700 Subject: [PATCH 12/20] Fix biometric content overlap with top/bottom bars Sets a solid background for the status and footer bar shown on each of the biometric enroll introduction screens, to prevent the content from showing through. Test: Manually tested face and fingerprint enrollment Fixes: 189075189 Change-Id: I1a41dc911c5ac7ded94e33b25a9c0e990e93ba3f --- .../BiometricEnrollIntroduction.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java index 09d8e71fab5..a85382b9420 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java +++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java @@ -18,6 +18,8 @@ package com.android.settings.biometrics; import android.app.admin.DevicePolicyManager; import android.content.Intent; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.os.Bundle; @@ -25,14 +27,17 @@ import android.os.UserHandle; import android.os.UserManager; import android.util.Log; import android.view.View; +import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.widget.LockPatternUtils; import com.android.settings.R; import com.android.settings.SetupWizardUtils; +import com.android.settings.Utils; import com.android.settings.password.ChooseLockGeneric; import com.android.settings.password.ChooseLockSettingsHelper; @@ -182,6 +187,15 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase } } + @Override + protected void onPostCreate(@Nullable Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + final LinearLayout buttonContainer = mFooterBarMixin.getButtonContainer(); + if (buttonContainer != null) { + buttonContainer.setBackgroundColor(getBackgroundColor()); + } + } + @Override protected void onResume() { super.onResume(); @@ -199,6 +213,12 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase } } + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + getWindow().setStatusBarColor(getBackgroundColor()); + } + @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -335,4 +355,10 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase } return mIconColorFilter; } + + @ColorInt + private int getBackgroundColor() { + final ColorStateList stateList = Utils.getColorAttr(this, android.R.attr.windowBackground); + return stateList != null ? stateList.getDefaultColor() : Color.TRANSPARENT; + } } From 046e7beaefe36057e9ab4e289b3d43a05facfcb4 Mon Sep 17 00:00:00 2001 From: "Wesley.CW Wang" Date: Wed, 2 Jun 2021 13:39:07 +0800 Subject: [PATCH 13/20] Update battery defender tip subtext Bug: 189888727 Test: m RunSettingsRoboTests Change-Id: I5dc3bed3f839b3f62d2e78f0ae16b5465035e1fc --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index baa55a20f05..8dc816c127d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6100,7 +6100,7 @@ Charging temporarily limited - Battery limited temporarily. Learn more. + To preserve your battery. Learn more. Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage: From 4cf930a9fff3b262cb6481ca98f29dced17f2373 Mon Sep 17 00:00:00 2001 From: Sunny Shao Date: Mon, 31 May 2021 10:50:28 +0800 Subject: [PATCH 14/20] Fix slider RTL problem Fixes: 187987211 Test: manual test Change-Id: Id28f060aa55773707dc23f4606a188cc188c3b07 --- res/layout/font_size_activity.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/res/layout/font_size_activity.xml b/res/layout/font_size_activity.xml index c3b26ae7526..8850f8694e0 100644 --- a/res/layout/font_size_activity.xml +++ b/res/layout/font_size_activity.xml @@ -56,7 +56,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" - android:layoutDirection="ltr" android:paddingTop="8dp"> Date: Tue, 1 Jun 2021 14:58:21 +0800 Subject: [PATCH 15/20] Fix voice access problem on location page. - Remove the seletcable attribute on footer preference so that voice access can identify learn more. - Apply latest footer preference API to set an action on learn more. - Remove unuse string resource. Test: Verify that talkback and voice access work well. Fix: 189652942 Change-Id: I45fcd21d6a2d693d8b5eaa446aaccb769f1c0c7f --- res/values/strings.xml | 5 ++--- res/xml/location_settings.xml | 1 - ...ionSettingsFooterPreferenceController.java | 20 +++++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index c6ea2d273ba..fcb97e02cf6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -695,9 +695,8 @@ emergency responders when you call or text an emergency number. - - <a href=" https://support.google.com/android/answer/3467281">Learn more</a> + + https://support.google.com/android/answer/3467281 diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml index cffab3ee06b..fe87efd73d7 100644 --- a/res/xml/location_settings.xml +++ b/res/xml/location_settings.xml @@ -71,7 +71,6 @@ diff --git a/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java b/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java index 281cc5abf9d..a3b68be7da2 100644 --- a/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java +++ b/src/com/android/settings/location/LocationSettingsFooterPreferenceController.java @@ -31,6 +31,7 @@ import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import com.android.settings.R; +import com.android.settingslib.HelpUtils; import com.android.settingslib.widget.FooterPreference; import java.util.ArrayList; @@ -104,15 +105,22 @@ public class LocationSettingsFooterPreferenceController extends LocationBasePref + footerString; } if (mFooterPreference != null) { - mFooterPreference.setTitle(Html.fromHtml(footerString - + PARAGRAPH_SEPARATOR - + mContext.getString( - R.string.location_settings_footer_learn_more))); - mFooterPreference.setContentDescription(Html.fromHtml(footerString + mContext.getString( - R.string.location_settings_footer_learn_more_content_description))); + mFooterPreference.setTitle(Html.fromHtml(footerString)); + mFooterPreference.setLearnMoreAction(v -> openLocationLearnMoreLink()); + mFooterPreference.setLearnMoreContentDescription(mContext.getString( + R.string.location_settings_footer_learn_more_content_description)); } } + private void openLocationLearnMoreLink() { + mFragment.startActivityForResult( + HelpUtils.getHelpIntent( + mContext, + mContext.getString(R.string.location_settings_footer_learn_more_link), + /*backupContext=*/""), + /*requestCode=*/ 0); + } + /** * Location footer preference group should always be displayed. */ From 08f90ddb2d5f6a00c0c01525714ffa6f42ee5317 Mon Sep 17 00:00:00 2001 From: Curtis Belmonte Date: Tue, 1 Jun 2021 17:10:24 -0700 Subject: [PATCH 16/20] Align assets and colors for biometric enroll intros Replaces the existing MP4 shown on the face enroll intro/consent screen with an updated lock asset that matches the current SUW theme. Also updates the colors of assets and text on these screens for face and fingerprint so that the two match. Test: Manually tested both enrollments for dark and light system themes Bug: 187681255 Change-Id: I119da913cfc76e02160f2efc4654cecf33f1f049 --- color-check-baseline.xml | 770 ++++++++++++++++-- .../face_enroll_intro_illustration.xml | 52 ++ .../fingerprint_enroll_introduction.xml | 20 +- res/layout/face_enroll_introduction.xml | 21 +- .../fingerprint_enroll_introduction.xml | 24 +- res/values-night/colors.xml | 5 + res/values/colors.xml | 5 + 7 files changed, 803 insertions(+), 94 deletions(-) create mode 100644 res/drawable/face_enroll_intro_illustration.xml diff --git a/color-check-baseline.xml b/color-check-baseline.xml index e6bf1ec29be..48a204f2cd2 100644 --- a/color-check-baseline.xml +++ b/color-check-baseline.xml @@ -413,6 +413,38 @@ column="5"/> + + + + + + + + + + + + + + + + + + + + + + + + @@ -1305,7 +1401,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1321,7 +1417,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1337,7 +1433,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1353,7 +1449,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1369,7 +1465,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1385,7 +1481,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1401,7 +1497,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1417,7 +1513,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1433,7 +1529,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1449,7 +1545,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1465,7 +1561,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1481,7 +1577,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1497,7 +1593,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1513,7 +1609,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1529,7 +1625,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1545,7 +1641,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1561,7 +1657,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1577,7 +1673,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1593,7 +1689,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1609,7 +1705,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1625,7 +1721,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1641,7 +1737,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1657,7 +1753,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1673,7 +1769,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1689,7 +1785,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1705,7 +1801,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1721,7 +1817,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1737,7 +1833,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1753,7 +1849,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1769,7 +1865,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1785,7 +1881,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1801,7 +1897,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1817,7 +1913,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1833,7 +1929,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1849,7 +1945,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1865,7 +1961,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1881,7 +1977,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1897,7 +1993,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1913,7 +2009,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1929,7 +2025,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1945,7 +2041,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1961,7 +2057,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1977,7 +2073,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1993,7 +2089,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2093,6 +2189,230 @@ column="9"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - @@ -3529,7 +4153,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3545,7 +4169,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -3561,10 +4185,26 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> + + + + + + + + + + + + + + + + + + diff --git a/res/drawable/fingerprint_enroll_introduction.xml b/res/drawable/fingerprint_enroll_introduction.xml index 9781c54000f..1ad4302cd61 100644 --- a/res/drawable/fingerprint_enroll_introduction.xml +++ b/res/drawable/fingerprint_enroll_introduction.xml @@ -21,33 +21,33 @@ android:viewportHeight="210.0" android:viewportWidth="210.0"> diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml index 7783d723d33..77a10197f1b 100644 --- a/res/layout/face_enroll_introduction.xml +++ b/res/layout/face_enroll_introduction.xml @@ -27,7 +27,7 @@ @@ -42,24 +42,23 @@ + android:layout_marginTop="-24dp" + android:layout_marginBottom="4dp"> - + android:layout_width="match_parent" + android:layout_height="match_parent" + android:contentDescription="@null" + android:src="@drawable/face_enroll_intro_illustration"/> - + + android:orientation="vertical"> + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_title_2" + android:textColor="?android:attr/textColorPrimary"/> + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_2" + android:textColor="?android:attr/textColorPrimary"/> + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_3" + android:textColor="?android:attr/textColorPrimary"/> @@ -115,7 +118,8 @@ android:layout_height="wrap_content" android:textAlignment="viewStart" android:paddingTop="12dp" - android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_1" /> + android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_1" + android:textColor="?android:attr/textColorPrimary"/> + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_4" + android:textColor="?android:attr/textColorPrimary"/> @@ -147,7 +152,8 @@ android:layout_height="wrap_content" android:textAlignment="viewStart" android:paddingTop="12dp" - android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2" /> + android:text="@string/security_settings_fingerprint_enroll_introduction_footer_title_2" + android:textColor="?android:attr/textColorPrimary"/> + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_message_5" + android:textColor="?android:attr/textColorPrimary"/> + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_message_learn_more" + android:textColor="?android:attr/textColorPrimary"/> diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml index faf7962ee59..0b685144134 100644 --- a/res/values-night/colors.xml +++ b/res/values-night/colors.xml @@ -41,5 +41,10 @@ @*android:color/surface_header_dark #f28b82 + + + #5bb974 + #669df6 + #5e5e5e diff --git a/res/values/colors.xml b/res/values/colors.xml index bd41f1ef08e..71d110b3408 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -126,6 +126,11 @@ #fffdd835 #ff9e9e9e + + #1e8e3e + #1a73e8 + #e3e3e3 + #ffff0000 #FF32c1de From c3fc64cbb027c9a330391dcfe7704afc2975629b Mon Sep 17 00:00:00 2001 From: Trevor David Black Date: Tue, 1 Jun 2021 19:42:42 +0000 Subject: [PATCH 17/20] Remove extra app info setting under specific condition Bug: b/189585202 Test: Settings -> Apps -> App -> ExtraAppInfo Change-Id: Ibdd86607bfdf2879ad3461b35c72964671827854 --- .../appinfo/ExtraAppInfoFeatureProvider.java | 7 ++- .../ExtraAppInfoFeatureProviderImpl.java | 5 ++ .../ExtraAppInfoPreferenceController.java | 11 ++++ .../ExtraAppInfoFeatureProviderImplTest.java | 54 +++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/robotests/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImplTest.java diff --git a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java index 4de1c2c91c0..ec70f572cdc 100644 --- a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java +++ b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java @@ -36,7 +36,12 @@ public interface ExtraAppInfoFeatureProvider { void setPackageName(String packageName); /** - * gets the summary name + * Checks if enabled + */ + boolean isEnabled(Context context); + + /** + * Gets the summary name */ String getSummary(Context context); } diff --git a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java index 55b9bf0dc75..7d800e68493 100644 --- a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java +++ b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java @@ -38,6 +38,11 @@ public class ExtraAppInfoFeatureProviderImpl implements return; } + @Override + public boolean isEnabled(Context context) { + return false; + } + @Override public String getSummary(Context context) { return ""; diff --git a/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java b/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java index 0d72b749119..43796d0d85c 100644 --- a/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java +++ b/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java @@ -20,6 +20,7 @@ import android.content.Context; import android.text.TextUtils; import androidx.preference.Preference; +import androidx.preference.PreferenceScreen; import com.android.settings.core.BasePreferenceController; import com.android.settings.overlay.FeatureFactory; @@ -55,6 +56,16 @@ public class ExtraAppInfoPreferenceController extends BasePreferenceController { return mExtraAppInfoFeatureProvider.getSummary(mContext); } + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + + if (mExtraAppInfoFeatureProvider != null) { + final Preference preference = screen.findPreference(getPreferenceKey()); + preference.setEnabled(mExtraAppInfoFeatureProvider.isEnabled(preference.getContext())); + } + } + /** * Set the local package name */ diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImplTest.java new file mode 100644 index 00000000000..d8ba07351e3 --- /dev/null +++ b/tests/robotests/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImplTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2021 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.applications.appinfo; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + +@RunWith(RobolectricTestRunner.class) +public class ExtraAppInfoFeatureProviderImplTest { + private Context mContext; + private ExtraAppInfoFeatureProviderImpl mController; + + @Before + public void setUp() { + mContext = RuntimeEnvironment.application; + mController = new ExtraAppInfoFeatureProviderImpl(); + } + + @Test + public void isSupported_notSupportedByDefault() { + assertThat(mController.isSupported(mContext)).isEqualTo(false); + } + + @Test + public void isEnabled_notEnabledByDefault() { + assertThat(mController.isEnabled(mContext)).isEqualTo(false); + } + + @Test + public void getSummary_emptyByDefault() { + assertThat(mController.getSummary(mContext)).isEqualTo(""); + } +} From 863d2e50e7287854f20b36a9b4dc99ba566199f3 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Thu, 27 May 2021 13:47:58 +0800 Subject: [PATCH 18/20] Remove silky flag for searching and help menu Bug: 183670633 Test: robotests Change-Id: Ia62936e9f48a111ab36d74b852ec04090e42039a --- src/com/android/settings/SettingsPreferenceFragment.java | 9 --------- .../manageapplications/ManageApplications.java | 5 ----- .../gestures/SystemNavigationGestureSettings.java | 9 --------- .../settings/wifi/calling/WifiCallingSettings.java | 9 --------- 4 files changed, 32 deletions(-) diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java index a276ad75458..b8ff60c7c14 100644 --- a/src/com/android/settings/SettingsPreferenceFragment.java +++ b/src/com/android/settings/SettingsPreferenceFragment.java @@ -26,7 +26,6 @@ import android.content.pm.PackageManager; import android.os.Bundle; import android.text.TextUtils; import android.util.ArrayMap; -import android.util.FeatureFlagUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -43,11 +42,8 @@ import androidx.preference.PreferenceScreen; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.android.settings.core.FeatureFlags; import com.android.settings.core.InstrumentedPreferenceFragment; import com.android.settings.core.instrumentation.InstrumentedDialogFragment; -import com.android.settings.search.actionbar.SearchMenuController; -import com.android.settings.support.actionbar.HelpMenuController; import com.android.settings.support.actionbar.HelpResourceProvider; import com.android.settings.widget.HighlightablePreferenceGroupAdapter; import com.android.settings.widget.LoadingViewController; @@ -129,11 +125,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); - // TODO(b/176883483): Remove both search and help menu if this feature rolled out - if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { - SearchMenuController.init(this /* host */); - HelpMenuController.init(this /* host */); - } if (icicle != null) { mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY); diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java index d5162a85c2d..164ef2d2723 100644 --- a/src/com/android/settings/applications/manageapplications/ManageApplications.java +++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java @@ -123,7 +123,6 @@ import com.android.settings.notification.app.AppNotificationSettings; import com.android.settings.widget.LoadingViewController; import com.android.settings.wifi.AppStateChangeWifiStateBridge; import com.android.settings.wifi.ChangeWifiStateDetails; -import com.android.settingslib.HelpUtils; import com.android.settingslib.applications.ApplicationsState; import com.android.settingslib.applications.ApplicationsState.AppEntry; import com.android.settingslib.applications.ApplicationsState.AppFilter; @@ -661,10 +660,6 @@ public class ManageApplications extends InstrumentedFragment if (activity == null) { return; } - // TODO(b/176883483): Remove the help menu if this feature rolled out - if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { - HelpUtils.prepareHelpMenuItem(activity, menu, getHelpResource(), getClass().getName()); - } mOptionsMenu = menu; inflater.inflate(R.menu.manage_apps, menu); diff --git a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java index 388d87ae9a9..854efa05531 100644 --- a/src/com/android/settings/gestures/SystemNavigationGestureSettings.java +++ b/src/com/android/settings/gestures/SystemNavigationGestureSettings.java @@ -30,18 +30,14 @@ import android.content.om.OverlayInfo; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; -import android.util.FeatureFlagUtils; import androidx.annotation.VisibleForTesting; import androidx.preference.PreferenceScreen; import com.android.settings.R; -import com.android.settings.core.FeatureFlags; import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.BaseSearchIndexProvider; -import com.android.settings.search.actionbar.SearchMenuController; -import com.android.settings.support.actionbar.HelpMenuController; import com.android.settings.support.actionbar.HelpResourceProvider; import com.android.settings.utils.CandidateInfoExtra; import com.android.settings.widget.RadioButtonPickerFragment; @@ -76,11 +72,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i @Override public void onAttach(Context context) { super.onAttach(context); - // TODO(b/176883483): Remove both search and help menu if this feature rolled out - if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { - SearchMenuController.init(this /* host */); - HelpMenuController.init(this /* host */); - } SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context) .getSuggestionFeatureProvider(context); diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettings.java b/src/com/android/settings/wifi/calling/WifiCallingSettings.java index 79f34c79962..86e7e8da670 100644 --- a/src/com/android/settings/wifi/calling/WifiCallingSettings.java +++ b/src/com/android/settings/wifi/calling/WifiCallingSettings.java @@ -22,7 +22,6 @@ import android.os.Bundle; import android.provider.Settings; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; -import android.util.FeatureFlagUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -35,12 +34,10 @@ import androidx.fragment.app.FragmentPagerAdapter; import com.android.internal.util.CollectionUtils; import com.android.settings.R; -import com.android.settings.core.FeatureFlags; import com.android.settings.core.InstrumentedFragment; import com.android.settings.network.SubscriptionUtil; import com.android.settings.network.ims.WifiCallingQueryImsState; import com.android.settings.search.actionbar.SearchMenuController; -import com.android.settings.support.actionbar.HelpMenuController; import com.android.settings.support.actionbar.HelpResourceProvider; import com.android.settings.widget.RtlCompatibleViewPager; import com.android.settings.widget.SlidingTabLayout; @@ -121,12 +118,6 @@ public class WifiCallingSettings extends InstrumentedFragment implements HelpRes @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); - // TODO(b/176883483): Remove the option menu if collapsing toolbar feature rolled out - if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { - setHasOptionsMenu(true); - SearchMenuController.init(this /* host */); - HelpMenuController.init(this /* host */); - } // TODO: besides in onCreate, we should also update subList when SIM / Sub status // changes. From 1aadccac6dec91d56a06cf1ccb1582c02a823e81 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Wed, 2 Jun 2021 18:58:15 +0800 Subject: [PATCH 19/20] Remove silky flag from misc files Remove the silky condition. Bug: 183670633 Test: robotests Change-Id: I53cff0b149afb26d40f9b3af21c1b384058b306b --- src/com/android/settings/Utils.java | 6 +----- .../settings/inputmethod/UserDictionarySettings.java | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 6d4ea264dc5..90dad9ddec6 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -110,7 +110,6 @@ import androidx.preference.PreferenceGroup; import com.android.internal.app.UnlaunchableAppActivity; import com.android.internal.util.ArrayUtils; import com.android.internal.widget.LockPatternUtils; -import com.android.settings.core.FeatureFlags; import com.android.settings.dashboard.profileselector.ProfileFragmentBridge; import com.android.settings.dashboard.profileselector.ProfileSelectFragment; import com.android.settings.password.ChooseLockSettingsHelper; @@ -1228,10 +1227,7 @@ public final class Utils extends com.android.settingslib.Utils { } public static boolean isPageTransitionEnabled(Context context) { - final boolean isSilkyHome = FeatureFlagUtils.isEnabled(context, FeatureFlags.SILKY_HOME); - final boolean isTransitionEnabled = Settings.Global.getInt(context.getContentResolver(), + return Settings.Global.getInt(context.getContentResolver(), SETTINGS_SHARED_AXIS_ENABLED, 0) == 1; - - return isSilkyHome && isTransitionEnabled; } } diff --git a/src/com/android/settings/inputmethod/UserDictionarySettings.java b/src/com/android/settings/inputmethod/UserDictionarySettings.java index 5e3e7495359..f51629d2b7a 100644 --- a/src/com/android/settings/inputmethod/UserDictionarySettings.java +++ b/src/com/android/settings/inputmethod/UserDictionarySettings.java @@ -26,7 +26,6 @@ import android.database.Cursor; import android.os.Bundle; import android.provider.UserDictionary; import android.text.TextUtils; -import android.util.FeatureFlagUtils; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -45,7 +44,6 @@ import androidx.loader.app.LoaderManager; import androidx.loader.content.Loader; import com.android.settings.R; -import com.android.settings.core.FeatureFlags; import com.android.settings.core.SubSettingLauncher; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.core.instrumentation.Instrumentable; @@ -106,10 +104,7 @@ public class UserDictionarySettings extends ListFragment implements Instrumentab @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // TODO(b/176883483): Remove the title after material component updated - if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) { - getActivity().setTitle(R.string.user_dict_settings_title); - } + getActivity().setTitle(R.string.user_dict_settings_title); // Show the language as a subtitle of the action bar final ActionBar actionBar = getActivity().getActionBar(); if (actionBar != null) { From 3d20bf93fde055c5128bd71b28a0f40144d2800c Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Wed, 2 Jun 2021 09:40:12 -0700 Subject: [PATCH 20/20] Fix array out of bounds in BiometricEnrollActivity Bug: 189876828 Test: adb shell am start -a android.settings.BIOMETRIC_ENROLL Change-Id: I89f8ea1353cd9243c20c6184d579707da27e7b6f --- .../settings/biometrics/BiometricEnrollActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java index 4702fed424a..11313fd52d4 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java +++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java @@ -266,10 +266,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity { faceManager.getSensorPropertiesInternal(); // This would need to be updated for devices with multiple sensors of the same modality - mIsFaceEnrollable = faceManager.getEnrolledFaces(mUserId).size() - < faceProperties.get(0).maxEnrollmentsPerUser; - mIsFingerprintEnrollable = fingerprintManager.getEnrolledFingerprints(mUserId).size() - < fpProperties.get(0).maxEnrollmentsPerUser; + mIsFaceEnrollable = !faceProperties.isEmpty() && + faceManager.getEnrolledFaces(mUserId).size() + < faceProperties.get(0).maxEnrollmentsPerUser; + mIsFingerprintEnrollable = !fpProperties.isEmpty() && + fingerprintManager.getEnrolledFingerprints(mUserId).size() + < fpProperties.get(0).maxEnrollmentsPerUser; if (!mConfirmingCredentials) { mConfirmingCredentials = true;