Snap for 7736437 from 72264775ef to sc-v2-release

Change-Id: I78e1292996e4bec0030baaf39b952884085648bd
This commit is contained in:
Android Build Coastguard Worker
2021-09-15 23:09:14 +00:00
9 changed files with 131 additions and 34 deletions

View File

@@ -136,7 +136,7 @@
android:taskAffinity="com.android.settings.root" android:taskAffinity="com.android.settings.root"
android:launchMode="singleTask" android:launchMode="singleTask"
android:exported="true" android:exported="true"
android:configChanges="keyboard|keyboardHidden"> android:configChanges="keyboard|keyboardHidden|screenSize|screenLayout">
<intent-filter android:priority="1"> <intent-filter android:priority="1">
<action android:name="android.settings.SETTINGS" /> <action android:name="android.settings.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

View File

@@ -726,6 +726,7 @@
<string name="security_dashboard_summary">Screen lock, Find My Device, app security</string> <string name="security_dashboard_summary">Screen lock, Find My Device, app security</string>
<!-- Face enrollment and settings --><skip /> <!-- Face enrollment and settings --><skip />
<!-- Note: Update FaceEnrollParentalConsent.CONSENT_STRING_RESOURCES when any _consent_ strings are added or removed. -->
<!-- Message shown in summary field when face unlock is set up. [CHAR LIMIT=40] --> <!-- Message shown in summary field when face unlock is set up. [CHAR LIMIT=40] -->
<string name="security_settings_face_preference_summary">Face added</string> <string name="security_settings_face_preference_summary">Face added</string>
<!-- Message shown in summary field when Face Unlock is not set up. [CHAR LIMIT=54] --> <!-- Message shown in summary field when Face Unlock is not set up. [CHAR LIMIT=54] -->
@@ -879,6 +880,7 @@
<string name="security_settings_face_settings_context_subtitle">Use Face Unlock to unlock your phone</string> <string name="security_settings_face_settings_context_subtitle">Use Face Unlock to unlock your phone</string>
<!-- Fingerprint enrollment and settings --><skip /> <!-- Fingerprint enrollment and settings --><skip />
<!-- Note: Update FingerprintEnrollParentalConsent.CONSENT_STRING_RESOURCES when any _consent_ strings are added or removed. -->
<!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] --> <!-- Title shown for menu item that launches fingerprint settings or enrollment [CHAR LIMIT=22] -->
<string name="security_settings_fingerprint_preference_title">Fingerprint</string> <string name="security_settings_fingerprint_preference_title">Fingerprint</string>
<!-- Fingerprint managment category title - configuration options for managing enrolled fingerprints [CHAR LIMIT=22] --> <!-- Fingerprint managment category title - configuration options for managing enrolled fingerprints [CHAR LIMIT=22] -->

View File

