Loading packages/Keyguard/test/SampleTrustAgent/res/layout/sample_trust_agent_settings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -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> No newline at end of file packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java +20 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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 Loading @@ -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 Loading @@ -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(); } } Loading @@ -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())); } } Loading
packages/Keyguard/test/SampleTrustAgent/res/layout/sample_trust_agent_settings.xml +14 −0 Original line number Diff line number Diff line Loading @@ -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> No newline at end of file
packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java +20 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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 Loading @@ -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 Loading @@ -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(); } } Loading @@ -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())); } }