From 730a573d2844acc0f303b77f5864b5339f29fdca Mon Sep 17 00:00:00 2001 From: Kevin Han Date: Fri, 11 Jun 2021 19:29:13 -0700 Subject: [PATCH 01/15] Update "Unused apps" load-in UI Update the UI for the "Unused apps" preference to update with the loaded number of unused apps instead of having the entire preference animate in. Bug: 187996287 Test: manual Test: atest HibernatedAppsPreferenceControllerTest Change-Id: I1c6998de4daaf4d8678a3ffdaf83f5d2417fa68d --- .../HibernatedAppsPreferenceController.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/applications/HibernatedAppsPreferenceController.java b/src/com/android/settings/applications/HibernatedAppsPreferenceController.java index bf12b86c004..898d7096ee6 100644 --- a/src/com/android/settings/applications/HibernatedAppsPreferenceController.java +++ b/src/com/android/settings/applications/HibernatedAppsPreferenceController.java @@ -61,6 +61,7 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont private PreferenceScreen mScreen; private int mUnusedCount = 0; private boolean mLoadingUnusedApps; + private boolean mLoadedUnusedCount; private final Executor mBackgroundExecutor; private final Executor mMainExecutor; @@ -79,14 +80,15 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont @Override public int getAvailabilityStatus() { - return isHibernationEnabled() && mUnusedCount > 0 - ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; + return isHibernationEnabled() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } @Override public CharSequence getSummary() { - return mContext.getResources().getQuantityString( - R.plurals.unused_apps_summary, mUnusedCount, mUnusedCount); + return mLoadedUnusedCount + ? mContext.getResources().getQuantityString( + R.plurals.unused_apps_summary, mUnusedCount, mUnusedCount) + : mContext.getResources().getString(R.string.summary_placeholder); } @Override @@ -111,8 +113,8 @@ public final class HibernatedAppsPreferenceController extends BasePreferenceCont loadUnusedCount(unusedCount -> { mUnusedCount = unusedCount; mLoadingUnusedApps = false; + mLoadedUnusedCount = true; mMainExecutor.execute(() -> { - super.displayPreference(mScreen); Preference pref = mScreen.findPreference(mPreferenceKey); refreshSummary(pref); }); From d98ee531c1d6a52e4c37014940ef78642c1f0f8e Mon Sep 17 00:00:00 2001 From: Sally Date: Mon, 14 Jun 2021 22:10:27 +0000 Subject: [PATCH 02/15] Add labels to intensity slider and flip labels Labels are Dimmer and Brighter. As the slider value is lowered, the dimming intensity is increased Slider min = 100 - intensity max Slider max = 100 - intensity min Ex: If intensity max = 80, the slider min with be 20. If the user moves the position to the minimum end we'll send 80 to Color DisplayManager Test: atest ReduceBrightColorsIntensityPreferenceControllerTest, manual Bug: 190722076 Change-Id: Ib05ba38805b8fa1f68c144a3929027899df70abf --- res/values/strings.xml | 4 ++++ res/xml/reduce_bright_colors_settings.xml | 9 +++++++-- ...uceBrightColorsIntensityPreferenceController.java | 12 ++++++++---- ...rightColorsIntensityPreferenceControllerTest.java | 8 +++++--- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 90708da8871..53e51e2384a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5586,6 +5586,10 @@ Intensity + + Dimmer + + Brighter Keep on after device restarts diff --git a/res/xml/reduce_bright_colors_settings.xml b/res/xml/reduce_bright_colors_settings.xml index b9ca8549204..00ab585f3c6 100644 --- a/res/xml/reduce_bright_colors_settings.xml +++ b/res/xml/reduce_bright_colors_settings.xml @@ -17,13 +17,18 @@ - + android:title="@string/reduce_bright_colors_intensity_preference_title" + settings:textStart="@string/reduce_bright_colors_intensity_start_label" + settings:textEnd="@string/reduce_bright_colors_intensity_end_label" + settings:tickMark="@android:color/transparent" + /> Date: Tue, 15 Jun 2021 13:07:15 -0700 Subject: [PATCH 03/15] Add biometric strings to DeviceAdminStringProviderImpl Bug: 190067596 Test: manual Change-Id: I3a8f94fd6b2730164dff263f068543abd8d4d18b --- res/values/strings.xml | 4 ++++ .../enterprise/DeviceAdminStringProviderImpl.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index b99dfc71675..eff49d1e975 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10942,6 +10942,10 @@ Can’t open this app Blocked by your credit provider + + Parent needed + + Hand the phone to your parent to start setting this up If you have questions, contact your IT admin diff --git a/src/com/android/settings/enterprise/DeviceAdminStringProviderImpl.java b/src/com/android/settings/enterprise/DeviceAdminStringProviderImpl.java index 68b202108b6..5d11d4ab3a6 100644 --- a/src/com/android/settings/enterprise/DeviceAdminStringProviderImpl.java +++ b/src/com/android/settings/enterprise/DeviceAdminStringProviderImpl.java @@ -79,4 +79,14 @@ class DeviceAdminStringProviderImpl implements DeviceAdminStringProvider { public String getDisabledByPolicyTitleForFinancedDevice() { return mContext.getString(R.string.disabled_by_policy_title_financed_device); } + + @Override + public String getDisabledBiometricsParentConsentTitle() { + return mContext.getString(R.string.disabled_by_policy_title_biometric_parental_consent); + } + + @Override + public String getDisabledBiometricsParentConsentContent() { + return mContext.getString(R.string.disabled_by_policy_content_biometric_parental_consent); + } } From 0c34d259a045de6ad74818bf18a636273b1c1a4a Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Tue, 15 Jun 2021 13:34:11 -0700 Subject: [PATCH 04/15] Show biometric-specific dialog when appropriate 1) We need to pass a "restriction" string from settings to the dialog, otherwise the biometric dialog could be shown in non-biometric flows 2) Updates ActionDisabledByAdminDialogHelper to pass the restrition to be taken into consideration when creating the controller 3) Sets an optional onClickListener on the positive button. Bug: 5788943 Test: atest ParentalControlsUtilsTest Change-Id: Iedff7fef50e186b2779f061f37d3080c910d2179 --- .../settings/biometrics/ParentalControlsUtils.java | 7 +++++-- .../enterprise/ActionDisabledByAdminDialog.java | 2 +- .../enterprise/ActionDisabledByAdminDialogHelper.java | 10 ++++++++-- .../settings/biometrics/ParentalControlsUtilsTest.java | 2 ++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/biometrics/ParentalControlsUtils.java b/src/com/android/settings/biometrics/ParentalControlsUtils.java index 2d3673b2de3..0959184b16f 100644 --- a/src/com/android/settings/biometrics/ParentalControlsUtils.java +++ b/src/com/android/settings/biometrics/ParentalControlsUtils.java @@ -22,6 +22,7 @@ import android.content.Context; import android.hardware.biometrics.BiometricAuthenticator; import android.hardware.biometrics.ParentalControlsUtilsInternal; import android.os.UserHandle; +import android.os.UserManager; import android.util.Log; import androidx.annotation.NonNull; @@ -49,7 +50,8 @@ public class ParentalControlsUtils { final UserHandle userHandle = new UserHandle(UserHandle.myUserId()); if (ParentalControlsUtilsInternal.isTestModeEnabled(context)) { Log.d(TAG, "Requiring consent for test flow"); - return new RestrictedLockUtils.EnforcedAdmin(null /* ComponentName */, userHandle); + return new RestrictedLockUtils.EnforcedAdmin(null /* ComponentName */, + UserManager.DISALLOW_BIOMETRIC, userHandle); } final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class); @@ -69,7 +71,8 @@ public class ParentalControlsUtils { userHandle)) { final ComponentName cn = ParentalControlsUtilsInternal.getSupervisionComponentName(dpm, userHandle); - return new RestrictedLockUtils.EnforcedAdmin(cn, userHandle); + return new RestrictedLockUtils.EnforcedAdmin(cn, UserManager.DISALLOW_BIOMETRIC, + userHandle); } else { return null; } diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java index 717c5bcd757..ce7ad242056 100644 --- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java +++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialog.java @@ -37,7 +37,7 @@ public class ActionDisabledByAdminDialog extends Activity final RestrictedLockUtils.EnforcedAdmin enforcedAdmin = getAdminDetailsFromIntent(getIntent()); final String restriction = getRestrictionFromIntent(getIntent()); - mDialogHelper = new ActionDisabledByAdminDialogHelper(this); + mDialogHelper = new ActionDisabledByAdminDialogHelper(this, restriction); mDialogHelper.prepareDialogBuilder(restriction, enforcedAdmin) .setOnDismissListener(this) .show(); diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java index 5da076736e9..e30f8900655 100644 --- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java +++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java @@ -56,11 +56,16 @@ public final class ActionDisabledByAdminDialogHelper { private final Activity mActivity; public ActionDisabledByAdminDialogHelper(Activity activity) { + this(activity, null /* restriction */); + } + + public ActionDisabledByAdminDialogHelper(Activity activity, String restriction) { mActivity = activity; mDialogView = (ViewGroup) LayoutInflater.from(mActivity).inflate( R.layout.admin_support_details_dialog, null); mActionDisabledByAdminController = ActionDisabledByAdminControllerFactory - .createInstance(mActivity, new DeviceAdminStringProviderImpl(mActivity)); + .createInstance(mActivity, restriction, + new DeviceAdminStringProviderImpl(mActivity)); } private @UserIdInt int getEnforcementAdminUserId(@NonNull EnforcedAdmin admin) { @@ -74,7 +79,8 @@ public final class ActionDisabledByAdminDialogHelper { public AlertDialog.Builder prepareDialogBuilder(String restriction, EnforcedAdmin enforcedAdmin) { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity) - .setPositiveButton(R.string.okay, null) + .setPositiveButton(R.string.okay, + mActionDisabledByAdminController.getPositiveButtonListener()) .setView(mDialogView); prepareDialogBuilder(builder, restriction, enforcedAdmin); return builder; diff --git a/tests/unit/src/com/android/settings/biometrics/ParentalControlsUtilsTest.java b/tests/unit/src/com/android/settings/biometrics/ParentalControlsUtilsTest.java index a820d655ceb..5128af0d410 100644 --- a/tests/unit/src/com/android/settings/biometrics/ParentalControlsUtilsTest.java +++ b/tests/unit/src/com/android/settings/biometrics/ParentalControlsUtilsTest.java @@ -35,6 +35,7 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS; import android.hardware.biometrics.BiometricAuthenticator; import android.os.UserHandle; +import android.os.UserManager; import androidx.annotation.Nullable; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -92,6 +93,7 @@ public class ParentalControlsUtilsTest { mSupervisionComponentName, tests[i][0] /* modality */, tests[i][1] /* keyguardDisableFlags */); assertNotNull(admin); + assertEquals(UserManager.DISALLOW_BIOMETRIC, admin.enforcedRestriction); assertEquals(mSupervisionComponentName, admin.component); } } From 35aa93d8d23f19d6e923547cb21e03673bb74976 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Tue, 15 Jun 2021 18:10:48 -0700 Subject: [PATCH 05/15] Pass context and enforcedAdmin to onClickListener These are apparently not available / not initialized in the constructor. So, let's just pass it in from known entry points. Bug: 188847063 Test: Builds Change-Id: I5467f341ccf017ddfb31ef9fc4ef1756ebb65939 --- .../settings/enterprise/ActionDisabledByAdminDialogHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java index e30f8900655..ccc74367cdf 100644 --- a/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java +++ b/src/com/android/settings/enterprise/ActionDisabledByAdminDialogHelper.java @@ -80,7 +80,8 @@ public final class ActionDisabledByAdminDialogHelper { EnforcedAdmin enforcedAdmin) { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity) .setPositiveButton(R.string.okay, - mActionDisabledByAdminController.getPositiveButtonListener()) + mActionDisabledByAdminController + .getPositiveButtonListener(mActivity, enforcedAdmin)) .setView(mDialogView); prepareDialogBuilder(builder, restriction, enforcedAdmin); return builder; From 25ee0a7438e4cce81ab0ec6c7a00f1e0a158968e Mon Sep 17 00:00:00 2001 From: menghanli Date: Wed, 16 Jun 2021 17:33:26 +0800 Subject: [PATCH 06/15] Fix "Left" & "Right" in the wrong sides for LTR language Root cause: In the LTR language, the "Left" & "Right" options should be in the opposite sides -- currently "Left" is in the right side and "Right" is in the left side (Same as the English version) and should be changed. Solution: Keep ltr layout direction. Bug: 190354990 Test: Manual test Change-Id: I47b71b3db7c834984202513e2cac6c4d787518dc --- res/layout/preference_balance_slider.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/layout/preference_balance_slider.xml b/res/layout/preference_balance_slider.xml index 93e192aedc4..22e175ce50f 100644 --- a/res/layout/preference_balance_slider.xml +++ b/res/layout/preference_balance_slider.xml @@ -72,6 +72,7 @@ Date: Wed, 16 Jun 2021 21:03:25 +0800 Subject: [PATCH 07/15] Improve flicker when open app info page The Battery item moves down because the summary of Screen time is loading in the background, we should put a summary placeholder to avoid item shifting. Fixes: 191115152 Test: robotests & visual Change-Id: Iee297a7350726f02c3569231d37112f8911b1b35 --- res/xml/app_info_settings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/xml/app_info_settings.xml b/res/xml/app_info_settings.xml index fef52432d24..f3c58601f7f 100644 --- a/res/xml/app_info_settings.xml +++ b/res/xml/app_info_settings.xml @@ -80,6 +80,7 @@ Date: Wed, 16 Jun 2021 14:00:39 -0400 Subject: [PATCH 08/15] Validate config activities with their rule owners Test: RoboTests Bug: 189332346 Change-Id: Iee1b1caca4d6eb2729feb872c3e4954b6c16519c --- ...ModeAutomaticRulePreferenceController.java | 58 ++++-- .../notification/zen/ZenRulePreference.java | 2 +- ...AutomaticRulePreferenceControllerTest.java | 169 ++++++++++++++++++ 3 files changed, 209 insertions(+), 20 deletions(-) create mode 100644 tests/robotests/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceControllerTest.java diff --git a/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java b/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java index f6f183995ec..701abbb0b65 100644 --- a/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java +++ b/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceController.java @@ -26,8 +26,11 @@ import android.content.pm.ActivityInfo; import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; +import android.os.Binder; import android.provider.Settings; import android.service.notification.ConditionProviderService; +import android.util.Log; +import android.util.Slog; import androidx.fragment.app.Fragment; import androidx.preference.Preference; @@ -36,6 +39,7 @@ import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.core.lifecycle.Lifecycle; import java.util.Map; +import java.util.Objects; abstract public class AbstractZenModeAutomaticRulePreferenceController extends AbstractZenModePreferenceController implements PreferenceControllerMixin { @@ -92,7 +96,7 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends ? ci.metaData.getString(ConditionProviderService.META_DATA_RULE_TYPE) : ci.metaData.getString(NotificationManager.META_DATA_AUTOMATIC_RULE_TYPE); - final ComponentName configurationActivity = getSettingsActivity(null, ci); + final ComponentName configurationActivity = getSettingsActivity(pm, null, ci); if (ruleType != null && !ruleType.trim().isEmpty() && configurationActivity != null) { final ZenRuleInfo ri = new ZenRuleInfo(); ri.serviceComponent = @@ -110,28 +114,44 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends return null; } - protected static ComponentName getSettingsActivity(AutomaticZenRule rule, ComponentInfo ci) { + protected static ComponentName getSettingsActivity(PackageManager pm, AutomaticZenRule rule, + ComponentInfo ci) { + String owner = rule != null ? rule.getPackageName() : ci.packageName; + ComponentName settingsActivity = null; // prefer config activity on the rule itself; fallback to manifest definition if (rule != null && rule.getConfigurationActivity() != null) { - return rule.getConfigurationActivity(); - } - if (ci == null) { - return null; - } - // new activity backed rule - if (ci instanceof ActivityInfo) { - return new ComponentName(ci.packageName, ci.name); - } - // old service backed rule - if (ci.metaData != null) { - final String configurationActivity = ci.metaData.getString( - ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY); - if (configurationActivity != null) { - return ComponentName.unflattenFromString(configurationActivity); + settingsActivity = rule.getConfigurationActivity(); + } else { + if (ci == null) { + settingsActivity = null; + } else if (ci instanceof ActivityInfo) { + // new activity backed rule + settingsActivity = new ComponentName(ci.packageName, ci.name); + } else if (ci.metaData != null) { + // old service backed rule + final String configurationActivity = ci.metaData.getString( + ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY); + if (configurationActivity != null) { + settingsActivity = ComponentName.unflattenFromString(configurationActivity); + } } } - - return null; + if (settingsActivity == null || owner == null) { + return settingsActivity; + } + try { + int ownerUid = pm.getPackageUid(owner, 0); + int configActivityOwnerUid = pm.getPackageUid(settingsActivity.getPackageName(), 0); + if (ownerUid == configActivityOwnerUid) { + return settingsActivity; + } else { + Log.w(TAG, "Config activity not in owner package for " + rule.getName()); + return null; + } + } catch (PackageManager.NameNotFoundException e) { + Log.e(TAG, "Failed to find config activity"); + return null; + } } public class RuleNameChangeListener implements ZenRuleNameDialog.PositiveClickListener { diff --git a/src/com/android/settings/notification/zen/ZenRulePreference.java b/src/com/android/settings/notification/zen/ZenRulePreference.java index b8c8354eb3f..a265a0776d2 100644 --- a/src/com/android/settings/notification/zen/ZenRulePreference.java +++ b/src/com/android/settings/notification/zen/ZenRulePreference.java @@ -168,7 +168,7 @@ public class ZenRulePreference extends TwoTargetPreference { : isEvent ? ZenModeEventRuleSettings.ACTION : ""; ComponentInfo si = mServiceListing.findService(rule.getOwner()); ComponentName settingsActivity = AbstractZenModeAutomaticRulePreferenceController. - getSettingsActivity(rule, si); + getSettingsActivity(mPm, rule, si); mIntent = AbstractZenModeAutomaticRulePreferenceController.getRuleIntent(action, settingsActivity, mId); if (mIntent.resolveActivity(mPm) == null) { diff --git a/tests/robotests/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceControllerTest.java new file mode 100644 index 00000000000..ae6e1d0c9c6 --- /dev/null +++ b/tests/robotests/src/com/android/settings/notification/zen/AbstractZenModeAutomaticRulePreferenceControllerTest.java @@ -0,0 +1,169 @@ +/* + * 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.notification.zen; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Mockito.when; + +import android.app.AutomaticZenRule; +import android.app.NotificationManager; +import android.content.ComponentName; +import android.content.Context; +import android.content.pm.ComponentInfo; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Bundle; +import android.service.notification.ConditionProviderService; +import android.service.notification.ZenPolicy; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + +@RunWith(RobolectricTestRunner.class) +public class AbstractZenModeAutomaticRulePreferenceControllerTest { + + @Mock + private PackageManager mPm; + private Context mContext; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + mContext = RuntimeEnvironment.application; + } + + @Test + public void testGetSettingsActivity_configActivity() throws Exception { + AutomaticZenRule rule = new AutomaticZenRule("name", null, + new ComponentName(mContext.getPackageName(), "test"), Uri.EMPTY, + new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); + rule.setPackageName(mContext.getPackageName()); + + when(mPm.getPackageUid(null, 0)).thenReturn(-1); + when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1); + + ComponentName actual = AbstractZenModeAutomaticRulePreferenceController + .getSettingsActivity(mPm, rule, null); + + assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "test")); + } + + @Test + public void testGetSettingsActivity_configActivity_wrongPackage() throws Exception { + AutomaticZenRule rule = new AutomaticZenRule("name", null, + new ComponentName("another", "test"), Uri.EMPTY, + new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); + rule.setPackageName(mContext.getPackageName()); + + when(mPm.getPackageUid(null, 0)).thenReturn(-1); + when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1); + + ComponentName actual = AbstractZenModeAutomaticRulePreferenceController + .getSettingsActivity(mPm, rule, null); + + assertThat(actual).isNull(); + } + + @Test + public void testGetSettingsActivity_configActivity_unspecifiedOwner() throws Exception { + AutomaticZenRule rule = new AutomaticZenRule("name", null, + new ComponentName("another", "test"), Uri.EMPTY, + new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); + + when(mPm.getPackageUid(null, 0)).thenReturn(-1); + when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1); + + ComponentName actual = AbstractZenModeAutomaticRulePreferenceController + .getSettingsActivity(mPm, rule, null); + + assertThat(actual).isEqualTo(new ComponentName("another", "test")); + } + + @Test + public void testGetSettingsActivity_cps() throws Exception { + AutomaticZenRule rule = new AutomaticZenRule("name", + new ComponentName(mContext.getPackageName(), "service"), null, Uri.EMPTY, + new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); + rule.setPackageName(mContext.getPackageName()); + + ComponentInfo ci = new ComponentInfo(); + ci.packageName = mContext.getPackageName(); + ci.metaData = new Bundle(); + ci.metaData.putString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY, + ComponentName.flattenToShortString( + new ComponentName(mContext.getPackageName(), "activity"))); + + when(mPm.getPackageUid(null, 0)).thenReturn(-1); + when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1); + + ComponentName actual = AbstractZenModeAutomaticRulePreferenceController + .getSettingsActivity(mPm, rule, ci); + + assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "activity")); + } + + @Test + public void testGetSettingsActivity_cps_wrongPackage() throws Exception { + AutomaticZenRule rule = new AutomaticZenRule("name", + new ComponentName(mContext.getPackageName(), "service"), null, Uri.EMPTY, + new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); + rule.setPackageName("other"); + + ComponentInfo ci = new ComponentInfo(); + ci.packageName = mContext.getPackageName(); + ci.metaData = new Bundle(); + ci.metaData.putString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY, + ComponentName.flattenToShortString( + new ComponentName(mContext.getPackageName(), "activity"))); + + when(mPm.getPackageUid(null, 0)).thenReturn(-1); + when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1); + + ComponentName actual = AbstractZenModeAutomaticRulePreferenceController + .getSettingsActivity(mPm, rule, ci); + + assertThat(actual).isNull(); + } + + @Test + public void testGetSettingsActivity_cps_unspecifiedPackage() throws Exception { + AutomaticZenRule rule = new AutomaticZenRule("name", + new ComponentName(mContext.getPackageName(), "service"), null, Uri.EMPTY, + new ZenPolicy(), NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); + + ComponentInfo ci = new ComponentInfo(); + ci.packageName = mContext.getPackageName(); + ci.metaData = new Bundle(); + ci.metaData.putString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY, + ComponentName.flattenToShortString( + new ComponentName(mContext.getPackageName(), "activity"))); + + when(mPm.getPackageUid(null, 0)).thenReturn(-1); + when(mPm.getPackageUid(mContext.getPackageName(), 0)).thenReturn(1); + + ComponentName actual = AbstractZenModeAutomaticRulePreferenceController + .getSettingsActivity(mPm, rule, ci); + + assertThat(actual).isEqualTo(new ComponentName(mContext.getPackageName(), "activity")); + } +} \ No newline at end of file From 073addda549c336031c3376e15fa0c915e6f6ea2 Mon Sep 17 00:00:00 2001 From: Sunny Shao Date: Mon, 14 Jun 2021 10:03:16 +0800 Subject: [PATCH 09/15] Fix Learn more link placement is wrong problem - Use the new style of the FooterPreference. Fixes: 190951058 Test: manual test Change-Id: I33d30f00b3785f5195e38e3e26524dd93971d486 --- res/values/strings.xml | 2 +- res/xml/installed_app_launch_settings.xml | 1 - .../intentpicker/AppLaunchSettings.java | 23 +++++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 3b4fae4b944..5be20c65416 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10133,7 +10133,7 @@ Add link - An app can verify links to automatically open in the app. Learn more + An app can verify links to automatically open in the app. diff --git a/res/xml/installed_app_launch_settings.xml b/res/xml/installed_app_launch_settings.xml index 7d971b07d2b..3394d864ebe 100644 --- a/res/xml/installed_app_launch_settings.xml +++ b/res/xml/installed_app_launch_settings.xml @@ -63,7 +63,6 @@ diff --git a/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java b/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java index 439a6a31b40..43c377aff7b 100644 --- a/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java +++ b/src/com/android/settings/applications/intentpicker/AppLaunchSettings.java @@ -46,7 +46,6 @@ import com.android.settings.R; import com.android.settings.Utils; import com.android.settings.applications.AppInfoBase; import com.android.settings.applications.ClearDefaultsPreference; -import com.android.settings.utils.AnnotationSpan; import com.android.settings.widget.EntityHeaderController; import com.android.settingslib.applications.AppUtils; import com.android.settingslib.widget.FooterPreference; @@ -73,8 +72,6 @@ public class AppLaunchSettings extends AppInfoBase implements "open_by_default_selected_links_category"; private static final String OTHER_DETAILS_PREF_CATEGORY_KEY = "app_launch_other_defaults"; - // Url and Uri - private static final String ANNOTATION_URL = "url"; private static final String LEARN_MORE_URI = "https://developer.android.com/training/app-links/verify-site-associations"; @@ -356,16 +353,22 @@ public class AppLaunchSettings extends AppInfoBase implements } private void initFooter() { - // learn more - final AnnotationSpan.LinkInfo linkInfo = - new AnnotationSpan.LinkInfo(ANNOTATION_URL, v -> { - final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(LEARN_MORE_URI)); - mContext.startActivity(intent); - }); final CharSequence footerText = mContext.getText(R.string.app_launch_footer); final FooterPreference footerPreference = (FooterPreference) findPreference( FOOTER_PREF_KEY); - footerPreference.setTitle(AnnotationSpan.linkify(footerText, linkInfo)); + footerPreference.setTitle(footerText); + // learn more + footerPreference.setLearnMoreAction(view -> { + final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(LEARN_MORE_URI)); + mContext.startActivity(intent); + }); + final String learnMoreContentDescription = mContext.getString( + R.string.footer_learn_more_content_description, getLabelName()); + footerPreference.setLearnMoreContentDescription(learnMoreContentDescription); + } + + private String getLabelName() { + return mContext.getString(R.string.launch_by_default); } private boolean isClearDefaultsEnabled() { From a2402aba8338e4c8514ab79012be6687895c9b01 Mon Sep 17 00:00:00 2001 From: tom hsu Date: Tue, 15 Jun 2021 19:23:45 +0800 Subject: [PATCH 10/15] [Settings] Prevent crash from abnormal behavior. - The problem is user remove SIM when stop in ApnSettings page, and do unexpected operation. - To figure out this problem, listen SIM absent event and make activity finish at this moment. Bug: 189909956 Test: Manual test. Change-Id: I179c708debcbc31ba9a93e4e434ae810051f5004 --- .../settings/network/apn/ApnSettings.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/network/apn/ApnSettings.java b/src/com/android/settings/network/apn/ApnSettings.java index 02d9b3d1f35..4df2e5ee38c 100755 --- a/src/com/android/settings/network/apn/ApnSettings.java +++ b/src/com/android/settings/network/apn/ApnSettings.java @@ -88,6 +88,13 @@ public class ApnSettings extends RestrictedSettingsFragment Telephony.Carriers.EDITED_STATUS, }; + /** Copied from {@code com.android.internal.telephony.TelephonyIntents} */ + private static final String ACTION_SIM_STATE_CHANGED = + "android.intent.action.SIM_STATE_CHANGED"; + /** Copied from {@code com.android.internal.telephony.IccCardConstants} */ + public static final String INTENT_KEY_ICC_STATE = "ss"; + public static final String INTENT_VALUE_ICC_ABSENT = "ABSENT"; + private static final int ID_INDEX = 0; private static final int NAME_INDEX = 1; private static final int APN_INDEX = 2; @@ -151,7 +158,16 @@ public class ApnSettings extends RestrictedSettingsFragment private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals( + String action = intent.getAction(); + if (ACTION_SIM_STATE_CHANGED.equals(action) + && intent.getStringExtra(INTENT_KEY_ICC_STATE) + .equals(INTENT_VALUE_ICC_ABSENT)) { + final SubscriptionManager sm = context.getSystemService(SubscriptionManager.class); + if (sm != null && !sm.isActiveSubscriptionId(mSubId)) { + Log.d(TAG, "Due to SIM absent, closes APN settings page"); + finish(); + } + } else if (intent.getAction().equals( TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED)) { if (mRestoreDefaultApnMode) { return; @@ -201,8 +217,9 @@ public class ApnSettings extends RestrictedSettingsFragment mSubId = activity.getIntent().getIntExtra(SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID); mPhoneId = SubscriptionUtil.getPhoneId(activity, mSubId); - mIntentFilter = new IntentFilter( - TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED); + mIntentFilter = new IntentFilter(); + mIntentFilter.addAction(TelephonyManager.ACTION_SUBSCRIPTION_CARRIER_IDENTITY_CHANGED); + mIntentFilter.addAction(ACTION_SIM_STATE_CHANGED); setIfOnlyAvailableForAdmins(true); From 9837ce4a2402b5e659802016ee16508db6506541 Mon Sep 17 00:00:00 2001 From: Jason Chang Date: Thu, 17 Jun 2021 01:40:13 +0800 Subject: [PATCH 11/15] Fix One-handed mode Settings Main Switch does not update its state correctly Add Settings.Secure.ONE_HANDED_MODE_ENABLED key observer when its state changes. Bug: 191267388 Test: Manual verified on Settings > System > Gestures > Use One-handed mode. Test: make RunSettingsRoboTests ROBOTEST_FILTER= "com.android.settings.gestures .OneHandedMainSwitchPreferenceControllerTest" Change-Id: I264fda3a8ab0a76e6234199346b6720895b95cd6 --- ...eHandedMainSwitchPreferenceController.java | 41 ++++++++++++++++++- ...dedMainSwitchPreferenceControllerTest.java | 9 ++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceController.java b/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceController.java index 043588e8a39..2b7d7a0f307 100644 --- a/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceController.java +++ b/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceController.java @@ -17,17 +17,30 @@ package com.android.settings.gestures; import android.content.Context; +import android.net.Uri; + +import androidx.preference.PreferenceScreen; import com.android.settings.widget.SettingsMainSwitchPreferenceController; +import com.android.settingslib.core.lifecycle.LifecycleObserver; +import com.android.settingslib.core.lifecycle.events.OnStart; +import com.android.settingslib.core.lifecycle.events.OnStop; +import com.android.settingslib.widget.MainSwitchPreference; /** * The controller to handle one-handed mode main switch enable or disable state. **/ public class OneHandedMainSwitchPreferenceController extends - SettingsMainSwitchPreferenceController { + SettingsMainSwitchPreferenceController implements OneHandedSettingsUtils.TogglesCallback, + LifecycleObserver, OnStart, OnStop { + + private final OneHandedSettingsUtils mUtils; + + private MainSwitchPreference mPreference; public OneHandedMainSwitchPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); + mUtils = new OneHandedSettingsUtils(context); } @Override @@ -53,4 +66,30 @@ public class OneHandedMainSwitchPreferenceController extends OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, isChecked); return true; } + + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + mPreference = screen.findPreference(getPreferenceKey()); + } + + @Override + public void onStart() { + mUtils.registerToggleAwareObserver(this); + } + + @Override + public void onStop() { + mUtils.unregisterToggleAwareObserver(); + } + + @Override + public void onChange(Uri uri) { + if (mPreference == null) { + return; + } + if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)) { + mPreference.setChecked(isChecked()); + } + } } diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceControllerTest.java index 40cf795acd4..599d4e09142 100644 --- a/tests/robotests/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/gestures/OneHandedMainSwitchPreferenceControllerTest.java @@ -56,6 +56,15 @@ public class OneHandedMainSwitchPreferenceControllerTest { assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isTrue(); } + @Test + public void isChecked_setOneHandedModeEnabled_shouldReturnTrue() { + SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true"); + mUtils.setNavigationBarMode(mContext, "2" /* fully gestural */); + OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, true); + + assertThat(mController.isChecked()).isTrue(); + } + @Test public void getAvailabilityStatus_setSupportOneHandedModeProperty_shouldAvailable() { SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true"); From b684a8dbdfebe296a34b85c106da269c1913f65c Mon Sep 17 00:00:00 2001 From: Yi-Ling Chuang Date: Thu, 17 Jun 2021 17:26:43 +0800 Subject: [PATCH 12/15] Improve the animation while opening search Remove the exit transition on the homepage. Fixes: 189390497 Test: robotest and launch search seeing the y-axis transition Change-Id: Ia791757e0fef51eeefc7442e04369016a6200f84 --- .../homepage/SettingsHomepageActivity.java | 21 ------------------- .../SettingsHomepageActivityTest.java | 4 +--- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java index 5950e4b8ba1..75b2eaedf42 100644 --- a/src/com/android/settings/homepage/SettingsHomepageActivity.java +++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java @@ -18,14 +18,11 @@ package com.android.settings.homepage; import android.animation.LayoutTransition; import android.app.ActivityManager; -import android.app.ActivityOptions; import android.app.settings.SettingsEnums; -import android.content.Intent; import android.os.Bundle; import android.util.FeatureFlagUtils; import android.util.Log; import android.view.View; -import android.view.Window; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.Toolbar; @@ -36,13 +33,11 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; import com.android.settings.R; -import com.android.settings.Utils; import com.android.settings.accounts.AvatarViewMixin; import com.android.settings.core.FeatureFlags; import com.android.settings.homepage.contextualcards.ContextualCardsFragment; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin; -import com.android.settingslib.transition.SettingsTransitionHelper; public class SettingsHomepageActivity extends FragmentActivity { @@ -69,12 +64,6 @@ public class SettingsHomepageActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { - if (Utils.isPageTransitionEnabled(this)) { - // Enable Activity transitions - getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS); - SettingsTransitionHelper.applyForwardTransition(this); - SettingsTransitionHelper.applyBackwardTransition(this); - } super.onCreate(savedInstanceState); setContentView(R.layout.settings_homepage_container); @@ -107,16 +96,6 @@ public class SettingsHomepageActivity extends FragmentActivity { .getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING); } - @Override - public void startActivity(Intent intent) { - if (Utils.isPageTransitionEnabled(this)) { - final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle(); - super.startActivity(intent, bundle); - return; - } - super.startActivity(intent); - } - private void showSuggestionFragment() { final Class fragment = FeatureFactory.getFactory(this) .getSuggestionFeatureProvider(this).getContextualSuggestionFragment(); diff --git a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java index 9a4ad3c29f7..4d203a8a6b0 100644 --- a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java +++ b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java @@ -38,7 +38,6 @@ import com.android.settings.R; import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl; import com.android.settings.homepage.contextualcards.slices.BatteryFixSliceTest; import com.android.settings.testutils.shadow.ShadowUserManager; -import com.android.settings.testutils.shadow.ShadowUtils; import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin; import org.junit.Before; @@ -59,13 +58,12 @@ import org.robolectric.util.ReflectionHelpers; @RunWith(RobolectricTestRunner.class) @Config(shadows = {ShadowUserManager.class, - SettingsHomepageActivityTest.ShadowSuggestionFeatureProviderImpl.class, ShadowUtils.class}) + SettingsHomepageActivityTest.ShadowSuggestionFeatureProviderImpl.class}) public class SettingsHomepageActivityTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - ShadowUtils.setIsPageTransitionEnabled(false); } @Test From 22b50de9f46c050aabb2c191b26f2bc85f2bdfbc Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Wed, 16 Jun 2021 16:19:36 +0800 Subject: [PATCH 13/15] Add click tile event for tracking - Search bar in homepage. - Avatar icon in homepage. - More personal safety in Safety & emergency. Test: Rebuilt rom Fix: 190341976 Change-Id: I14297211e4b7424f5fdeb46c360b3913101251d7 --- src/com/android/settings/accounts/AvatarViewMixin.java | 9 +++------ .../emergency/MoreSettingsPreferenceController.java | 9 ++++++--- .../android/settings/search/SearchFeatureProvider.java | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/com/android/settings/accounts/AvatarViewMixin.java b/src/com/android/settings/accounts/AvatarViewMixin.java index c4ab55a46bf..7a2565c45b2 100644 --- a/src/com/android/settings/accounts/AvatarViewMixin.java +++ b/src/com/android/settings/accounts/AvatarViewMixin.java @@ -39,7 +39,6 @@ import androidx.lifecycle.OnLifecycleEvent; import com.android.settings.R; import com.android.settings.homepage.SettingsHomepageActivity; import com.android.settings.overlay.FeatureFactory; -import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.utils.ThreadUtils; import java.net.URISyntaxException; @@ -59,6 +58,7 @@ public class AvatarViewMixin implements LifecycleObserver { private static final String METHOD_GET_ACCOUNT_AVATAR = "getAccountAvatar"; private static final String KEY_AVATAR_BITMAP = "account_avatar"; private static final String KEY_ACCOUNT_NAME = "account_name"; + private static final String KEY_AVATAR_ICON = "avatar_icon"; private static final String EXTRA_ACCOUNT_NAME = "extra.accountName"; private final Context mContext; @@ -105,11 +105,8 @@ public class AvatarViewMixin implements LifecycleObserver { return; } - final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory( - mContext).getMetricsFeatureProvider(); - metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, - SettingsEnums.CLICK_ACCOUNT_AVATAR, SettingsEnums.SETTINGS_HOMEPAGE, - null /* key */, Integer.MIN_VALUE /* value */); + FeatureFactory.getFactory(mContext).getMetricsFeatureProvider() + .logSettingsTileClick(KEY_AVATAR_ICON, SettingsEnums.SETTINGS_HOMEPAGE); // Here may have two different UI while start the activity. // It will display adding account UI when device has no any account. diff --git a/src/com/android/settings/emergency/MoreSettingsPreferenceController.java b/src/com/android/settings/emergency/MoreSettingsPreferenceController.java index 3c9ae6ed106..cbb95a6357b 100644 --- a/src/com/android/settings/emergency/MoreSettingsPreferenceController.java +++ b/src/com/android/settings/emergency/MoreSettingsPreferenceController.java @@ -43,6 +43,7 @@ import androidx.preference.PreferenceScreen; import com.android.settings.R; import com.android.settings.Utils; import com.android.settings.core.BasePreferenceController; +import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.widget.LayoutPreference; import java.util.List; @@ -57,6 +58,7 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i private static final String TAG = "MoreSettingsPrefCtrl"; @VisibleForTesting Intent mIntent; + private LayoutPreference mPreference; public MoreSettingsPreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); @@ -82,8 +84,8 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); - final LayoutPreference pref = screen.findPreference(getPreferenceKey()); - final Button button = pref.findViewById(R.id.button); + mPreference = screen.findPreference(getPreferenceKey()); + final Button button = mPreference.findViewById(R.id.button); final Drawable icon = getIcon(); button.setText(getButtonText()); if (icon != null) { @@ -109,6 +111,8 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i @Override public void onClick(View v) { + FeatureFactory.getFactory(mContext).getMetricsFeatureProvider() + .logClickedPreference(mPreference, getMetricsCategory()); final Intent intent = new Intent(mIntent) .addCategory(Intent.CATEGORY_LAUNCHER) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); @@ -170,5 +174,4 @@ public class MoreSettingsPreferenceController extends BasePreferenceController i icon.draw(canvas); return bitmap; } - } diff --git a/src/com/android/settings/search/SearchFeatureProvider.java b/src/com/android/settings/search/SearchFeatureProvider.java index 18c802c2195..4c39b9c0c11 100644 --- a/src/com/android/settings/search/SearchFeatureProvider.java +++ b/src/com/android/settings/search/SearchFeatureProvider.java @@ -21,7 +21,6 @@ import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO; import android.annotation.NonNull; import android.app.Activity; import android.app.ActivityOptions; -import android.app.settings.SettingsEnums; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -43,6 +42,7 @@ import com.google.android.setupcompat.util.WizardManagerHelper; */ public interface SearchFeatureProvider { + String KEY_HOMEPAGE_SEARCH_BAR = "homepage_search_bar"; int REQUEST_CODE = 501; /** @@ -100,8 +100,9 @@ public interface SearchFeatureProvider { FeatureFactory.getFactory(context).getSlicesFeatureProvider() .indexSliceDataAsync(context); + FeatureFactory.getFactory(context).getMetricsFeatureProvider() - .action(context, SettingsEnums.ACTION_SEARCH_RESULTS); + .logSettingsTileClick(KEY_HOMEPAGE_SEARCH_BAR, pageId); final Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle(); activity.startActivityForResult(intent, REQUEST_CODE, bundle); }); From 1e8a907d9151a54c817ab0ef5b412399d24286f3 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Thu, 17 Jun 2021 17:39:41 +0800 Subject: [PATCH 14/15] Fix dialog color problem in night mode. Assign the suface light and dark color for Dialog. Test: Rebuilt apk, and see color works well on wifi dialog. Fix: 190142194 Change-Id: I43d010c70e22639a29a571bfadb4351f41e1a240 --- color-check-baseline.xml | 1138 +++++++++++++++++------------------ res/values-night/themes.xml | 3 +- res/values/themes.xml | 2 +- 3 files changed, 540 insertions(+), 603 deletions(-) diff --git a/color-check-baseline.xml b/color-check-baseline.xml index bb414ad25e5..ea8789a3a71 100644 --- a/color-check-baseline.xml +++ b/color-check-baseline.xml @@ -89,23 +89,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - @@ -133,8 +117,8 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="homepage_support_background">#3F5FBD</color>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="homepage_accessibility_background">#783BE5</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + - - - - + + + + @@ -249,7 +249,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -373,11 +373,11 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="settings_dialog_colorError">#f28b82</color> <!-- Red 300 -->" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="fingerprint_title_color">#ffffffff</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -389,11 +389,11 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="fingerprint_title_color">#ffffffff</color>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="settings_dialog_colorError">#f28b82</color> <!-- Red 300 -->" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -413,38 +413,6 @@ column="5"/> - - - - - - - - + errorLine1=" <color name="biometric_enroll_intro_color_bar">#5bb974</color>" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + + + + + @@ -1145,7 +1145,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1161,7 +1161,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1177,7 +1177,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1193,7 +1193,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1209,7 +1209,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1225,7 +1225,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1241,7 +1241,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1257,7 +1257,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1273,7 +1273,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1289,7 +1289,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1305,7 +1305,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1321,7 +1321,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1337,7 +1337,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1353,7 +1353,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1369,7 +1369,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1385,7 +1385,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1401,7 +1401,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1417,7 +1417,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1433,7 +1433,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1449,7 +1449,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1465,7 +1465,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1481,7 +1481,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1497,7 +1497,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1509,11 +1509,11 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" <color name="face_intro_outline">#ffdadce0</color>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" <color name="face_enroll_icon_color">#42a5f5</color> <!-- Blue 400 -->" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1529,7 +1529,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1545,7 +1545,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1561,7 +1561,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1577,7 +1577,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1593,7 +1593,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1609,7 +1609,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1625,7 +1625,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1641,7 +1641,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1657,7 +1657,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1673,7 +1673,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1689,7 +1689,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1705,7 +1705,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1721,7 +1721,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1737,7 +1737,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1753,7 +1753,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1769,7 +1769,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1785,7 +1785,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1801,7 +1801,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1817,7 +1817,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1833,7 +1833,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1849,7 +1849,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1865,7 +1865,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1881,7 +1881,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1897,7 +1897,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1913,7 +1913,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1929,7 +1929,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1945,7 +1945,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1961,7 +1961,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1977,7 +1977,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1993,7 +1993,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2009,7 +2009,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2025,7 +2025,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2041,7 +2041,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2057,7 +2057,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2073,7 +2073,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2181,235 +2181,235 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" android:fillColor="@color/biometric_enroll_intro_color_icon"" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + errorLine1=" android:tint="@color/face_enroll_icon_color">" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2517,222 +2517,14 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" android:fillColor="@color/biometric_enroll_intro_color_bar"" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" android:fillColor="@color/biometric_enroll_intro_color_outline"" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2757,11 +2549,123 @@ priority="4" summary="Using hardcoded color" explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes. This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app." - errorLine1=" android:fillColor="@color/biometric_enroll_intro_color_outline"" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + errorLine1=" android:strokeColor="@color/biometric_enroll_intro_color_icon"" + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3897,7 +3801,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -4121,7 +4025,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -4137,7 +4041,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -4153,7 +4057,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -4169,7 +4073,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -4185,7 +4089,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -4201,7 +4105,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -4217,7 +4121,7 @@ errorLine2=" ^"> @@ -4233,7 +4137,7 @@ errorLine2=" ^"> @@ -4249,7 +4153,7 @@ errorLine2=" ^"> @@ -4265,10 +4169,42 @@ errorLine2=" ^"> + + + + + + + + @@ -4297,7 +4233,7 @@ errorLine2=" ^"> @@ -4313,7 +4249,7 @@ errorLine2=" ^"> @@ -4329,7 +4265,7 @@ errorLine2=" ^"> @@ -4345,7 +4281,7 @@ errorLine2=" ^"> @@ -4361,7 +4297,7 @@ errorLine2=" ^"> @@ -4377,7 +4313,7 @@ errorLine2=" ^"> @@ -4393,7 +4329,7 @@ errorLine2=" ^"> diff --git a/res/values-night/themes.xml b/res/values-night/themes.xml index 9faaede1785..b95a5a0f87f 100644 --- a/res/values-night/themes.xml +++ b/res/values-night/themes.xml @@ -32,7 +32,8 @@ diff --git a/res/values/themes.xml b/res/values/themes.xml index 4c5cdb7291f..8e0f45944ef 100644 --- a/res/values/themes.xml +++ b/res/values/themes.xml @@ -130,7 +130,7 @@