From b4e96b1223122862c742e18d0444c5069a2c90e6 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Mon, 28 Jun 2021 15:13:14 +0800 Subject: [PATCH 01/15] Fix ManageApplications pinned header overlaps content A best UX is to hide pinned header when scrolling up and show pinned header when scrolling down. It needs CoordinatorLayout and CoordinatorLayout.Behavior to control the expected UX. However, we have an outer CoordinatorLayout in CollapsingToolbarBaseActivity, if we use CoordinatorLayout here, the inner one will not pass scroll value to its parent. We will have no overscroll effect problem and tool bar no collapsed problem. This workaround draw pinned header at last and assign background color to cover content. Bug: 187376670 Test: manual visual Settings -> Notifications -> App Settings Settings > Apps > all apps Change-Id: I217fba917d11f63d954369c18e0361112ff981fe --- res/layout/manage_applications_apps.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml index 7ea88038734..f8f4a76b11a 100644 --- a/res/layout/manage_applications_apps.xml +++ b/res/layout/manage_applications_apps.xml @@ -20,13 +20,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + + From f01c5cfa8ebef383e5a6ac9f0130a61599726c6e Mon Sep 17 00:00:00 2001 From: "Wesley.CW Wang" Date: Tue, 29 Jun 2021 14:01:51 +0800 Subject: [PATCH 02/15] Update high usage tips string Bug: 183689347 Test: make SettingsRoboTests Change-Id: Id38c9a7e10827dcf72a0f5016723f51c8f119a98 --- res/values/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 26fbd795575..23c020ad8c0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6155,11 +6155,11 @@ 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: + Because you’ve used your phone more than usual, your battery may run out sooner than it normally would.\n\nApps using most battery: - Your tablet has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage: + Because you’ve used your tablet more than usual, your battery may run out sooner than it normally would.\n\nApps using most battery: - Your device has been used more than usual. Your battery may run out sooner than expected.\n\nTop apps by battery usage: + Because you’ve used your device more than usual, your battery may run out sooner than it normally would.\n\nApps using most battery: Includes high-power background activity From c38978f3e14490d1a87f40b03445b4b2f4db8a18 Mon Sep 17 00:00:00 2001 From: Jason Chiu Date: Tue, 29 Jun 2021 21:10:32 +0800 Subject: [PATCH 03/15] Guard against the exceptions when launching a non-existing fragment Test: robotest Bug: 190371550 Change-Id: I2bb7d4bdb23756634526db7e272563a1587c9640 --- src/com/android/settings/SettingsActivity.java | 6 ++++-- src/com/android/settings/Utils.java | 18 +++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index 12f63ea226f..f3cdd6c1640 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -574,7 +574,7 @@ public class SettingsActivity extends SettingsBaseActivity /** * Switch to a specific Fragment with taking care of validation, Title and BackStack */ - private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate, + private void switchToFragment(String fragmentName, Bundle args, boolean validate, int titleResId, CharSequence title) { Log.d(LOG_TAG, "Switching to fragment " + fragmentName); if (validate && !isValidFragment(fragmentName)) { @@ -582,6 +582,9 @@ public class SettingsActivity extends SettingsBaseActivity + fragmentName); } Fragment f = Utils.getTargetFragment(this, fragmentName, args); + if (f == null) { + return; + } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.main_content, f); if (titleResId > 0) { @@ -592,7 +595,6 @@ public class SettingsActivity extends SettingsBaseActivity transaction.commitAllowingStateLoss(); getSupportFragmentManager().executePendingTransactions(); Log.d(LOG_TAG, "Executed frag manager pendingTransactions"); - return f; } private void updateTilesList() { diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index 708dbeddecd..e79852bf7ef 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -1158,13 +1158,17 @@ public final class Utils extends com.android.settingslib.Utils { == ProfileSelectFragment.ProfileType.PERSONAL : false; final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE) == ProfileSelectFragment.ProfileType.WORK : false; - if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1 - && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null - && !isWork && !isPersonal) { - f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName), - args); - } else { - f = Fragment.instantiate(activity, fragmentName, args); + try { + if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1 + && ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null + && !isWork && !isPersonal) { + f = Fragment.instantiate(activity, + ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName), args); + } else { + f = Fragment.instantiate(activity, fragmentName, args); + } + } catch (Exception e) { + Log.e(TAG, "Unable to get target fragment", e); } return f; } From 0ad478316372a8a5cadd6fd4b1ce437e3139d012 Mon Sep 17 00:00:00 2001 From: Alex Johnston Date: Wed, 30 Jun 2021 14:36:23 +0000 Subject: [PATCH 04/15] Fix Settings usb preference search * Invert isPageSearchEnabled check Bug: 192449168 Test: manual testing with TestDPC Change-Id: I91dcf930485ad16a83cb04bf170c9608c1768ea2 --- .../settings/connecteddevice/usb/UsbDetailsFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java index 8d14cf9f8c3..8850acd4b35 100644 --- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java +++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java @@ -107,7 +107,7 @@ public class UsbDetailsFragment extends DashboardFragment { @Override protected boolean isPageSearchEnabled(Context context) { return checkIfUsbDataSignalingIsDisabled( - context, UserHandle.myUserId()) != null; + context, UserHandle.myUserId()) == null; } @Override From c17876365aa0e035c506fa3eccf5589b78901300 Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Wed, 30 Jun 2021 20:56:48 +0000 Subject: [PATCH 05/15] Revert "Revert "Return enrollment consent status to caller."" This reverts commit c358adad5680d3a8416969e7c739195d995ee5da. Reason for revert: Applying original change with additional change for single sensor devices. Bug: 192420564 Bug: 188847063 Test: manual enroll face & fingerprint via setup wizard (on fp, face, & fp+face device variants) Change-Id: Idfaaa2b6f4611056f9999325bac8401e28a7510b --- .../biometrics/BiometricEnrollActivity.java | 128 ++++++++++-------- .../MultiBiometricEnrollHelper.java | 8 -- .../biometrics/ParentalConsentHelper.java | 2 + 3 files changed, 75 insertions(+), 63 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java index db5e003456a..3b8f25507e9 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java +++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java @@ -71,6 +71,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { private static final int REQUEST_CHOOSE_OPTIONS = 3; // prompt hand phone back to parent after enrollment private static final int REQUEST_HANDOFF_PARENT = 4; + private static final int REQUEST_SINGLE_ENROLL = 5; public static final int RESULT_SKIP = BiometricEnrollBase.RESULT_SKIP; @@ -78,8 +79,13 @@ public class BiometricEnrollActivity extends InstrumentedActivity { // this only applies to fingerprint. public static final String EXTRA_SKIP_INTRO = "skip_intro"; - // TODO: temporary while waiting for team to add real flag - public static final String EXTRA_TEMP_REQUIRE_PARENTAL_CONSENT = "require_consent"; + // Intent extra. If true, parental consent will be requested before user enrollment. + public static final String EXTRA_REQUIRE_PARENTAL_CONSENT = "require_consent"; + + // If EXTRA_REQUIRE_PARENTAL_CONSENT was used to start the activity then the result + // intent will include this extra containing a bundle of the form: + // "modality" -> consented (boolean). + public static final String EXTRA_PARENTAL_CONSENT_STATUS = "consent_status"; private static final String SAVED_STATE_CONFIRMING_CREDENTIALS = "confirming_credentials"; private static final String SAVED_STATE_ENROLL_ACTION_LOGGED = "enroll_action_logged"; @@ -189,7 +195,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { // TODO(b/188847063): replace with real flag when ready mParentalOptionsRequired = intent.getBooleanExtra( - BiometricEnrollActivity.EXTRA_TEMP_REQUIRE_PARENTAL_CONSENT, false); + BiometricEnrollActivity.EXTRA_REQUIRE_PARENTAL_CONSENT, false); if (mParentalOptionsRequired && mParentalOptions == null) { mParentalConsentHelper = new ParentalConsentHelper( @@ -201,19 +207,6 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } private void startEnroll() { - // TODO(b/188847063): This can be deleted, but log it now until it's wired up for real. - if (mParentalOptionsRequired) { - if (mParentalOptions == null) { - throw new IllegalStateException("consent options required, but not set"); - } - Log.d(TAG, "consent for face: " - + ParentalConsentHelper.hasFaceConsent(mParentalOptions)); - Log.d(TAG, "consent for fingerprint: " - + ParentalConsentHelper.hasFingerprintConsent(mParentalOptions)); - } else { - Log.d(TAG, "startEnroll without requiring consent"); - } - // Default behavior is to enroll BIOMETRIC_WEAK or above. See ACTION_BIOMETRIC_ENROLL. final int authenticators = getIntent().getIntExtra( EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK); @@ -234,21 +227,38 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } } + boolean canUseFace = mHasFeatureFace; + boolean canUseFingerprint = mHasFeatureFingerprint; + if (mParentalOptionsRequired) { + if (mParentalOptions == null) { + throw new IllegalStateException("consent options required, but not set"); + } + canUseFace = canUseFace + && ParentalConsentHelper.hasFaceConsent(mParentalOptions); + canUseFingerprint = canUseFingerprint + && ParentalConsentHelper.hasFingerprintConsent(mParentalOptions); + } + // This will need to be updated if the device has sensors other than BIOMETRIC_STRONG if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) { launchCredentialOnlyEnroll(); - } else if (mHasFeatureFace && mHasFeatureFingerprint) { + } else if (canUseFace && canUseFingerprint) { if (mParentalOptionsRequired && mGkPwHandle != null) { launchFaceAndFingerprintEnroll(); } else { setOrConfirmCredentialsNow(); } - } else if (mHasFeatureFingerprint) { + } else if (canUseFingerprint) { launchFingerprintOnlyEnroll(); - } else if (mHasFeatureFace) { + } else if (canUseFace) { launchFaceOnlyEnroll(); - } else { - Log.e(TAG, "Unknown state, finishing (was SUW: " + setupWizard + ")"); + } else { // no modalities available + if (mParentalOptionsRequired) { + Log.d(TAG, "No consent for any modality: skipping enrollment"); + setResult(RESULT_OK, newResultIntent()); + } else { + Log.e(TAG, "Unknown state, finishing (was SUW: " + setupWizard + ")"); + } finish(); } } @@ -275,7 +285,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { if (mParentalConsentHelper != null) { handleOnActivityResultWhileConsenting(requestCode, resultCode, data); } else { - handleOnActivityResultWhileEnrollingMultiple(requestCode, resultCode, data); + handleOnActivityResultWhileEnrolling(requestCode, resultCode, data); } } @@ -305,8 +315,10 @@ public class BiometricEnrollActivity extends InstrumentedActivity { final boolean isStillPrompting = mParentalConsentHelper.launchNext( this, REQUEST_CHOOSE_OPTIONS, resultCode, data); if (!isStillPrompting) { - Log.d(TAG, "Enrollment options set, requesting handoff"); - launchHandoffToParent(); + Log.d(TAG, "Enrollment consent options set, starting enrollment"); + mParentalOptions = mParentalConsentHelper.getConsentResult(); + mParentalConsentHelper = null; + startEnroll(); } } else { Log.d(TAG, "Unknown or cancelled parental consent"); @@ -314,18 +326,6 @@ public class BiometricEnrollActivity extends InstrumentedActivity { finish(); } break; - case REQUEST_HANDOFF_PARENT: - if (resultCode == RESULT_OK) { - Log.d(TAG, "Enrollment options set, starting enrollment"); - mParentalOptions = mParentalConsentHelper.getConsentResult(); - mParentalConsentHelper = null; - startEnroll(); - } else { - Log.d(TAG, "Unknown or cancelled handoff"); - setResult(RESULT_CANCELED); - finish(); - } - break; default: Log.w(TAG, "Unknown consenting requestCode: " + requestCode + ", finishing"); finish(); @@ -333,9 +333,13 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } // handles responses while multi biometric enrollment is pending - private void handleOnActivityResultWhileEnrollingMultiple( + private void handleOnActivityResultWhileEnrolling( int requestCode, int resultCode, Intent data) { - if (mMultiBiometricEnrollHelper == null) { + if (requestCode == REQUEST_HANDOFF_PARENT) { + Log.d(TAG, "Enrollment complete, requesting handoff, result: " + resultCode); + setResult(RESULT_OK, newResultIntent()); + finish(); + } else if (mMultiBiometricEnrollHelper == null) { overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); switch (requestCode) { @@ -355,15 +359,37 @@ public class BiometricEnrollActivity extends InstrumentedActivity { finish(); } break; + case REQUEST_SINGLE_ENROLL: + finishOrLaunchHandToParent(resultCode); + break; default: Log.w(TAG, "Unknown enrolling requestCode: " + requestCode + ", finishing"); finish(); } } else { - mMultiBiometricEnrollHelper.onActivityResult(requestCode, resultCode, data); + Log.d(TAG, "RequestCode: " + requestCode + " resultCode: " + resultCode); + BiometricUtils.removeGatekeeperPasswordHandle(this, mGkPwHandle); + finishOrLaunchHandToParent(resultCode); } } + private void finishOrLaunchHandToParent(int resultCode) { + if (mParentalOptionsRequired) { + launchHandoffToParent(); + } else { + setResult(resultCode); + finish(); + } + } + + private Intent newResultIntent() { + final Intent intent = new Intent(); + final Bundle consentStatus = mParentalOptions.deepCopy(); + intent.putExtra(EXTRA_PARENTAL_CONSENT_STATUS, consentStatus); + Log.v(TAG, "Result consent status: " + consentStatus); + return intent; + } + private static boolean isSuccessfulConfirmOrChooseCredential(int requestCode, int resultCode) { final boolean okChoose = requestCode == REQUEST_CHOOSE_LOCK && resultCode == ChooseLockPattern.RESULT_FINISHED; @@ -384,8 +410,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity { super.onStop(); if (mConfirmingCredentials - || mMultiBiometricEnrollHelper != null - || mParentalConsentHelper != null) { + || mParentalOptionsRequired + || mMultiBiometricEnrollHelper != null) { return; } @@ -395,7 +421,6 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } } - private void setOrConfirmCredentialsNow() { if (!mConfirmingCredentials) { mConfirmingCredentials = true; @@ -454,21 +479,14 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } } - /** - * This should only be used to launch enrollment for single-sensor devices, which use - * FLAG_ACTIVITY_FORWARD_RESULT path. - * - * @param intent Enrollment activity that should be started (e.g. FaceEnrollIntroduction.class, - * etc). - */ - private void launchSingleSensorEnrollActivity(@NonNull Intent intent) { - intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); + // This should only be used to launch enrollment for single-sensor devices. + private void launchSingleSensorEnrollActivity(@NonNull Intent intent, int requestCode) { byte[] hardwareAuthToken = null; if (this instanceof InternalActivity) { hardwareAuthToken = getIntent().getByteArrayExtra( ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN); } - BiometricUtils.launchEnrollForResult(this, intent, 0 /* requestCode */, hardwareAuthToken, + BiometricUtils.launchEnrollForResult(this, intent, requestCode, hardwareAuthToken, mGkPwHandle, mUserId); } @@ -477,7 +495,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { // If only device credential was specified, ask the user to only set that up. intent = new Intent(this, ChooseLockGeneric.class); intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true); - launchSingleSensorEnrollActivity(intent); + launchSingleSensorEnrollActivity(intent, 0 /* requestCode */); } private void launchFingerprintOnlyEnroll() { @@ -489,12 +507,12 @@ public class BiometricEnrollActivity extends InstrumentedActivity { } else { intent = BiometricUtils.getFingerprintIntroIntent(this, getIntent()); } - launchSingleSensorEnrollActivity(intent); + launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL); } private void launchFaceOnlyEnroll() { final Intent intent = BiometricUtils.getFaceIntroIntent(this, getIntent()); - launchSingleSensorEnrollActivity(intent); + launchSingleSensorEnrollActivity(intent, REQUEST_SINGLE_ENROLL); } private void launchFaceAndFingerprintEnroll() { diff --git a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java index 74d7c535e05..44d75c5808d 100644 --- a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java +++ b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java @@ -20,7 +20,6 @@ import android.app.PendingIntent; import android.content.Intent; import android.hardware.face.FaceManager; import android.hardware.fingerprint.FingerprintManager; -import android.util.Log; import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; @@ -107,11 +106,4 @@ public class MultiBiometricEnrollHelper { hardwareAuthToken, mGkPwHandle, mUserId); })); } - - void onActivityResult(int requestCode, int resultCode, Intent data) { - Log.d(TAG, "RequestCode: " + requestCode + " resultCode: " + resultCode); - BiometricUtils.removeGatekeeperPasswordHandle(mActivity, mGkPwHandle); - mActivity.setResult(resultCode); - mActivity.finish(); - } } diff --git a/src/com/android/settings/biometrics/ParentalConsentHelper.java b/src/com/android/settings/biometrics/ParentalConsentHelper.java index 905a95527ef..6c4004e5c55 100644 --- a/src/com/android/settings/biometrics/ParentalConsentHelper.java +++ b/src/com/android/settings/biometrics/ParentalConsentHelper.java @@ -46,6 +46,7 @@ public class ParentalConsentHelper { private static final String KEY_FACE_CONSENT = "face"; private static final String KEY_FINGERPRINT_CONSENT = "fingerprint"; + private static final String KEY_IRIS_CONSENT = "iris"; private final boolean mRequireFace; private final boolean mRequireFingerprint; @@ -153,6 +154,7 @@ public class ParentalConsentHelper { result.putBoolean(KEY_FACE_CONSENT, mConsentFace != null ? mConsentFace : false); result.putBoolean(KEY_FINGERPRINT_CONSENT, mConsentFingerprint != null ? mConsentFingerprint : false); + result.putBoolean(KEY_IRIS_CONSENT, false); return result; } From 47e8ddbdb9cd73fc103fa59d5be974eebdf0b7bd Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Wed, 30 Jun 2021 14:09:44 -0700 Subject: [PATCH 06/15] Prevent finishing early on single sensor devices. Fixes regression from commit c358adad5680d3a8416969e7c739195d995ee5da. Fix: 192420564 Fix: 188847063 Test: manual enroll face & fingerprint via setup wizard (on fp, face, & fp+face device variants) Change-Id: If7027e4d0ddf9d73daf91f174f237e4eb1621ea7 --- .../biometrics/BiometricEnrollActivity.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java index 3b8f25507e9..26d8a45c5c9 100644 --- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java +++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java @@ -242,6 +242,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity { // This will need to be updated if the device has sensors other than BIOMETRIC_STRONG if (!setupWizard && authenticators == BiometricManager.Authenticators.DEVICE_CREDENTIAL) { launchCredentialOnlyEnroll(); + finish(); } else if (canUseFace && canUseFingerprint) { if (mParentalOptionsRequired && mGkPwHandle != null) { launchFaceAndFingerprintEnroll(); @@ -405,22 +406,6 @@ public class BiometricEnrollActivity extends InstrumentedActivity { super.onApplyThemeResource(theme, newResid, first); } - @Override - protected void onStop() { - super.onStop(); - - if (mConfirmingCredentials - || mParentalOptionsRequired - || mMultiBiometricEnrollHelper != null) { - return; - } - - if (!isChangingConfigurations()) { - Log.d(TAG, "Finishing in onStop"); - finish(); - } - } - private void setOrConfirmCredentialsNow() { if (!mConfirmingCredentials) { mConfirmingCredentials = true; From a8456b4aa95f0c0d059467164d686c9afde3a00b Mon Sep 17 00:00:00 2001 From: tom hsu Date: Wed, 30 Jun 2021 18:17:40 +0800 Subject: [PATCH 07/15] [Settings] Make UI be able to update current status, after SIM absent. - The cache of default data subscription id does not update when SIM absent. Therefore, uses getActiveSubscriptionIdList instead current to make it more precise. Bug: 192032602 Test: Manual test. see b/192032602#7 Change-Id: I29e697e97d32ecb2e93c9620ec65215f963e4ebe --- src/com/android/settings/network/ProviderModelSliceHelper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/android/settings/network/ProviderModelSliceHelper.java b/src/com/android/settings/network/ProviderModelSliceHelper.java index 16d5c924552..6ecaae50aea 100644 --- a/src/com/android/settings/network/ProviderModelSliceHelper.java +++ b/src/com/android/settings/network/ProviderModelSliceHelper.java @@ -80,8 +80,7 @@ public class ProviderModelSliceHelper { public boolean hasCarrier() { if (isAirplaneModeEnabled() || mSubscriptionManager == null || mTelephonyManager == null - || mSubscriptionManager.getDefaultDataSubscriptionId() - == mSubscriptionManager.INVALID_SUBSCRIPTION_ID) { + || mSubscriptionManager.getActiveSubscriptionIdList().length <= 0) { return false; } return true; From b453e44bf85516cda83e8798ce63a4df5a4c2642 Mon Sep 17 00:00:00 2001 From: changbetty Date: Thu, 1 Jul 2021 14:57:52 +0800 Subject: [PATCH 08/15] Add Adaptive Connectivity switch on/off string for fixing string gender Bug: 189234188 Test: Manual test Change-Id: I8a3df2a0f4b364e4bc31e0efd116312b5fdf3b42 --- res/values/strings.xml | 4 ++++ .../network/AdaptiveConnectivityPreferenceController.java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 26fbd795575..25f4a25f2ef 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6788,6 +6788,10 @@ Adaptive connectivity Extends battery life and improves device performance by automatically managing your network connections + + On + + Off Credential storage diff --git a/src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java b/src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java index 33d1d5b66cd..a938515b3e2 100644 --- a/src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java +++ b/src/com/android/settings/network/AdaptiveConnectivityPreferenceController.java @@ -48,7 +48,7 @@ public class AdaptiveConnectivityPreferenceController extends BasePreferenceCont public CharSequence getSummary() { return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.ADAPTIVE_CONNECTIVITY_ENABLED, 1) == 1 - ? mContext.getString(R.string.switch_on_text) - : mContext.getString(R.string.switch_off_text); + ? mContext.getString(R.string.adaptive_connectivity_switch_on) + : mContext.getString(R.string.adaptive_connectivity_switch_off); } } From a460e4f8904113380e24b4e45e096e451616ef44 Mon Sep 17 00:00:00 2001 From: Jason Chiu Date: Tue, 29 Jun 2021 19:52:02 +0800 Subject: [PATCH 09/15] Update title and subtext of Contact search in Work profile settings Test: visual Bug: 184610902 Change-Id: I5391ce3c1dc4aef6ec9e840f382d74a6a399e562 --- 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 26fbd795575..8a28329a33e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11585,10 +11585,10 @@ Work profile settings - - Contact search - - Allow contact searches by your organization to identify callers and contacts + + Let personal apps identify contacts using work directory + + Searches and incoming calls may be visible to your IT admin Cross-profile calendar From 15ca9a632fc00f4d106dab59230495d9e029c2f4 Mon Sep 17 00:00:00 2001 From: "Wesley.CW Wang" Date: Wed, 30 Jun 2021 21:35:55 +0800 Subject: [PATCH 10/15] Update filter logic for BatteryDiffEntries - Use user id and package name to query the battery entry list instead of uid, to handle the cases which enter app info page without uid like launch icon -> app info Bug: 178197718 Test: make SettingsRoboTests Change-Id: I665e57ff3eabf23485455fb2e1af2e0376af1e40 --- .../AppBatteryPreferenceController.java | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java index 89c3478b4ef..f0285bc4a46 100644 --- a/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java +++ b/src/com/android/settings/applications/appinfo/AppBatteryPreferenceController.java @@ -78,6 +78,7 @@ public class AppBatteryPreferenceController extends BasePreferenceController private String mBatteryPercent; private final String mPackageName; private final int mUid; + private final int mUserId; private boolean mBatteryUsageStatsLoaded = false; private boolean mBatteryDiffEntriesLoaded = false; @@ -88,6 +89,7 @@ public class AppBatteryPreferenceController extends BasePreferenceController mBatteryUtils = BatteryUtils.getInstance(mContext); mPackageName = packageName; mUid = uid; + mUserId = mContext.getUserId(); refreshFeatureFlag(mContext); if (lifecycle != null) { lifecycle.addObserver(this); @@ -173,16 +175,29 @@ public class AppBatteryPreferenceController extends BasePreferenceController protected BatteryDiffEntry doInBackground(Void... unused) { final List batteryDiffEntries = BatteryChartPreferenceController.getBatteryLast24HrUsageData(mContext); - if (batteryDiffEntries != null) { - for (BatteryDiffEntry batteryDiffEntry : batteryDiffEntries) { - if (batteryDiffEntry.mBatteryHistEntry.mUid == mUid - && batteryDiffEntry.mBatteryHistEntry.mConsumerType - == ConvertUtils.CONSUMER_TYPE_UID_BATTERY) { - return batteryDiffEntry; - } - } + if (batteryDiffEntries == null) { + return null; } - return null; + // Filter entry with consumer type to avoid system app, + // then use user id to divide normal app and work profile app, + // return target application from filter list by package name. + return batteryDiffEntries.stream() + .filter(entry -> entry.mBatteryHistEntry.mConsumerType + == ConvertUtils.CONSUMER_TYPE_UID_BATTERY) + .filter(entry -> entry.mBatteryHistEntry.mUserId == mUserId) + .filter(entry -> { + if (entry.mBatteryHistEntry.mPackageName + .equals(mPackageName)) { + Log.i(TAG, "Return target application: " + + entry.mBatteryHistEntry.mPackageName + + " | uid: " + entry.mBatteryHistEntry.mUid + + " | userId: " + entry.mBatteryHistEntry.mUserId); + return true; + } + return false; + }) + .findFirst() + .orElse(/* other */null); } @Override From d9a4197d9d3aad1881ba856782a6554a6a115281 Mon Sep 17 00:00:00 2001 From: Jason Chang Date: Sun, 27 Jun 2021 20:49:02 +0800 Subject: [PATCH 11/15] Change One-handed mode controls states in the Settings pages for improving better UX experience MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to UX feedback to adjust One-handed mode UI controls’ status in the Settings page for better UX experience. Bug: 192171369 Test: manual verified on Settings > System > Gesture page > System controls page Test: make RunSettingsRoboTests ROBOTEST_FILTER= "com.android.settings.gestures .OneHandedEnablePreferenceControllerTest" Test: make RunSettingsRoboTests ROBOTEST_FILTER= "com.android.settings.gestures .OneHandedMainSwitchPreferenceControllerTest" Test: make RunSettingsRoboTests ROBOTEST_FILTER= "com.android.settings.gestures .OneHandedActionPullDownPrefControllerTest" Test: make RunSettingsRoboTests ROBOTEST_FILTER= "com.android.settings.gestures .OneHandedActionShowNotificationPrefControllerTest" Test: make RunSettingsRoboTests ROBOTEST_FILTER= "com.android.settings.gestures .OneHandedPreferenceCategoryControllerTest" Change-Id: I76242fe70c3ec06cd5e2f9bb059c87293cc686dd --- res/values/arrays.xml | 8 -- res/values/strings.xml | 17 +--- res/xml/one_handed_settings.xml | 4 +- ...OneHandedActionPullDownPrefController.java | 3 +- ...dActionShowNotificationPrefController.java | 3 +- .../OneHandedEnablePreferenceController.java | 4 - ...OneHandedPreferenceCategoryController.java | 52 ++++++++++++ .../gestures/OneHandedSettingsUtils.java | 34 +++++++- ...andedActionPullDownPrefControllerTest.java | 22 +++++ ...ionShowNotificationPrefControllerTest.java | 22 +++++ ...andedPreferenceCategoryControllerTest.java | 81 +++++++++++++++++++ 11 files changed, 217 insertions(+), 33 deletions(-) create mode 100644 src/com/android/settings/gestures/OneHandedPreferenceCategoryController.java create mode 100644 tests/robotests/src/com/android/settings/gestures/OneHandedPreferenceCategoryControllerTest.java diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 00577cd5739..34506658c45 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -1575,14 +1575,6 @@ @string/rtt_settings_always_visible - - - @string/screensaver_settings_summary_never - @string/one_handed_timeout_short - @string/one_handed_timeout_medium - @string/one_handed_timeout_long - - 0 diff --git a/res/values/strings.xml b/res/values/strings.xml index ef0a0517584..45f01bf8da1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -11721,29 +11721,16 @@ Double-tap to check device - - Swipe for notifications - - Swipe down on the bottom edge of the screen to show your notifications.\nYou can\'t use one-handed mode when this feature is turned on. - One-handed mode Use one-handed mode - - Exit when switching apps - - Timeout - - 4 seconds - - 8 seconds - - 12 seconds reachability Swipe down to + + Use the shortcut to To use one handed mode, swipe down from the bottom edge of the screen. To use this feature, make sure gesture navigation is turned on in system navigation settings. diff --git a/res/xml/one_handed_settings.xml b/res/xml/one_handed_settings.xml index 8893e1eda21..2f5c091bdf0 100644 --- a/res/xml/one_handed_settings.xml +++ b/res/xml/one_handed_settings.xml @@ -39,7 +39,8 @@ + android:title="@string/one_handed_mode_swipe_down_category" + settings:controller="com.android.settings.gestures.OneHandedPreferenceCategoryController"> - diff --git a/src/com/android/settings/gestures/OneHandedActionPullDownPrefController.java b/src/com/android/settings/gestures/OneHandedActionPullDownPrefController.java index 84ea8b6c457..e17165b1856 100644 --- a/src/com/android/settings/gestures/OneHandedActionPullDownPrefController.java +++ b/src/com/android/settings/gestures/OneHandedActionPullDownPrefController.java @@ -92,7 +92,8 @@ public class OneHandedActionPullDownPrefController extends BasePreferenceControl if (mPreference == null) { return; } - if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)) { + if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI) + || uri.equals(OneHandedSettingsUtils.SHORTCUT_ENABLED_URI)) { mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext)); } else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) { updateState(mPreference); diff --git a/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefController.java b/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefController.java index 564429986e1..9f56a14afd6 100644 --- a/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefController.java +++ b/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefController.java @@ -92,7 +92,8 @@ public class OneHandedActionShowNotificationPrefController extends BasePreferenc if (mPreference == null) { return; } - if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)) { + if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI) + || uri.equals(OneHandedSettingsUtils.SHORTCUT_ENABLED_URI)) { mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext)); } else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) { updateState(mPreference); diff --git a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java index bd8de9fdada..29004c8f1fd 100644 --- a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java +++ b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java @@ -17,7 +17,6 @@ package com.android.settings.gestures; import android.content.Context; -import android.provider.Settings; import com.android.settings.R; import com.android.settings.core.BasePreferenceController; @@ -27,8 +26,6 @@ import com.android.settings.core.BasePreferenceController; */ public class OneHandedEnablePreferenceController extends BasePreferenceController { - private static final String ONE_HANDED_ENABLED = Settings.Secure.ONE_HANDED_MODE_ENABLED; - public OneHandedEnablePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); } @@ -44,5 +41,4 @@ public class OneHandedEnablePreferenceController extends BasePreferenceControlle OneHandedSettingsUtils.isOneHandedModeEnabled(mContext) ? R.string.gesture_setting_on : R.string.gesture_setting_off); } - } diff --git a/src/com/android/settings/gestures/OneHandedPreferenceCategoryController.java b/src/com/android/settings/gestures/OneHandedPreferenceCategoryController.java new file mode 100644 index 00000000000..9623299343c --- /dev/null +++ b/src/com/android/settings/gestures/OneHandedPreferenceCategoryController.java @@ -0,0 +1,52 @@ +/* + * 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.gestures; + +import android.content.Context; + +import androidx.preference.Preference; +import androidx.preference.PreferenceScreen; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; + +/** + * Category Preference controller for One-handed mode category + */ +public class OneHandedPreferenceCategoryController extends BasePreferenceController { + + private Preference mPreference; + + public OneHandedPreferenceCategoryController(Context context, String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public int getAvailabilityStatus() { + return AVAILABLE; + } + + @Override + public void displayPreference(PreferenceScreen screen) { + super.displayPreference(screen); + mPreference = screen.findPreference(getPreferenceKey()); + mPreference.setTitle( + OneHandedSettingsUtils.getNavigationBarMode(mContext) == 0 /* 3 button */ + ? R.string.one_handed_mode_use_shortcut_category + : R.string.one_handed_mode_swipe_down_category); + } +} diff --git a/src/com/android/settings/gestures/OneHandedSettingsUtils.java b/src/com/android/settings/gestures/OneHandedSettingsUtils.java index a9311296b43..f058689912b 100644 --- a/src/com/android/settings/gestures/OneHandedSettingsUtils.java +++ b/src/com/android/settings/gestures/OneHandedSettingsUtils.java @@ -16,6 +16,8 @@ package com.android.settings.gestures; +import static com.android.internal.accessibility.AccessibilityShortcutController.ONE_HANDED_COMPONENT_NAME; + import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; @@ -33,6 +35,9 @@ import androidx.annotation.VisibleForTesting; */ public class OneHandedSettingsUtils { + static final String ONE_HANDED_MODE_TARGET_NAME = + ONE_HANDED_COMPONENT_NAME.getShortClassName(); + static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode"; static final int OFF = 0; static final int ON = 1; @@ -40,6 +45,8 @@ public class OneHandedSettingsUtils { Settings.Secure.getUriFor(Settings.Secure.ONE_HANDED_MODE_ENABLED); static final Uri SHOW_NOTIFICATION_ENABLED_URI = Settings.Secure.getUriFor(Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED); + static final Uri SHORTCUT_ENABLED_URI = + Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS); public enum OneHandedTimeout { NEVER(0), SHORT(4), MEDIUM(8), LONG(12); @@ -220,8 +227,30 @@ public class OneHandedSettingsUtils { * navigation settings. */ public static boolean canEnableController(Context context) { - return (OneHandedSettingsUtils.isOneHandedModeEnabled(context) - && OneHandedSettingsUtils.getNavigationBarMode(context) != 0 /* 3-button mode */); + return ((OneHandedSettingsUtils.isOneHandedModeEnabled(context) + && getNavigationBarMode(context) != 0 /* 3-button */) + || getShortcutEnabled(context)); + } + + /** + * Queries one-handed mode shortcut enabled in settings or not. + * + * @return true if user enabled one-handed shortcut in settings, false otherwise. + */ + public static boolean getShortcutEnabled(Context context) { + final String targets = Settings.Secure.getStringForUser(context.getContentResolver(), + Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, sCurrentUserId); + return targets != null ? targets.contains(ONE_HANDED_MODE_TARGET_NAME) : false; + } + + /** + * This is a test only API for set Shortcut enabled or not. + */ + @VisibleForTesting + public void setShortcutEnabled(Context context, boolean enabled) { + final String targetName = enabled ? ONE_HANDED_MODE_TARGET_NAME : ""; + Settings.Secure.putStringForUser(context.getContentResolver(), + Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, targetName, sCurrentUserId); } /** @@ -256,6 +285,7 @@ public class OneHandedSettingsUtils { final ContentResolver resolver = mContext.getContentResolver(); resolver.registerContentObserver(ONE_HANDED_MODE_ENABLED_URI, true, this); resolver.registerContentObserver(SHOW_NOTIFICATION_ENABLED_URI, true, this); + resolver.registerContentObserver(SHORTCUT_ENABLED_URI, true, this); } @Override diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedActionPullDownPrefControllerTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedActionPullDownPrefControllerTest.java index 60398de9937..36938c2ee9d 100644 --- a/tests/robotests/src/com/android/settings/gestures/OneHandedActionPullDownPrefControllerTest.java +++ b/tests/robotests/src/com/android/settings/gestures/OneHandedActionPullDownPrefControllerTest.java @@ -105,4 +105,26 @@ public class OneHandedActionPullDownPrefControllerTest { assertThat(mController.getAvailabilityStatus()) .isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING); } + + @Test + public void getAvailabilityStatus_setShortcutEnabled_shouldEnabled() { + SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true"); + OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false); + mUtils.setNavigationBarMode(mContext, "0" /* 3-button mode */); + mUtils.setShortcutEnabled(mContext, true); + + assertThat(mController.getAvailabilityStatus()) + .isEqualTo(BasePreferenceController.AVAILABLE); + } + + @Test + public void getAvailabilityStatus_setShortcutDisabled_shouldDisabled() { + SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true"); + OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false); + mUtils.setNavigationBarMode(mContext, "0" /* 3-button mode */); + mUtils.setShortcutEnabled(mContext, false); + + assertThat(mController.getAvailabilityStatus()) + .isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING); + } } diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefControllerTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefControllerTest.java index b56a4f78f16..a7afccd2fe5 100644 --- a/tests/robotests/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefControllerTest.java +++ b/tests/robotests/src/com/android/settings/gestures/OneHandedActionShowNotificationPrefControllerTest.java @@ -104,4 +104,26 @@ public class OneHandedActionShowNotificationPrefControllerTest { assertThat(mController.getAvailabilityStatus()) .isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING); } + + @Test + public void getAvailabilityStatus_setShortcutEnabled_shouldEnabled() { + SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true"); + OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false); + mUtils.setNavigationBarMode(mContext, "0" /* 3-button mode */); + mUtils.setShortcutEnabled(mContext, true); + + assertThat(mController.getAvailabilityStatus()) + .isEqualTo(BasePreferenceController.AVAILABLE); + } + + @Test + public void getAvailabilityStatus_setShortcutDisabled_shouldDisabled() { + SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true"); + OneHandedSettingsUtils.setOneHandedModeEnabled(mContext, false); + mUtils.setNavigationBarMode(mContext, "0" /* 3-button mode */); + mUtils.setShortcutEnabled(mContext, false); + + assertThat(mController.getAvailabilityStatus()) + .isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING); + } } diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedPreferenceCategoryControllerTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedPreferenceCategoryControllerTest.java new file mode 100644 index 00000000000..112e04aa806 --- /dev/null +++ b/tests/robotests/src/com/android/settings/gestures/OneHandedPreferenceCategoryControllerTest.java @@ -0,0 +1,81 @@ +/* + * 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.gestures; + +import static junit.framework.TestCase.assertTrue; + +import static org.mockito.Mockito.when; + +import android.content.Context; +import android.os.UserHandle; +import android.text.TextUtils; + +import androidx.preference.PreferenceCategory; +import androidx.preference.PreferenceScreen; + +import com.android.settings.R; + +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 OneHandedPreferenceCategoryControllerTest { + + private static final String KEY = "gesture_one_handed_mode_swipe_down"; + + private Context mContext; + private OneHandedSettingsUtils mUtils; + private OneHandedPreferenceCategoryController mController; + @Mock + private PreferenceCategory mPreference; + @Mock + private PreferenceScreen mScreen; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + mContext = RuntimeEnvironment.application; + mUtils = new OneHandedSettingsUtils(mContext); + mController = new OneHandedPreferenceCategoryController(mContext, KEY); + OneHandedSettingsUtils.setUserId(UserHandle.myUserId()); + mPreference = new PreferenceCategory(mContext); + when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); + } + + @Test + public void getTitle_set3ButtonMode_shouldReturnSetShortcutTo() { + mUtils.setNavigationBarMode(mContext, "0" /* 3 button */); + mController.displayPreference(mScreen); + + assertTrue(TextUtils.equals(mPreference.getTitle(), mContext.getText( + R.string.one_handed_mode_use_shortcut_category))); + } + + @Test + public void getTitle_setGestureMode_shouldReturnSwipeDownTo() { + mUtils.setNavigationBarMode(mContext, "2" /* fully gestural */); + mController.displayPreference(mScreen); + + assertTrue(TextUtils.equals(mPreference.getTitle(), mContext.getText( + R.string.one_handed_mode_swipe_down_category))); + } +} From ed7139fad013e9e599c8c666d24c77b99101a7c7 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Thu, 1 Jul 2021 19:22:02 +0800 Subject: [PATCH 12/15] Correct breadcrumbs of Wi-Fi scanning and Bluetooth scanning Since the screen title of the Location Services page is not the same as the preference title on the Location page, it breaked the page relation between Location and Location services to lead to the broken breadcrumbs for Wi-Fi scanning and Bluetooth scanning. Fixes: 192540579 Test: visual Change-Id: I9fbc4033517a715e97e534991549a1029ca4e5fa --- res/xml/location_services.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/xml/location_services.xml b/res/xml/location_services.xml index 516491c5f1e..2de4e7b2446 100644 --- a/res/xml/location_services.xml +++ b/res/xml/location_services.xml @@ -16,7 +16,7 @@ + android:title="@string/location_services_preference_title"> Date: Thu, 1 Jul 2021 16:20:23 +0100 Subject: [PATCH 13/15] Add bottom padding to 'Choose a new lock screen' * Add 24dp padding Before: https://screenshot.googleplex.com/64sTaMhwqMKQ4CE After: https://screenshot.googleplex.com/As33LmkLXG7duV5 Bug: 192541032 Test: manual testing (see screenshots) Change-Id: I4e29e4f776e7be1c42301c39c4844d7ee948eaaa --- res/values/styles.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/values/styles.xml b/res/values/styles.xml index 63ea86ebe3b..e25c7fa5bed 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -394,6 +394,7 @@ From 494c68e3cf0a214b7b3fdcfbaba9a91b2be8abf9 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Thu, 1 Jul 2021 05:11:41 +0000 Subject: [PATCH 14/15] Revert "Add a cancel string for ToggleSubscriptionDialog to handle Tamil" This reverts commit eba8857094c0a1deabaedba92f9713fddb7b0781. Reason for revert: Issue not urgent enough to go in S, will resubmit to master Bug: 185553806 Change-Id: Id7f6042e0f7c70a3a8ca951fb80bb7f30acedcb9 --- res/values/strings.xml | 2 -- .../telephony/ToggleSubscriptionDialogActivity.java | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 0f98a5a3e23..aeaea6116b8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -12892,8 +12892,6 @@ Restart No thanks - - Cancel Switch diff --git a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java index e67ac42af47..0064e6ccfd2 100644 --- a/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java +++ b/src/com/android/settings/network/telephony/ToggleSubscriptionDialogActivity.java @@ -338,7 +338,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getString(R.string.sim_action_restart_title), getString(R.string.sim_action_enable_dsds_text), getString(R.string.sim_action_reboot), - getString(R.string.sim_action_cancel)); + getString(R.string.cancel)); } /* Displays the SIM toggling confirmation dialog. */ @@ -359,7 +359,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc title, null, getString(R.string.yes), - getString(R.string.sim_action_cancel)); + getString(R.string.cancel)); } private void showEnableSimConfirmDialog() { @@ -384,7 +384,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getSwitchSubscriptionTitle(), getSwitchDialogBodyMsg(activeSub, isBetweenEsim), getSwitchDialogPosBtnText(), - getString(R.string.sim_action_cancel)); + getString(android.R.string.cancel)); } private void showNonSwitchSimConfirmDialog() { @@ -395,7 +395,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc getEnableSubscriptionTitle(), null /* msg */, getString(R.string.yes), - getString(R.string.sim_action_cancel)); + getString(android.R.string.cancel)); } private String getSwitchDialogPosBtnText() { From 4cf13de04d133c1c70a44358f1935aac1e071a32 Mon Sep 17 00:00:00 2001 From: Curtis Belmonte Date: Thu, 1 Jul 2021 10:38:25 -0700 Subject: [PATCH 15/15] Adjust UI of face and fingerprint enroll intro pages Changes the appearance and spacing of the face and fingerprint unlock intro/consent pages to be consistent with one another and more closely match the latest mocks. Test: Manually tested face and fingerprint enrollment Fixes: 192475206 Change-Id: I4d41ddc15dc1a6be818762a286f06470344cf819 --- res/layout/face_enroll_introduction.xml | 53 +++++------------ .../fingerprint_enroll_introduction.xml | 57 ++++++------------- res/values/styles.xml | 14 +++++ 3 files changed, 45 insertions(+), 79 deletions(-) diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml index 2887bcac277..c9c4d23f578 100644 --- a/res/layout/face_enroll_introduction.xml +++ b/res/layout/face_enroll_introduction.xml @@ -43,9 +43,7 @@ + android:layout_height="wrap_content"> + style="@style/BiometricEnrollIntroTitle" + android:text="@string/security_settings_face_enroll_introduction_info_title" /> + android:orientation="horizontal"> + style="@style/BiometricEnrollIntroMessage" /> + android:orientation="horizontal"> + style="@style/BiometricEnrollIntroMessage" /> - - - - + style="@style/BiometricEnrollIntroTitle" + android:text="@string/security_settings_face_enroll_introduction_how_title" /> - - + style="@style/BiometricEnrollIntroMessage" /> - - + style="@style/BiometricEnrollIntroTitle" /> + style="@style/BiometricEnrollIntroMessage" + android:paddingBottom="0dp" /> diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml index 5f828799269..d4914e64bbb 100644 --- a/res/layout/fingerprint_enroll_introduction.xml +++ b/res/layout/fingerprint_enroll_introduction.xml @@ -42,8 +42,7 @@ + android:layout_height="wrap_content"> + style="@style/BiometricEnrollIntroTitle" + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_footer_title_2" /> + android:orientation="horizontal"> + style="@style/BiometricEnrollIntroMessage" /> + android:orientation="horizontal"> + style="@style/BiometricEnrollIntroMessage" /> - - + style="@style/BiometricEnrollIntroTitle" /> + android:orientation="horizontal"> + style="@style/BiometricEnrollIntroMessage" /> - - + style="@style/BiometricEnrollIntroTitle" + android:text="@string/security_settings_face_enroll_introduction_info_title"/> + android:orientation="horizontal"> + style="@style/BiometricEnrollIntroMessage" /> + android:orientation="horizontal"> + style="@style/BiometricEnrollIntroMessage" + android:paddingBottom="0dp" + android:text="@string/security_settings_fingerprint_v2_enroll_introduction_message_learn_more" /> diff --git a/res/values/styles.xml b/res/values/styles.xml index 63ea86ebe3b..979632e57db 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -397,6 +397,20 @@ 1.2 + + + +