FileDocCategorySizeDatePackage
SampleTrustAgentSettings.javaAPI DocAndroid 5.1 API3850Thu Mar 12 22:22:42 GMT 2015com.android.trustagent.test

SampleTrustAgentSettings

public class SampleTrustAgentSettings extends android.app.Activity implements CompoundButton.OnCheckedChangeListener, View.OnClickListener

Fields Summary
private static final int
TRUST_DURATION_MS
private android.widget.CheckBox
mReportUnlockAttempts
private android.widget.CheckBox
mReportDeviceLocked
private android.widget.CheckBox
mManagingTrust
private android.widget.TextView
mCheckDeviceLockedResult
private android.app.KeyguardManager
mKeyguardManager
Constructors Summary
Methods Summary
public voidonCheckedChanged(android.widget.CompoundButton buttonView, boolean isChecked)

        if (buttonView == mReportUnlockAttempts) {
            SampleTrustAgent.setReportUnlockAttempts(this, isChecked);
        } else if (buttonView == mManagingTrust) {
            SampleTrustAgent.setIsManagingTrust(this, isChecked);
        } else if (buttonView == mReportDeviceLocked) {
            SampleTrustAgent.setReportDeviceLocked(this, isChecked);
        }
    
public voidonClick(android.view.View v)

        int id = v.getId();
        if (id == R.id.enable_trust) {
            SampleTrustAgent.sendGrantTrust(this, "SampleTrustAgent", TRUST_DURATION_MS,
                    false /* initiatedByUser */);
        } else if (id == R.id.revoke_trust) {
            SampleTrustAgent.sendRevokeTrust(this);
        } else if (id == R.id.crash) {
            throw new RuntimeException("crash");
        } else if (id == R.id.check_device_locked) {
            updateTrustedState();
        }
    
protected voidonCreate(android.os.Bundle savedInstanceState)



    
         
        super.onCreate(savedInstanceState);

        mKeyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);

        setContentView(R.layout.sample_trust_agent_settings);

        findViewById(R.id.enable_trust).setOnClickListener(this);
        findViewById(R.id.revoke_trust).setOnClickListener(this);
        findViewById(R.id.crash).setOnClickListener(this);
        findViewById(R.id.check_device_locked).setOnClickListener(this);

        mReportUnlockAttempts = (CheckBox) findViewById(R.id.report_unlock_attempts);
        mReportUnlockAttempts.setOnCheckedChangeListener(this);

        mReportDeviceLocked = (CheckBox) findViewById(R.id.report_device_locked);
        mReportDeviceLocked.setOnCheckedChangeListener(this);

        mManagingTrust = (CheckBox) findViewById(R.id.managing_trust);
        mManagingTrust.setOnCheckedChangeListener(this);

        mCheckDeviceLockedResult = (TextView) findViewById(R.id.check_device_locked_result);
    
protected voidonResume()

        super.onResume();
        mReportUnlockAttempts.setChecked(SampleTrustAgent.getReportUnlockAttempts(this));
        mManagingTrust.setChecked(SampleTrustAgent.getIsManagingTrust(this));
        updateTrustedState();
    
private voidupdateTrustedState()

        mCheckDeviceLockedResult.setText(Boolean.toString(
                mKeyguardManager.isDeviceLocked()));