Add padlocks to more preferences that can be disabled by admin.
Bug: 26899715 Bug: 26767574 Bug: 26768057 Change-Id: I2dc590833cbee1e35047002ef554432f10ddc654
This commit is contained in:
@@ -6378,9 +6378,6 @@
|
|||||||
<!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
|
<!-- Label for showing apps with domain URLs (data URI with http or https) in list [CHAR LIMIT=30] -->
|
||||||
<string name="filter_with_domain_urls_apps">With domain URLs</string>
|
<string name="filter_with_domain_urls_apps">With domain URLs</string>
|
||||||
|
|
||||||
<!-- Summary for a trust agent that was disabled by the device policy [LIMIT=NONE] -->
|
|
||||||
<string name="trust_agent_disabled_device_admin">Disabled by administrator</string>
|
|
||||||
|
|
||||||
<!-- Title for advanced application management settings [CHAR LIMIT=30] -->
|
<!-- Title for advanced application management settings [CHAR LIMIT=30] -->
|
||||||
<string name="advanced_apps">Advanced</string>
|
<string name="advanced_apps">Advanced</string>
|
||||||
|
|
||||||
|
@@ -345,11 +345,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private void addTrustAgentSettings(PreferenceGroup securityCategory) {
|
private void addTrustAgentSettings(PreferenceGroup securityCategory) {
|
||||||
final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
|
final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
|
||||||
ArrayList<TrustAgentComponentInfo> agents =
|
ArrayList<TrustAgentComponentInfo> agents =
|
||||||
getActiveTrustAgents(getPackageManager(), mLockPatternUtils, mDPM);
|
getActiveTrustAgents(getActivity(), mLockPatternUtils, mDPM);
|
||||||
for (int i = 0; i < agents.size(); i++) {
|
for (int i = 0; i < agents.size(); i++) {
|
||||||
final TrustAgentComponentInfo agent = agents.get(i);
|
final TrustAgentComponentInfo agent = agents.get(i);
|
||||||
Preference trustAgentPreference =
|
RestrictedPreference trustAgentPreference =
|
||||||
new Preference(securityCategory.getContext());
|
new RestrictedPreference(securityCategory.getContext());
|
||||||
trustAgentPreference.setKey(KEY_TRUST_AGENT);
|
trustAgentPreference.setKey(KEY_TRUST_AGENT);
|
||||||
trustAgentPreference.setTitle(agent.title);
|
trustAgentPreference.setTitle(agent.title);
|
||||||
trustAgentPreference.setSummary(agent.summary);
|
trustAgentPreference.setSummary(agent.summary);
|
||||||
@@ -361,10 +361,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
// Add preference to the settings menu.
|
// Add preference to the settings menu.
|
||||||
securityCategory.addPreference(trustAgentPreference);
|
securityCategory.addPreference(trustAgentPreference);
|
||||||
|
|
||||||
if (agent.disabledByAdministrator) {
|
trustAgentPreference.setDisabledByAdmin(agent.admin);
|
||||||
trustAgentPreference.setEnabled(false);
|
if (!trustAgentPreference.isDisabledByAdmin() && !hasSecurity) {
|
||||||
trustAgentPreference.setSummary(R.string.trust_agent_disabled_device_admin);
|
|
||||||
} else if (!hasSecurity) {
|
|
||||||
trustAgentPreference.setEnabled(false);
|
trustAgentPreference.setEnabled(false);
|
||||||
trustAgentPreference.setSummary(R.string.disabled_because_no_backup_security);
|
trustAgentPreference.setSummary(R.string.disabled_because_no_backup_security);
|
||||||
}
|
}
|
||||||
@@ -409,14 +407,15 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(
|
private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(
|
||||||
PackageManager pm, LockPatternUtils utils, DevicePolicyManager dpm) {
|
Context context, LockPatternUtils utils, DevicePolicyManager dpm) {
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
ArrayList<TrustAgentComponentInfo> result = new ArrayList<TrustAgentComponentInfo>();
|
ArrayList<TrustAgentComponentInfo> result = new ArrayList<TrustAgentComponentInfo>();
|
||||||
List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT,
|
List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT,
|
||||||
PackageManager.GET_META_DATA);
|
PackageManager.GET_META_DATA);
|
||||||
List<ComponentName> enabledTrustAgents = utils.getEnabledTrustAgents(MY_USER_ID);
|
List<ComponentName> enabledTrustAgents = utils.getEnabledTrustAgents(MY_USER_ID);
|
||||||
|
|
||||||
boolean disableTrustAgents = (dpm.getKeyguardDisabledFeatures(null)
|
EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context,
|
||||||
& DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
|
DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
|
||||||
|
|
||||||
if (enabledTrustAgents != null && !enabledTrustAgents.isEmpty()) {
|
if (enabledTrustAgents != null && !enabledTrustAgents.isEmpty()) {
|
||||||
for (int i = 0; i < resolveInfos.size(); i++) {
|
for (int i = 0; i < resolveInfos.size(); i++) {
|
||||||
@@ -429,9 +428,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
!enabledTrustAgents.contains(
|
!enabledTrustAgents.contains(
|
||||||
TrustAgentUtils.getComponentName(resolveInfo)) ||
|
TrustAgentUtils.getComponentName(resolveInfo)) ||
|
||||||
TextUtils.isEmpty(trustAgentComponentInfo.title)) continue;
|
TextUtils.isEmpty(trustAgentComponentInfo.title)) continue;
|
||||||
if (disableTrustAgents && dpm.getTrustAgentConfiguration(
|
if (admin != null && dpm.getTrustAgentConfiguration(
|
||||||
null, TrustAgentUtils.getComponentName(resolveInfo)) == null) {
|
null, TrustAgentUtils.getComponentName(resolveInfo)) == null) {
|
||||||
trustAgentComponentInfo.disabledByAdministrator = true;
|
trustAgentComponentInfo.admin = admin;
|
||||||
}
|
}
|
||||||
result.add(trustAgentComponentInfo);
|
result.add(trustAgentComponentInfo);
|
||||||
if (ONLY_ONE_TRUST_AGENT) break;
|
if (ONLY_ONE_TRUST_AGENT) break;
|
||||||
@@ -722,7 +721,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
||||||
if (lockPatternUtils.isSecure(MY_USER_ID)) {
|
if (lockPatternUtils.isSecure(MY_USER_ID)) {
|
||||||
ArrayList<TrustAgentComponentInfo> agents =
|
ArrayList<TrustAgentComponentInfo> agents =
|
||||||
getActiveTrustAgents(context.getPackageManager(), lockPatternUtils,
|
getActiveTrustAgents(context, lockPatternUtils,
|
||||||
context.getSystemService(DevicePolicyManager.class));
|
context.getSystemService(DevicePolicyManager.class));
|
||||||
for (int i = 0; i < agents.size(); i++) {
|
for (int i = 0; i < agents.size(); i++) {
|
||||||
final TrustAgentComponentInfo agent = agents.get(i);
|
final TrustAgentComponentInfo agent = agents.get(i);
|
||||||
@@ -784,7 +783,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private RestrictedListPreference mLockAfter;
|
private RestrictedListPreference mLockAfter;
|
||||||
private SwitchPreference mVisiblePattern;
|
private SwitchPreference mVisiblePattern;
|
||||||
private SwitchPreference mPowerButtonInstantlyLocks;
|
private SwitchPreference mPowerButtonInstantlyLocks;
|
||||||
private Preference mOwnerInfoPref;
|
private RestrictedPreference mOwnerInfoPref;
|
||||||
|
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private DevicePolicyManager mDPM;
|
private DevicePolicyManager mDPM;
|
||||||
@@ -860,19 +859,24 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
trustAgentPreference.getTitle()));
|
trustAgentPreference.getTitle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
|
mOwnerInfoPref = (RestrictedPreference) findPreference(KEY_OWNER_INFO_SETTINGS);
|
||||||
if (mOwnerInfoPref != null) {
|
if (mOwnerInfoPref != null) {
|
||||||
mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID)
|
if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
|
||||||
&& !mLockPatternUtils.isDeviceOwnerInfoEnabled());
|
EnforcedAdmin admin = RestrictedLockUtils.getDeviceOwner(getActivity());
|
||||||
|
mOwnerInfoPref.setDisabledByAdmin(admin);
|
||||||
if (mOwnerInfoPref.isEnabled()) {
|
} else {
|
||||||
mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
mOwnerInfoPref.setDisabledByAdmin(null);
|
||||||
@Override
|
mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID));
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
if (mOwnerInfoPref.isEnabled()) {
|
||||||
OwnerInfoSettings.show(SecuritySubSettings.this);
|
mOwnerInfoPref.setOnPreferenceClickListener(
|
||||||
return true;
|
new OnPreferenceClickListener() {
|
||||||
}
|
@Override
|
||||||
});
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
OwnerInfoSettings.show(SecuritySubSettings.this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1000,7 +1004,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
public void updateOwnerInfo() {
|
public void updateOwnerInfo() {
|
||||||
if (mOwnerInfoPref != null) {
|
if (mOwnerInfoPref != null) {
|
||||||
if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
|
if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
|
||||||
mOwnerInfoPref.setSummary(R.string.disabled_by_administrator_summary);
|
mOwnerInfoPref.setSummary(
|
||||||
|
mLockPatternUtils.getDeviceOwnerInfo());
|
||||||
} else {
|
} else {
|
||||||
mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID)
|
mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID)
|
||||||
? mLockPatternUtils.getOwnerInfo(MY_USER_ID)
|
? mLockPatternUtils.getOwnerInfo(MY_USER_ID)
|
||||||
|
@@ -22,7 +22,9 @@ import android.text.TextUtils.TruncateAt;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class SingleLineSummaryPreference extends Preference {
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
|
public class SingleLineSummaryPreference extends RestrictedPreference {
|
||||||
|
|
||||||
public SingleLineSummaryPreference(Context context, AttributeSet attrs) {
|
public SingleLineSummaryPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
@@ -34,9 +34,13 @@ import android.util.ArraySet;
|
|||||||
|
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
import com.android.settingslib.RestrictedSwitchPreference;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
public class TrustAgentSettings extends SettingsPreferenceFragment implements
|
public class TrustAgentSettings extends SettingsPreferenceFragment implements
|
||||||
Preference.OnPreferenceChangeListener {
|
Preference.OnPreferenceChangeListener {
|
||||||
private static final String SERVICE_INTERFACE = TrustAgentService.SERVICE_INTERFACE;
|
private static final String SERVICE_INTERFACE = TrustAgentService.SERVICE_INTERFACE;
|
||||||
@@ -96,13 +100,15 @@ public class TrustAgentSettings extends SettingsPreferenceFragment implements
|
|||||||
(PreferenceGroup) getPreferenceScreen().findPreference("trust_agents");
|
(PreferenceGroup) getPreferenceScreen().findPreference("trust_agents");
|
||||||
category.removeAll();
|
category.removeAll();
|
||||||
|
|
||||||
boolean disabledByDevicePolicy = (mDpm.getKeyguardDisabledFeatures(null)
|
final EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(context,
|
||||||
& DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
|
DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, UserHandle.myUserId());
|
||||||
|
|
||||||
final int count = mAvailableAgents.size();
|
final int count = mAvailableAgents.size();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
AgentInfo agent = mAvailableAgents.valueAt(i);
|
AgentInfo agent = mAvailableAgents.valueAt(i);
|
||||||
final SwitchPreference preference = new SwitchPreference(getPrefContext());
|
final RestrictedSwitchPreference preference =
|
||||||
|
new RestrictedSwitchPreference(getPrefContext());
|
||||||
|
preference.useAdminDisabledSummary(true);
|
||||||
agent.preference = preference;
|
agent.preference = preference;
|
||||||
preference.setPersistent(false);
|
preference.setPersistent(false);
|
||||||
preference.setTitle(agent.label);
|
preference.setTitle(agent.label);
|
||||||
@@ -111,11 +117,10 @@ public class TrustAgentSettings extends SettingsPreferenceFragment implements
|
|||||||
preference.setOnPreferenceChangeListener(this);
|
preference.setOnPreferenceChangeListener(this);
|
||||||
preference.setChecked(mActiveAgents.contains(agent.component));
|
preference.setChecked(mActiveAgents.contains(agent.component));
|
||||||
|
|
||||||
if (disabledByDevicePolicy
|
if (admin != null
|
||||||
&& mDpm.getTrustAgentConfiguration(null, agent.component) == null) {
|
&& mDpm.getTrustAgentConfiguration(null, agent.component) == null) {
|
||||||
preference.setChecked(false);
|
preference.setChecked(false);
|
||||||
preference.setEnabled(false);
|
preference.setDisabledByAdmin(admin);
|
||||||
preference.setSummary(R.string.trust_agent_disabled_device_admin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
category.addPreference(agent.preference);
|
category.addPreference(agent.preference);
|
||||||
|
@@ -33,6 +33,8 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||||
|
|
||||||
public class TrustAgentUtils {
|
public class TrustAgentUtils {
|
||||||
static final String TAG = "TrustAgentUtils";
|
static final String TAG = "TrustAgentUtils";
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ public class TrustAgentUtils {
|
|||||||
ComponentName componentName;
|
ComponentName componentName;
|
||||||
String title;
|
String title;
|
||||||
String summary;
|
String summary;
|
||||||
boolean disabledByAdministrator;
|
EnforcedAdmin admin = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ComponentName getComponentName(ResolveInfo resolveInfo) {
|
public static ComponentName getComponentName(ResolveInfo resolveInfo) {
|
||||||
|
Reference in New Issue
Block a user