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