Java Code Examples for android.app.admin.DevicePolicyManager#KEYGUARD_DISABLE_TRUST_AGENTS

The following examples show how to use android.app.admin.DevicePolicyManager#KEYGUARD_DISABLE_TRUST_AGENTS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyguardFeaturesTest.java    From AdminControl with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: TrustAgentWrapper.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
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;
}