am 4bc3c8bd: Merge "SampleTrustAgent: Exercise KeyguardManager.isKeyguardInTrustedState" into lmp-mr1-dev
* commit '4bc3c8bd643ca6840bf5b3fe01d8221f3a389d96': SampleTrustAgent: Exercise KeyguardManager.isKeyguardInTrustedState
This commit is contained in:
@@ -44,4 +44,18 @@
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Report unlock attempts" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button android:id="@+id/check_trusted"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Keyguard in trusted state?" />
|
||||
<TextView android:id="@+id/check_trusted_result"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -18,10 +18,12 @@ package com.android.trustagent.test;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SampleTrustAgentSettings extends Activity implements View.OnClickListener,
|
||||
CompoundButton.OnCheckedChangeListener {
|
||||
@@ -30,21 +32,31 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi
|
||||
|
||||
private CheckBox mReportUnlockAttempts;
|
||||
private CheckBox mManagingTrust;
|
||||
private TextView mCheckTrustedStateResult;
|
||||
|
||||
private KeyguardManager mKeyguardManager;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable 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_trusted).setOnClickListener(this);
|
||||
|
||||
mReportUnlockAttempts = (CheckBox) findViewById(R.id.report_unlock_attempts);
|
||||
mReportUnlockAttempts.setOnCheckedChangeListener(this);
|
||||
|
||||
mManagingTrust = (CheckBox) findViewById(R.id.managing_trust);
|
||||
mManagingTrust.setOnCheckedChangeListener(this);
|
||||
|
||||
mCheckTrustedStateResult = (TextView) findViewById(R.id.check_trusted_result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +64,7 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi
|
||||
super.onResume();
|
||||
mReportUnlockAttempts.setChecked(SampleTrustAgent.getReportUnlockAttempts(this));
|
||||
mManagingTrust.setChecked(SampleTrustAgent.getIsManagingTrust(this));
|
||||
updateTrustedState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,6 +77,8 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi
|
||||
SampleTrustAgent.sendRevokeTrust(this);
|
||||
} else if (id == R.id.crash) {
|
||||
throw new RuntimeException("crash");
|
||||
} else if (id == R.id.check_trusted) {
|
||||
updateTrustedState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,4 +90,9 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi
|
||||
SampleTrustAgent.setIsManagingTrust(this, isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTrustedState() {
|
||||
mCheckTrustedStateResult.setText(Boolean.toString(
|
||||
mKeyguardManager.isKeyguardInTrustedState()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user