From 8b3792d65bf01618d5391c4e16dc765ea9c565fc Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Fri, 3 Sep 2021 23:59:32 +0000 Subject: [PATCH 1/4] Add string ids to the result bundle for parental consent. Bug: 198491515 Test: N/A (builds) Change-Id: Id120f5f7a7e923f9d3ce7dd38d3e5214296ca219 --- res/values/strings.xml | 2 ++ .../biometrics/ParentalConsentHelper.java | 9 +++++++++ .../face/FaceEnrollParentalConsent.java | 15 +++++++++++++++ .../FingerprintEnrollParentalConsent.java | 14 ++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index 1951718a2d3..b069a358871 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -726,6 +726,7 @@ Screen lock, Find My Device, app security + Face added @@ -879,6 +880,7 @@ Use Face Unlock to unlock your phone + Fingerprint diff --git a/src/com/android/settings/biometrics/ParentalConsentHelper.java b/src/com/android/settings/biometrics/ParentalConsentHelper.java index 6c4004e5c55..e0e082b8fef 100644 --- a/src/com/android/settings/biometrics/ParentalConsentHelper.java +++ b/src/com/android/settings/biometrics/ParentalConsentHelper.java @@ -48,6 +48,10 @@ public class ParentalConsentHelper { private static final String KEY_FINGERPRINT_CONSENT = "fingerprint"; private static final String KEY_IRIS_CONSENT = "iris"; + private static final String KEY_FACE_CONSENT_STRINGS = "face_strings"; + private static final String KEY_FINGERPRINT_CONSENT_STRINGS = "fingerprint_strings"; + private static final String KEY_IRIS_CONSENT_STRINGS = "iris_strings"; + private final boolean mRequireFace; private final boolean mRequireFingerprint; @@ -152,9 +156,14 @@ public class ParentalConsentHelper { public Bundle getConsentResult() { final Bundle result = new Bundle(); result.putBoolean(KEY_FACE_CONSENT, mConsentFace != null ? mConsentFace : false); + result.putIntArray(KEY_FACE_CONSENT_STRINGS, + FaceEnrollParentalConsent.CONSENT_STRING_RESOURCES); result.putBoolean(KEY_FINGERPRINT_CONSENT, mConsentFingerprint != null ? mConsentFingerprint : false); + result.putIntArray(KEY_FINGERPRINT_CONSENT_STRINGS, + FingerprintEnrollParentalConsent.CONSENT_STRING_RESOURCES); result.putBoolean(KEY_IRIS_CONSENT, false); + result.putIntArray(KEY_IRIS_CONSENT_STRINGS, new int[0]); return result; } diff --git a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java index 183e05ef29d..54466f90f0a 100644 --- a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java +++ b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java @@ -33,6 +33,21 @@ import com.android.settings.R; */ public class FaceEnrollParentalConsent extends FaceEnrollIntroduction { + /** + * List of string resources to log when recording the result of this activity in gms. + * This must be updated when any strings are added/removed. + */ + public static final int[] CONSENT_STRING_RESOURCES = new int[] { + R.string.security_settings_face_enroll_consent_introduction_title, + R.string.security_settings_face_enroll_introduction_consent_message, + R.string.security_settings_face_enroll_introduction_info_consent_glasses, + R.string.security_settings_face_enroll_introduction_info_consent_looking, + R.string.security_settings_face_enroll_introduction_info_consent_gaze, + R.string.security_settings_face_enroll_introduction_how_consent_message, + R.string.security_settings_face_enroll_introduction_control_consent_title, + R.string.security_settings_face_enroll_introduction_control_consent_message + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java index a95a91260d5..22212f27d83 100644 --- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java +++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java @@ -33,6 +33,20 @@ import com.android.settings.R; */ public class FingerprintEnrollParentalConsent extends FingerprintEnrollIntroduction { + /** + * List of string resources to log when recording the result of this activity in gms. + * This must be updated when any strings are added/removed. + */ + public static final int[] CONSENT_STRING_RESOURCES = new int[] { + R.string.security_settings_fingerprint_enroll_consent_introduction_title, + R.string.security_settings_fingerprint_enroll_introduction_consent_message, + R.string.security_settings_fingerprint_enroll_introduction_footer_title_consent_1, + R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_2, + R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_3, + R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_4, + R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_5 + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); From dc909e2a13c633801938b73148a5b0b5082eb2d1 Mon Sep 17 00:00:00 2001 From: Abel Tesfaye Date: Tue, 10 Aug 2021 20:34:10 +0000 Subject: [PATCH 2/4] Add toggle switch for auto rotate preference in display settings. Bug: 183471038 Test: locally with flame & crosshatch Change-Id: Iea4dbdd6df8a53f0fb79b82c97892256ad072c1d --- .../SmartAutoRotatePreferenceController.java | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/display/SmartAutoRotatePreferenceController.java b/src/com/android/settings/display/SmartAutoRotatePreferenceController.java index f8d5f96786e..849fbe74cc8 100644 --- a/src/com/android/settings/display/SmartAutoRotatePreferenceController.java +++ b/src/com/android/settings/display/SmartAutoRotatePreferenceController.java @@ -22,6 +22,8 @@ import static android.provider.Settings.Secure.CAMERA_AUTOROTATE; import static com.android.settings.display.SmartAutoRotateController.hasSufficientPermission; import static com.android.settings.display.SmartAutoRotateController.isRotationResolverServiceAvailable; +import android.text.TextUtils; +import android.app.settings.SettingsEnums; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -37,7 +39,9 @@ import androidx.preference.PreferenceScreen; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.view.RotationPolicy; import com.android.settings.R; -import com.android.settings.core.BasePreferenceController; +import com.android.settings.core.TogglePreferenceController; +import com.android.settings.overlay.FeatureFactory; +import com.android.settingslib.core.instrumentation.MetricsFeatureProvider; import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStop; @@ -45,12 +49,10 @@ import com.android.settingslib.core.lifecycle.events.OnStop; /** * SmartAutoRotatePreferenceController provides auto rotate summary in display settings */ -public class SmartAutoRotatePreferenceController extends BasePreferenceController +public class SmartAutoRotatePreferenceController extends TogglePreferenceController implements LifecycleObserver, OnStart, OnStop { - private RotationPolicy.RotationPolicyListener mRotationPolicyListener; - private Preference mPreference; - + private final MetricsFeatureProvider mMetricsFeatureProvider; private final SensorPrivacyManager mPrivacyManager; private final PowerManager mPowerManager; private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @@ -60,12 +62,16 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle } }; + private RotationPolicy.RotationPolicyListener mRotationPolicyListener; + private Preference mPreference; + public SmartAutoRotatePreferenceController(Context context, String preferenceKey) { super(context, preferenceKey); mPrivacyManager = SensorPrivacyManager.getInstance(context); mPrivacyManager .addSensorPrivacyListener(CAMERA, (sensor, enabled) -> refreshSummary(mPreference)); mPowerManager = context.getSystemService(PowerManager.class); + mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider(); } @Override @@ -74,12 +80,28 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } + @Override + public boolean isSliceable() { + return TextUtils.equals(getPreferenceKey(), "auto_rotate"); + } + + @Override + public boolean isPublicSlice() { + return true; + } + @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); mPreference = screen.findPreference(getPreferenceKey()); } + @Override + public void updateState(Preference preference) { + super.updateState(preference); + refreshSummary(mPreference); + } + @Override public void onStart() { mContext.registerReceiver(mReceiver, @@ -89,7 +111,7 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle @Override public void onChange() { if (mPreference != null) { - refreshSummary(mPreference); + updateState(mPreference); } } }; @@ -121,6 +143,20 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle return mPowerManager.isPowerSaveMode(); } + @Override + public boolean isChecked() { + return !RotationPolicy.isRotationLocked(mContext); + } + + @Override + public boolean setChecked(boolean isChecked) { + final boolean isLocked = !isChecked; + mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_ROTATION_LOCK, + isLocked); + RotationPolicy.setRotationLock(mContext, isLocked); + return true; + } + @Override public CharSequence getSummary() { int activeStringId = R.string.auto_rotate_option_off; From f6a8f6c8af35564cbd0c78b9307aab2e9deea013 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Fri, 10 Sep 2021 14:25:12 +0800 Subject: [PATCH 3/4] Extends the criteria width of 2-pane mode Follow UI spec, we extend criteria width from 600dp -> 720dp Original code checks if there is only one Activity in Activity stack to decide if it's a deep link intent, it has problem at configurationChange. This change checks if the intent is from Settings app itself to decide if it's a deep link intent. Bug: 197716926 Bug: 199808997 Test: Build apk and run on the device. Change-Id: Ide8ef2ccffa87b9ee4fab41ab4f395b00def9bd6 --- .../android/settings/SettingsActivity.java | 70 ++++++++++++------- .../ActivityEmbeddingUtils.java | 2 +- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index 178892e6f5f..b82bb765629 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -233,6 +233,12 @@ public class SettingsActivity extends SettingsBaseActivity protected void onCreate(Bundle savedState) { super.onCreate(savedState); Log.d(LOG_TAG, "Starting onCreate"); + + if (launchHomepageForTwonPaneDeepLink()) { + finish(); + return; + } + long startTime = System.currentTimeMillis(); final FeatureFactory factory = FeatureFactory.getFactory(this); @@ -242,22 +248,7 @@ public class SettingsActivity extends SettingsBaseActivity // Should happen before any call to getIntent() getMetaData(); - // If it's a deep link intent, start the Activity from SettingsHomepageActivity for 2-pane. final Intent intent = getIntent(); - final boolean isFromSettingsHomepage = intent.getBooleanExtra( - SettingsHomepageActivity.EXTRA_IS_FROM_SETTINGS_HOMEPAGE, /* defaultValue */ false); - if (ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this) && !isFromSettingsHomepage - && isOnlyOneActivityInActivityStack()) { - final Intent trampolineIntent = - new Intent(android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK); - trampolineIntent.putExtra( - android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI, - intent.toUri(Intent.URI_INTENT_SCHEME)); - startActivity(trampolineIntent); - finish(); - return; - } - if (intent.hasExtra(EXTRA_UI_OPTIONS)) { getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); } @@ -265,17 +256,11 @@ public class SettingsActivity extends SettingsBaseActivity // Getting Intent properties can only be done after the super.onCreate(...) final String initialFragmentName = getInitialFragmentName(intent); - // This is a "Sub Settings" when: - // - this is a real SubSettings - // - or :settings:show_fragment_as_subsetting is passed to the Intent - final boolean isSubSettings = this instanceof SubSettings || - intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false); - // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content // insets. // If this is in setup flow, don't apply theme. Because light theme needs to be applied // in SettingsBaseActivity#onCreate(). - if (isSubSettings && !WizardManagerHelper.isAnySetupWizard(getIntent())) { + if (isSubSettings(intent) && !WizardManagerHelper.isAnySetupWizard(getIntent())) { setTheme(R.style.Theme_SubSettings); } @@ -364,10 +349,43 @@ public class SettingsActivity extends SettingsBaseActivity } } - private boolean isOnlyOneActivityInActivityStack() { - final ActivityManager activityManager = getSystemService(ActivityManager.class); - List taskList = activityManager.getRunningTasks(2); - return taskList.get(0).numActivities == 1; + private boolean isSubSettings(Intent intent) { + return this instanceof SubSettings || + intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false); + } + + /** Returns true if the Activity is started by a deep link intent for large screen devices. */ + private boolean launchHomepageForTwonPaneDeepLink() { + if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) { + return false; + } + + final Intent intent = getIntent(); + // Only starts trampoline for deep links. Should return false for all the cases that + // Settings app starts SettingsActivity or SubSetting by itself. + if (intent.getAction() == null) { + // Other apps should send deep link intent which matches intent filter of the Activity. + return false; + } + + if (isSubSettings(intent)) { + return false; + } + + if (intent.getBooleanExtra(SettingsHomepageActivity.EXTRA_IS_FROM_SETTINGS_HOMEPAGE, + /* defaultValue */ false)) { + return false; + } + + // It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it. + final Intent trampolineIntent = + new Intent(android.provider.Settings.ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK); + trampolineIntent.putExtra( + android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI, + intent.toUri(Intent.URI_INTENT_SCHEME)); + startActivity(trampolineIntent); + + return true; } /** Returns the initial fragment name that the activity will launch. */ diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java index 96c37773fc1..fd6618716e0 100644 --- a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java +++ b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java @@ -28,7 +28,7 @@ import androidx.window.embedding.SplitController; public class ActivityEmbeddingUtils { public static final float SPLIT_RATIO = 0.5f; // The smallest value of current width of the window when the split should be used. - private static final float MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP = 600f; + private static final float MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP = 720f; // The smallest value of the smallest-width (sw) of the window in any rotation when // the split should be used. private static final float MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP = 600f; From fdfac783aba9411ec5aa267d9d7792c493c23414 Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Wed, 8 Sep 2021 10:52:14 +0800 Subject: [PATCH 4/4] Add android:configChanges for SettingsHomepageActivity When resuming Settings app of large screen devices, SettingsHomepageActivity will be re-created for Activity resized. It produces unnecessary Activity destroy and re-create. This change prevents SettingsHomepageActivity from configuration changes for screenSize|screenLayout. Bug: 198361315 Test: manual 1. Launch Settings app by a Settings shortcut widget. 2. Move Settings app to background. 3. Click Settings shortcut widget again. Observe if SettingsHomepageActivity re-creates. Change-Id: I4d71330f6a1760768ba4443e192f66b0a2cbb6bf --- AndroidManifest.xml | 2 +- .../android/settings/homepage/SettingsHomepageActivity.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2c3eb057fc3..7ea777de02f 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -136,7 +136,7 @@ android:taskAffinity="com.android.settings.root" android:launchMode="singleTask" android:exported="true" - android:configChanges="keyboard|keyboardHidden"> + android:configChanges="keyboard|keyboardHidden|screenSize|screenLayout"> diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java index 4a0a912323c..f073a618e05 100644 --- a/src/com/android/settings/homepage/SettingsHomepageActivity.java +++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java @@ -208,6 +208,9 @@ public class SettingsHomepageActivity extends FragmentActivity implements return; } + // To prevent launchDeepLinkIntentToRight again for configuration change. + intent.setAction(null); + targetIntent.setFlags(targetIntent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); targetIntent.putExtra(EXTRA_IS_FROM_SETTINGS_HOMEPAGE, true);