@@ -233,6 +233,12 @@ public class SettingsActivity extends SettingsBaseActivity
protected void onCreate(Bundle savedState) { protected void onCreate(Bundle savedState) {
super.onCreate(savedState); super.onCreate(savedState);
Log.d(LOG_TAG, "Starting onCreate"); Log.d(LOG_TAG, "Starting onCreate");
if (launchHomepageForTwonPaneDeepLink()) {
finish();
return;
}
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
final FeatureFactory factory = FeatureFactory.getFactory(this); final FeatureFactory factory = FeatureFactory.getFactory(this);
@@ -242,22 +248,7 @@ public class SettingsActivity extends SettingsBaseActivity
// Should happen before any call to getIntent() // Should happen before any call to getIntent()
getMetaData(); getMetaData();
// If it's a deep link intent, start the Activity from SettingsHomepageActivity for 2-pane.
final Intent intent = getIntent(); 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)) { if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0)); 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(...) // Getting Intent properties can only be done after the super.onCreate(...)
final String initialFragmentName = getInitialFragmentName(intent); 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 // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content
// insets. // insets.
// If this is in setup flow, don't apply theme. Because light theme needs to be applied // If this is in setup flow, don't apply theme. Because light theme needs to be applied
// in SettingsBaseActivity#onCreate(). // in SettingsBaseActivity#onCreate().
if (isSubSettings && !WizardManagerHelper.isAnySetupWizard(getIntent())) { if (isSubSettings(intent) && !WizardManagerHelper.isAnySetupWizard(getIntent())) {
setTheme(R.style.Theme_SubSettings); setTheme(R.style.Theme_SubSettings);
} }
@@ -364,10 +349,43 @@ public class SettingsActivity extends SettingsBaseActivity
} }
} }
private boolean isOnlyOneActivityInActivityStack() { private boolean isSubSettings(Intent intent) {
final ActivityManager activityManager = getSystemService(ActivityManager.class); return this instanceof SubSettings ||
List<ActivityManager.RunningTaskInfo> taskList = activityManager.getRunningTasks(2); intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
return taskList.get(0).numActivities == 1; }
/** 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. */ /** Returns the initial fragment name that the activity will launch. */

View File

@@ -28,7 +28,7 @@ import androidx.window.embedding.SplitController;
public class ActivityEmbeddingUtils { public class ActivityEmbeddingUtils {
public static final float SPLIT_RATIO = 0.5f; public static final float SPLIT_RATIO = 0.5f;
// The smallest value of current width of the window when the split should be used. // 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 smallest value of the smallest-width (sw) of the window in any rotation when
// the split should be used. // the split should be used.
private static final float MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP = 600f; private static final float MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP = 600f;

View File

@@ -48,6 +48,10 @@ public class ParentalConsentHelper {
private static final String KEY_FINGERPRINT_CONSENT = "fingerprint"; private static final String KEY_FINGERPRINT_CONSENT = "fingerprint";
private static final String KEY_IRIS_CONSENT = "iris"; 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 mRequireFace;
private final boolean mRequireFingerprint; private final boolean mRequireFingerprint;
@@ -152,9 +156,14 @@ public class ParentalConsentHelper {
public Bundle getConsentResult() { public Bundle getConsentResult() {
final Bundle result = new Bundle(); final Bundle result = new Bundle();
result.putBoolean(KEY_FACE_CONSENT, mConsentFace != null ? mConsentFace : false); result.putBoolean(KEY_FACE_CONSENT, mConsentFace != null ? mConsentFace : false);
result.putIntArray(KEY_FACE_CONSENT_STRINGS,
FaceEnrollParentalConsent.CONSENT_STRING_RESOURCES);
result.putBoolean(KEY_FINGERPRINT_CONSENT, result.putBoolean(KEY_FINGERPRINT_CONSENT,
mConsentFingerprint != null ? mConsentFingerprint : false); mConsentFingerprint != null ? mConsentFingerprint : false);
result.putIntArray(KEY_FINGERPRINT_CONSENT_STRINGS,
FingerprintEnrollParentalConsent.CONSENT_STRING_RESOURCES);
result.putBoolean(KEY_IRIS_CONSENT, false); result.putBoolean(KEY_IRIS_CONSENT, false);
result.putIntArray(KEY_IRIS_CONSENT_STRINGS, new int[0]);
return result; return result;
} }

View File

@@ -33,6 +33,21 @@ import com.android.settings.R;
*/ */
public class FaceEnrollParentalConsent extends FaceEnrollIntroduction { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@@ -33,6 +33,20 @@ import com.android.settings.R;
*/ */
public class FingerprintEnrollParentalConsent extends FingerprintEnrollIntroduction { 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@@ -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.hasSufficientPermission;
import static com.android.settings.display.SmartAutoRotateController.isRotationResolverServiceAvailable; import static com.android.settings.display.SmartAutoRotateController.isRotationResolverServiceAvailable;
import android.text.TextUtils;
import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -37,7 +39,9 @@ import androidx.preference.PreferenceScreen;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.view.RotationPolicy; import com.android.internal.view.RotationPolicy;
import com.android.settings.R; 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.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop; 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 * SmartAutoRotatePreferenceController provides auto rotate summary in display settings
*/ */
public class SmartAutoRotatePreferenceController extends BasePreferenceController public class SmartAutoRotatePreferenceController extends TogglePreferenceController
implements LifecycleObserver, OnStart, OnStop { implements LifecycleObserver, OnStart, OnStop {
private RotationPolicy.RotationPolicyListener mRotationPolicyListener; private final MetricsFeatureProvider mMetricsFeatureProvider;
private Preference mPreference;
private final SensorPrivacyManager mPrivacyManager; private final SensorPrivacyManager mPrivacyManager;
private final PowerManager mPowerManager; private final PowerManager mPowerManager;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() { 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) { public SmartAutoRotatePreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey); super(context, preferenceKey);
mPrivacyManager = SensorPrivacyManager.getInstance(context); mPrivacyManager = SensorPrivacyManager.getInstance(context);
mPrivacyManager mPrivacyManager
.addSensorPrivacyListener(CAMERA, (sensor, enabled) -> refreshSummary(mPreference)); .addSensorPrivacyListener(CAMERA, (sensor, enabled) -> refreshSummary(mPreference));
mPowerManager = context.getSystemService(PowerManager.class); mPowerManager = context.getSystemService(PowerManager.class);
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
} }
@Override @Override
@@ -74,12 +80,28 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle
? AVAILABLE : UNSUPPORTED_ON_DEVICE; ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
} }
@Override
public boolean isSliceable() {
return TextUtils.equals(getPreferenceKey(), "auto_rotate");
}
@Override
public boolean isPublicSlice() {
return true;
}
@Override @Override
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey()); mPreference = screen.findPreference(getPreferenceKey());
} }
@Override
public void updateState(Preference preference) {
super.updateState(preference);
refreshSummary(mPreference);
}
@Override @Override
public void onStart() { public void onStart() {
mContext.registerReceiver(mReceiver, mContext.registerReceiver(mReceiver,
@@ -89,7 +111,7 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle
@Override @Override
public void onChange() { public void onChange() {
if (mPreference != null) { if (mPreference != null) {
refreshSummary(mPreference); updateState(mPreference);
} }
} }
}; };
@@ -121,6 +143,20 @@ public class SmartAutoRotatePreferenceController extends BasePreferenceControlle
return mPowerManager.isPowerSaveMode(); 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 @Override
public CharSequence getSummary() { public CharSequence getSummary() {
int activeStringId = R.string.auto_rotate_option_off; int activeStringId = R.string.auto_rotate_option_off;

View File

@@ -208,6 +208,9 @@ public class SettingsHomepageActivity extends FragmentActivity implements
return; return;
} }
// To prevent launchDeepLinkIntentToRight again for configuration change.
intent.setAction(null);
targetIntent.setFlags(targetIntent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK); targetIntent.setFlags(targetIntent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
targetIntent.putExtra(EXTRA_IS_FROM_SETTINGS_HOMEPAGE, true); targetIntent.putExtra(EXTRA_IS_FROM_SETTINGS_HOMEPAGE, true);