下面列出了android.app.admin.DevicePolicyManager#KEYGUARD_DISABLE_TRUST_AGENTS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* One keyguard features disabled, request to disable fingerprint.
* @throws Exception any failure.
*/
@Test
public void test_changeOneKeyguardFeaturesDisabled() throws Exception {
int expected = DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS
+ DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT;
int result = KeyguardFeatures.setFingerprintDisabled(
DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS, true);
assertEquals(expected, result);
}
boolean updateDevicePolicyFeatures() {
boolean trustDisabled = false;
if (DEBUG) Slog.d(TAG, "updateDevicePolicyFeatures(" + mName + ")");
try {
if (mTrustAgentService != null) {
DevicePolicyManager dpm =
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
if ((dpm.getKeyguardDisabledFeatures(null, mUserId)
& DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0) {
List<PersistableBundle> config = dpm.getTrustAgentConfiguration(
null, mName, mUserId);
trustDisabled = true;
if (DEBUG) Slog.d(TAG, "Detected trust agents disabled. Config = " + config);
if (config != null && config.size() > 0) {
if (DEBUG) {
Slog.d(TAG, "TrustAgent " + mName.flattenToShortString()
+ " disabled until it acknowledges "+ config);
}
mSetTrustAgentFeaturesToken = new Binder();
mTrustAgentService.onConfigure(config, mSetTrustAgentFeaturesToken);
}
} else {
mTrustAgentService.onConfigure(Collections.EMPTY_LIST, null);
}
final long maxTimeToLock = dpm.getMaximumTimeToLock(null, mUserId);
if (maxTimeToLock != mMaximumTimeToLock) {
// If the timeout changes, cancel the alarm and send a timeout event to have
// the agent re-evaluate trust.
mMaximumTimeToLock = maxTimeToLock;
if (mAlarmPendingIntent != null) {
mAlarmManager.cancel(mAlarmPendingIntent);
mAlarmPendingIntent = null;
mHandler.sendEmptyMessage(MSG_TRUST_TIMEOUT);
}
}
}
} catch (RemoteException e) {
onError(e);
}
if (mTrustDisabledByDpm != trustDisabled) {
mTrustDisabledByDpm = trustDisabled;
mTrustManagerService.updateTrust(mUserId, 0);
}
return trustDisabled;
}