Merge "Fix issue #27291496: Remove Background Check from Settings / Dev Options" into nyc-dev
diff --git a/res/layout/preview_seek_bar_view_pager.xml b/res/layout/preview_seek_bar_view_pager.xml
index 4badca4..d16a356 100644
--- a/res/layout/preview_seek_bar_view_pager.xml
+++ b/res/layout/preview_seek_bar_view_pager.xml
@@ -45,7 +45,7 @@
android:gravity="center"
android:text="@string/screen_zoom_preview_title"
android:textAppearance="@android:style/TextAppearance.Material.Widget.ActionBar.Title"
- android:textColor="?android:attr/textColorPrimaryInverse"
+ android:textColor="@color/seek_bar_preference_preview_text"
android:elevation="2dp"/>
</RelativeLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e69839d..3b9e712 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3155,15 +3155,19 @@
<!-- Security & location settings screen, title when changing or confirming the work profile lock -->
<string name="lock_settings_profile_screen_lock_title">Work profile screen lock</string>
<!-- Security & location settings screen, setting option name to unify work and personal locks -->
- <string name="lock_settings_profile_unification_title">Use same screen lock</string>
+ <string name="lock_settings_profile_unification_title">Use the same lock</string>
<!-- Security & location settings screen, setting option explanation to unify work and personal locks -->
- <string name="lock_settings_profile_unification_summary">Change primary profile to match work profile</string>
+ <string name="lock_settings_profile_unification_summary">Change device screen lock to match work profile?</string>
<!-- Security & location settings screen, title of the dialog asking if the user wants to unify work and personal locks -->
<string name="lock_settings_profile_unification_dialog_title">Use the same screen lock?</string>
<!-- Security & location settings screen, explanation in the dialog asking if the user wants to unify work and personal locks -->
<string name="lock_settings_profile_unification_dialog_body">You can use this lock for your device but it will include all screen lock related policies set by your IT admin on the work profile.\nDo you want to use the same screen lock for your device?</string>
+ <!-- Security & location settings screen, explanation in the dialog asking if the user wants to create a new lock for personal and work as the current work lock is not enough for the device. -->
+ <string name="lock_settings_profile_unification_dialog_uncompliant_body">Your work screen lock doesn\'t meet your organization\'s security requirements.\nYou can set a new screen lock for both your device and your work profile, but any work screen lock policies will apply to your device screen lock as well.</string>
+ <!-- Security & location settings screen, confirmation button of the dialog asking if the user wants to create a new lock for both personal and work profiles. -->
+ <string name="lock_settings_profile_unification_dialog_uncompliant_confirm">Change lock</string>
<!-- Security & location settings screen, summary of the item that changes your work profile lock when it is unified with the personal lock -->
- <string name="lock_settings_profile_unified_summary">Same as your device lock</string>
+ <string name="lock_settings_profile_unified_summary">Same as device screen lock</string>
<!-- Applications Settings --> <skip />
<!-- Applications settings screen, setting option name for the user to go to the screen to manage installed applications -->
@@ -6900,7 +6904,7 @@
<!-- Description for the screen zoom level that makes interface elements small. [CHAR LIMIT=24] -->
<string name="screen_zoom_summary_small">Small</string>
<!-- Description for the device's default screen zoom level. [CHAR LIMIT=24] -->
- <string name="screen_zoom_summary_normal">Normal</string>
+ <string name="screen_zoom_summary_default">Default</string>
<!-- Description for the screen zoom level that makes interface elements large. [CHAR LIMIT=24] -->
<string name="screen_zoom_summary_large">Large</string>
<!-- Description for the screen zoom level that makes interface elements larger. [CHAR LIMIT=24] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 70b5005..acd658f 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -373,8 +373,8 @@
<style name="PreviewPagerPageIndicator">
<item name="dotGap">8dp</item>
- <item name="pageIndicatorColor">@android:color/tertiary_text_light</item>
- <item name="currentPageIndicatorColor">@android:color/primary_text_light</item>
+ <item name="pageIndicatorColor">?android:attr/colorControlNormal</item>
+ <item name="currentPageIndicatorColor">?android:attr/colorControlActivated</item>
</style>
<style name="LanguageCheckboxAndLabel">
diff --git a/res/xml/security_settings_unification.xml b/res/xml/security_settings_unification.xml
index ac8d5b2..79b8b7d 100644
--- a/res/xml/security_settings_unification.xml
+++ b/res/xml/security_settings_unification.xml
@@ -18,11 +18,10 @@
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:title="@string/security_settings_title">
- <PreferenceScreen
+ <SwitchPreference
android:key="unification"
android:title="@string/lock_settings_profile_unification_title"
android:summary="@string/lock_settings_profile_unification_summary"
- settings:keywords="@string/keywords_unification"
- android:persistent="false"/>
+ settings:keywords="@string/keywords_unification"/>
</PreferenceScreen>
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 6ad7df1..8464462 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -117,7 +117,7 @@
// These switch preferences need special handling since they're not all stored in Settings.
private static final String SWITCH_PREFERENCE_KEYS[] = {
- KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS };
+ KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS, KEY_UNIFICATION };
// Only allow one trust agent on the platform.
private static final boolean ONLY_ONE_TRUST_AGENT = true;
@@ -132,6 +132,7 @@
private LockPatternUtils mLockPatternUtils;
private SwitchPreference mVisiblePatternProfile;
+ private SwitchPreference mUnifyProfile;
private SwitchPreference mShowPassword;
@@ -235,13 +236,13 @@
getActivity(), mLockPatternUtils, mProfileChallengeUserId);
addPreferencesFromResource(profileResid);
maybeAddFingerprintPreference(root, mProfileChallengeUserId);
- if (mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
- maybeAddUnificationPreference();
- } else {
+ addPreferencesFromResource(R.xml.security_settings_unification);
+ if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
Preference lockPreference = root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
String summary = getContext().getString(
R.string.lock_settings_profile_unified_summary);
lockPreference.setSummary(summary);
+ lockPreference.setEnabled(false);
}
}
@@ -273,6 +274,7 @@
mVisiblePatternProfile =
(SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN_PROFILE);
+ mUnifyProfile = (SwitchPreference) root.findPreference(KEY_UNIFICATION);
// Append the rest of the settings
addPreferencesFromResource(R.xml.security_settings_misc);
@@ -386,15 +388,6 @@
}
}
- private void maybeAddUnificationPreference() {
- if (mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId)
- >= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
- && mLockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
- mProfileChallengeUserId)) {
- addPreferencesFromResource(R.xml.security_settings_unification);
- }
- }
-
private void addTrustAgentSettings(PreferenceGroup securityCategory) {
final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
ArrayList<TrustAgentComponentInfo> agents =
@@ -560,12 +553,13 @@
// depend on others...
createPreferenceHierarchy();
- final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (mVisiblePatternProfile != null) {
- mVisiblePatternProfile.setChecked(lockPatternUtils.isVisiblePatternEnabled(
+ mVisiblePatternProfile.setChecked(mLockPatternUtils.isVisiblePatternEnabled(
mProfileChallengeUserId));
}
+ updateUnificationPreference();
+
if (mShowPassword != null) {
mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
@@ -576,6 +570,13 @@
}
}
+ private void updateUnificationPreference() {
+ if (mUnifyProfile != null) {
+ mUnifyProfile.setChecked(!mLockPatternUtils.isSeparateProfileChallengeEnabled(
+ mProfileChallengeUserId));
+ }
+ }
+
@Override
public boolean onPreferenceTreeClick(Preference preference) {
final String key = preference.getKey();
@@ -599,11 +600,6 @@
startActivity(mTrustAgentClickIntent);
mTrustAgentClickIntent = null;
}
- } else if (KEY_UNIFICATION.equals(key)) {
- UnificationConfirmationDialog dialog =
- UnificationConfirmationDialog.newIntance(mProfileChallengeUserId);
- dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
- return true;
} else {
// If we didn't handle it, let preferences handle it.
return super.onPreferenceTreeClick(preference);
@@ -680,6 +676,13 @@
mCurrentProfilePassword = null;
}
+ private void unifyUncompliantLocks() {
+ mLockPatternUtils.clearLock(mProfileChallengeUserId);
+ mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, false);
+ startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
+ R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
+ }
+
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
boolean result = true;
@@ -687,6 +690,20 @@
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (KEY_VISIBLE_PATTERN_PROFILE.equals(key)) {
lockPatternUtils.setVisiblePatternEnabled((Boolean) value, mProfileChallengeUserId);
+ } else if (KEY_UNIFICATION.equals(key)) {
+ if ((Boolean) value) {
+ final boolean compliantForDevice =
+ (mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId)
+ >= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
+ && mLockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
+ mProfileChallengeUserId));
+ UnificationConfirmationDialog dialog =
+ UnificationConfirmationDialog.newIntance(compliantForDevice);
+ dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
+ } else {
+ mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, true);
+ createPreferenceHierarchy();
+ }
} else if (KEY_SHOW_PASSWORD.equals(key)) {
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
((Boolean) value) ? 1 : 0);
@@ -946,13 +963,12 @@
createPreferenceHierarchy();
- final LockPatternUtils lockPatternUtils = mLockPatternUtils;
if (mVisiblePattern != null) {
- mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(
+ mVisiblePattern.setChecked(mLockPatternUtils.isVisiblePatternEnabled(
MY_USER_ID));
}
if (mPowerButtonInstantlyLocks != null) {
- mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks(
+ mPowerButtonInstantlyLocks.setChecked(mLockPatternUtils.getPowerButtonInstantlyLocks(
MY_USER_ID));
}
@@ -1205,9 +1221,13 @@
}
public static class UnificationConfirmationDialog extends DialogFragment {
+ private static final String EXTRA_COMPLIANT = "compliant";
- public static UnificationConfirmationDialog newIntance(int userId) {
+ public static UnificationConfirmationDialog newIntance(boolean compliant) {
UnificationConfirmationDialog dialog = new UnificationConfirmationDialog();
+ Bundle args = new Bundle();
+ args.putBoolean(EXTRA_COMPLIANT, compliant);
+ dialog.setArguments(args);
return dialog;
}
@@ -1222,14 +1242,21 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final SecuritySettings parentFragment = ((SecuritySettings) getParentFragment());
+ final boolean compliant = getArguments().getBoolean(EXTRA_COMPLIANT);
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.lock_settings_profile_unification_dialog_title)
- .setMessage(R.string.lock_settings_profile_unification_dialog_body)
- .setPositiveButton(R.string.okay,
+ .setMessage(compliant ? R.string.lock_settings_profile_unification_dialog_body
+ : R.string.lock_settings_profile_unification_dialog_uncompliant_body)
+ .setPositiveButton(compliant ? R.string.okay
+ : R.string.lock_settings_profile_unification_dialog_uncompliant_confirm,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
- parentFragment.launchConfirmDeviceLockForUnification();
+ if (compliant) {
+ parentFragment.launchConfirmDeviceLockForUnification();
+ } else {
+ parentFragment.unifyUncompliantLocks();
+ }
}
}
)
@@ -1237,6 +1264,7 @@
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
+ parentFragment.updateUnificationPreference();
dismiss();
}
}
diff --git a/src/com/android/settings/display/DisplayDensityUtils.java b/src/com/android/settings/display/DisplayDensityUtils.java
index 891b7fb..6810511 100644
--- a/src/com/android/settings/display/DisplayDensityUtils.java
+++ b/src/com/android/settings/display/DisplayDensityUtils.java
@@ -46,14 +46,14 @@
/** Maximum density scale. The actual scale used depends on the device. */
private static final float MAX_SCALE = 1.50f;
- /** Summary used for "normal" scale. */
- private static final int SUMMARY_NORMAL = R.string.screen_zoom_summary_normal;
+ /** Summary used for "default" scale. */
+ private static final int SUMMARY_DEFAULT = R.string.screen_zoom_summary_default;
/** Summary used for "custom" scale. */
private static final int SUMMARY_CUSTOM = R.string.screen_zoom_summary_custom;
/**
- * Summaries for scales smaller than "normal" in order of smallest to
+ * Summaries for scales smaller than "default" in order of smallest to
* largest.
*/
private static final int[] SUMMARIES_SMALLER = new int[] {
@@ -61,7 +61,7 @@
};
/**
- * Summaries for scales larger than "normal" in order of smallest to
+ * Summaries for scales larger than "default" in order of smallest to
* largest.
*/
private static final int[] SUMMARIES_LARGER = new int[] {
@@ -80,16 +80,16 @@
private final String[] mEntries;
private final int[] mValues;
- private final int mNormalDensity;
+ private final int mDefaultDensity;
private final int mCurrentIndex;
public DisplayDensityUtils(Context context) {
- final int normalDensity = DisplayDensityUtils.getNormalDisplayDensity(
+ final int defaultDensity = DisplayDensityUtils.getDefaultDisplayDensity(
Display.DEFAULT_DISPLAY);
- if (normalDensity <= 0) {
+ if (defaultDensity <= 0) {
mEntries = null;
mValues = null;
- mNormalDensity = 0;
+ mDefaultDensity = 0;
mCurrentIndex = -1;
return;
}
@@ -102,7 +102,7 @@
// Compute number of "larger" and "smaller" scales for this display.
final int minDimensionPx = Math.min(metrics.widthPixels, metrics.heightPixels);
final int maxDensity = DisplayMetrics.DENSITY_MEDIUM * minDimensionPx / MIN_DIMENSION_DP;
- final float maxScale = Math.min(MAX_SCALE, maxDensity / (float) normalDensity);
+ final float maxScale = Math.min(MAX_SCALE, maxDensity / (float) defaultDensity);
final float minScale = MIN_SCALE;
final int numLarger = (int) MathUtils.constrain((maxScale - 1) / MIN_SCALE_INTERVAL,
0, SUMMARIES_LARGER.length);
@@ -117,7 +117,7 @@
final float interval = (1 - minScale) / numSmaller;
for (int i = numSmaller - 1; i >= 0; i--) {
// Round down to a multiple of 2 by truncating the low bit.
- final int density = ((int) (normalDensity * (1 - (i + 1) * interval))) & ~1;
+ final int density = ((int) (defaultDensity * (1 - (i + 1) * interval))) & ~1;
if (currentDensity == density) {
currentDensityIndex = curIndex;
}
@@ -127,18 +127,18 @@
}
}
- if (currentDensity == normalDensity) {
+ if (currentDensity == defaultDensity) {
currentDensityIndex = curIndex;
}
- values[curIndex] = normalDensity;
- entries[curIndex] = res.getString(SUMMARY_NORMAL);
+ values[curIndex] = defaultDensity;
+ entries[curIndex] = res.getString(SUMMARY_DEFAULT);
curIndex++;
if (numLarger > 0) {
final float interval = (maxScale - 1) / numLarger;
for (int i = 0; i < numLarger; i++) {
// Round down to a multiple of 2 by truncating the low bit.
- final int density = ((int) (normalDensity * (1 + (i + 1) * interval))) & ~1;
+ final int density = ((int) (defaultDensity * (1 + (i + 1) * interval))) & ~1;
if (currentDensity == density) {
currentDensityIndex = curIndex;
}
@@ -163,7 +163,7 @@
displayIndex = curIndex;
}
- mNormalDensity = normalDensity;
+ mDefaultDensity = defaultDensity;
mCurrentIndex = displayIndex;
mEntries = entries;
mValues = values;
@@ -181,18 +181,18 @@
return mCurrentIndex;
}
- public int getNormalDensity() {
- return mNormalDensity;
+ public int getDefaultDensity() {
+ return mDefaultDensity;
}
/**
- * Returns the normal (default) density for the specified display.
+ * Returns the default density for the specified display.
*
* @param displayId the identifier of the display
- * @return the normal density of the specified display, or {@code -1} if
+ * @return the default density of the specified display, or {@code -1} if
* the display does not exist or the density could not be obtained
*/
- private static int getNormalDisplayDensity(int displayId) {
+ private static int getDefaultDisplayDensity(int displayId) {
try {
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
return wm.getInitialDisplayDensity(displayId);
diff --git a/src/com/android/settings/display/ScreenZoomSettings.java b/src/com/android/settings/display/ScreenZoomSettings.java
index d87f230..f6049c7 100644
--- a/src/com/android/settings/display/ScreenZoomSettings.java
+++ b/src/com/android/settings/display/ScreenZoomSettings.java
@@ -38,7 +38,7 @@
*/
public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment implements Indexable {
- private int mNormalDensity;
+ private int mDefaultDensity;
private int[] mValues;
@Override
@@ -56,19 +56,19 @@
final int initialIndex = density.getCurrentIndex();
if (initialIndex < 0) {
- // Failed to obtain normal density, which means we failed to
+ // Failed to obtain default density, which means we failed to
// connect to the window manager service. Just use the current
// density and don't let the user change anything.
final int densityDpi = getResources().getDisplayMetrics().densityDpi;
mValues = new int[] { densityDpi };
- mEntries = new String[] { getString(R.string.screen_zoom_summary_normal) };
+ mEntries = new String[] { getString(R.string.screen_zoom_summary_default) };
mInitialIndex = 0;
- mNormalDensity = densityDpi;
+ mDefaultDensity = densityDpi;
} else {
mValues = density.getValues();
mEntries = density.getEntries();
mInitialIndex = initialIndex;
- mNormalDensity = density.getNormalDensity();
+ mDefaultDensity = density.getDefaultDensity();
}
}
@@ -86,7 +86,7 @@
@Override
protected void commit() {
final int densityDpi = mValues[mCurrentIndex];
- if (densityDpi == mNormalDensity) {
+ if (densityDpi == mDefaultDensity) {
DisplayDensityUtils.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
} else {
DisplayDensityUtils.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, densityDpi);