Merge "Block "Screen lock" menu if password is managed." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
52fdd6a058
@@ -17,15 +17,16 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.preference.Preference;
|
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A preference with a Gear on the side
|
* A preference with a Gear on the side
|
||||||
*/
|
*/
|
||||||
public class GearPreference extends Preference implements View.OnClickListener {
|
public class GearPreference extends RestrictedPreference implements View.OnClickListener {
|
||||||
|
|
||||||
private OnGearClickListener mOnGearClickListener;
|
private OnGearClickListener mOnGearClickListener;
|
||||||
|
|
||||||
@@ -42,7 +43,9 @@ public class GearPreference extends Preference implements View.OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||||
super.onBindViewHolder(holder);
|
super.onBindViewHolder(holder);
|
||||||
holder.findViewById(R.id.settings_button).setOnClickListener(this);
|
final View gear = holder.findViewById(R.id.settings_button);
|
||||||
|
gear.setOnClickListener(this);
|
||||||
|
gear.setEnabled(true); // Make gear available even if the preference itself is disabled.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -230,6 +230,15 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils, MY_USER_ID);
|
final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils, MY_USER_ID);
|
||||||
addPreferencesFromResource(resid);
|
addPreferencesFromResource(resid);
|
||||||
|
|
||||||
|
final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
|
||||||
|
getActivity(), MY_USER_ID);
|
||||||
|
if (admin != null && mDPM.getPasswordQuality(admin.component) ==
|
||||||
|
DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
|
||||||
|
final GearPreference unlockSetOrChangePref =
|
||||||
|
(GearPreference) getPreferenceScreen().findPreference(KEY_UNLOCK_SET_OR_CHANGE);
|
||||||
|
unlockSetOrChangePref.setDisabledByAdmin(admin);
|
||||||
|
}
|
||||||
|
|
||||||
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
|
mProfileChallengeUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
|
||||||
if (mProfileChallengeUserId != UserHandle.USER_NULL
|
if (mProfileChallengeUserId != UserHandle.USER_NULL
|
||||||
&& mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
|
&& mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
|
||||||
@@ -744,59 +753,58 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||||
Context context, boolean enabled) {
|
Context context, boolean enabled) {
|
||||||
|
final List<SearchIndexableResource> index = new ArrayList<SearchIndexableResource>();
|
||||||
|
|
||||||
List<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>();
|
final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
||||||
|
final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
|
||||||
LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
context, MY_USER_ID);
|
||||||
// Add options for lock/unlock screen
|
final DevicePolicyManager dpm = (DevicePolicyManager)
|
||||||
int resId = getResIdForLockUnlockScreen(context, lockPatternUtils, MY_USER_ID);
|
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
|
|
||||||
SearchIndexableResource sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = resId;
|
|
||||||
result.add(sir);
|
|
||||||
|
|
||||||
final UserManager um = UserManager.get(context);
|
final UserManager um = UserManager.get(context);
|
||||||
|
|
||||||
|
if (admin == null || dpm.getPasswordQuality(admin.component) !=
|
||||||
|
DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
|
||||||
|
// Add options for lock/unlock screen
|
||||||
|
final int resId = getResIdForLockUnlockScreen(context, lockPatternUtils,
|
||||||
|
MY_USER_ID);
|
||||||
|
index.add(getSearchResource(context, resId));
|
||||||
|
}
|
||||||
|
|
||||||
final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
|
final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
|
||||||
if (profileUserId != UserHandle.USER_NULL
|
if (profileUserId != UserHandle.USER_NULL
|
||||||
&& lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)) {
|
&& lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)) {
|
||||||
sir = new SearchIndexableResource(context);
|
index.add(getSearchResource(context, getResIdForLockUnlockScreen(context,
|
||||||
sir.xmlResId = getResIdForLockUnlockScreen(
|
lockPatternUtils, profileUserId)));
|
||||||
context, lockPatternUtils, profileUserId);
|
|
||||||
result.add(sir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (um.isAdminUser()) {
|
if (um.isAdminUser()) {
|
||||||
DevicePolicyManager dpm = (DevicePolicyManager)
|
|
||||||
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
|
||||||
|
|
||||||
switch (dpm.getStorageEncryptionStatus()) {
|
switch (dpm.getStorageEncryptionStatus()) {
|
||||||
case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
|
case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
|
||||||
// The device is currently encrypted.
|
// The device is currently encrypted.
|
||||||
resId = R.xml.security_settings_encrypted;
|
index.add(getSearchResource(context, R.xml.security_settings_encrypted));
|
||||||
break;
|
break;
|
||||||
case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
|
case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
|
||||||
// This device supports encryption but isn't encrypted.
|
// This device supports encryption but isn't encrypted.
|
||||||
resId = R.xml.security_settings_unencrypted;
|
index.add(getSearchResource(context, R.xml.security_settings_unencrypted));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sir = new SearchIndexableResource(context);
|
|
||||||
sir.xmlResId = resId;
|
|
||||||
result.add(sir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sir = new SearchIndexableResource(context);
|
final SearchIndexableResource sir = getSearchResource(context,
|
||||||
sir.xmlResId = SecuritySubSettings.getResIdForLockUnlockSubScreen(context,
|
SecuritySubSettings.getResIdForLockUnlockSubScreen(context, lockPatternUtils));
|
||||||
lockPatternUtils);
|
|
||||||
sir.className = SecuritySubSettings.class.getName();
|
sir.className = SecuritySubSettings.class.getName();
|
||||||
result.add(sir);
|
index.add(sir);
|
||||||
|
|
||||||
// Append the rest of the settings
|
// Append the rest of the settings
|
||||||
sir = new SearchIndexableResource(context);
|
index.add(getSearchResource(context, R.xml.security_settings_misc));
|
||||||
sir.xmlResId = R.xml.security_settings_misc;
|
|
||||||
result.add(sir);
|
|
||||||
|
|
||||||
return result;
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SearchIndexableResource getSearchResource(Context context, int xmlResId) {
|
||||||
|
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
|
sir.xmlResId = xmlResId;
|
||||||
|
return sir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user