Merge "Fix Incorrect Trust Agent Count" into tm-qpr-dev am: 9f1dba6017
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/19669514 Change-Id: I2334c56c62c3f019ad50d505a91b08351c392aee Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -32,12 +32,14 @@ public class ManageTrustAgentsPreferenceController extends BasePreferenceControl
|
||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
||||
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private TrustAgentManager mTrustAgentManager;
|
||||
|
||||
public ManageTrustAgentsPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
final SecurityFeatureProvider securityFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getSecurityFeatureProvider();
|
||||
mLockPatternUtils = securityFeatureProvider.getLockPatternUtils(context);
|
||||
mTrustAgentManager = securityFeatureProvider.getTrustAgentManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,6 +66,6 @@ public class ManageTrustAgentsPreferenceController extends BasePreferenceControl
|
||||
}
|
||||
|
||||
private int getTrustAgentCount() {
|
||||
return mLockPatternUtils.getEnabledTrustAgents(MY_USER_ID).size();
|
||||
return mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils, false).size();
|
||||
}
|
||||
}
|
||||
|
@@ -99,13 +99,27 @@ public class TrustAgentManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of trust agents.
|
||||
* Returns a list of trust agents that have a android:settingsActivity set in their declaration.
|
||||
*
|
||||
* If {@link #ONLY_ONE_TRUST_AGENT} is set, the list will contain up to 1 agent instead of all
|
||||
* available agents on device.
|
||||
*/
|
||||
public List<TrustAgentComponentInfo> getActiveTrustAgents(Context context,
|
||||
LockPatternUtils utils) {
|
||||
return getActiveTrustAgents(context, utils, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of trust agents.
|
||||
*
|
||||
* If {@link #ONLY_ONE_TRUST_AGENT} is set, the list will contain up to 1 agent instead of all
|
||||
* available agents on device.
|
||||
*
|
||||
* @param skipTrustAgentsWithNoActivity {@code false} to only include trustagents with
|
||||
* android:settingsActivity set in their declaration, {@code true} otherwise.
|
||||
*/
|
||||
public List<TrustAgentComponentInfo> getActiveTrustAgents(Context context,
|
||||
LockPatternUtils utils, boolean skipTrustAgentsWithNoActivity) {
|
||||
final int myUserId = UserHandle.myUserId();
|
||||
final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
@@ -125,9 +139,12 @@ public class TrustAgentManager {
|
||||
}
|
||||
final TrustAgentComponentInfo trustAgentComponentInfo =
|
||||
getSettingsComponent(pm, resolveInfo);
|
||||
if (trustAgentComponentInfo.componentName == null ||
|
||||
!enabledTrustAgents.contains(getComponentName(resolveInfo)) ||
|
||||
TextUtils.isEmpty(trustAgentComponentInfo.title)) {
|
||||
if (skipTrustAgentsWithNoActivity
|
||||
&& trustAgentComponentInfo.componentName == null) {
|
||||
continue;
|
||||
}
|
||||
if (!enabledTrustAgents.contains(getComponentName(resolveInfo))
|
||||
|| TextUtils.isEmpty(trustAgentComponentInfo.title)) {
|
||||
continue;
|
||||
}
|
||||
if (admin != null && dpm.getTrustAgentConfiguration(
|
||||
|
Reference in New Issue
Block a user