From 7e03dfcb796ef1a6000a5fd5fda03c9e15ea62e1 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Fri, 16 May 2014 16:06:28 +0200 Subject: Apply revised TrustAgent API Bug: 14997466 Change-Id: I81042e058a20f28603a11471882f3dcfc4f8b13c --- .../src/com/android/trustagent/test/SampleTrustAgent.java | 14 +++++++------- .../android/trustagent/test/SampleTrustAgentSettings.java | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'packages/Keyguard/test/SampleTrustAgent/src') diff --git a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java index 25406d6..a51ea75 100644 --- a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java +++ b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java @@ -31,7 +31,7 @@ public class SampleTrustAgent extends TrustAgentService { LocalBroadcastManager mLocalBroadcastManager; - private static final String ACTION_ENABLE_TRUST = "action.sample_trust_agent.enable_trust"; + private static final String ACTION_GRANT_TRUST = "action.sample_trust_agent.grant_trust"; private static final String ACTION_REVOKE_TRUST = "action.sample_trust_agent.revoke_trust"; private static final String EXTRA_MESSAGE = "extra.message"; @@ -45,14 +45,14 @@ public class SampleTrustAgent extends TrustAgentService { public void onCreate() { super.onCreate(); IntentFilter filter = new IntentFilter(); - filter.addAction(ACTION_ENABLE_TRUST); + filter.addAction(ACTION_GRANT_TRUST); filter.addAction(ACTION_REVOKE_TRUST); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this); mLocalBroadcastManager.registerReceiver(mReceiver, filter); } @Override - protected void onUnlockAttempt(boolean successful) { + public void onUnlockAttempt(boolean successful) { if (getReportUnlockAttempts(this)) { Toast.makeText(this, "onUnlockAttempt(successful=" + successful + ")", Toast.LENGTH_SHORT).show(); @@ -69,8 +69,8 @@ public class SampleTrustAgent extends TrustAgentService { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); - if (ACTION_ENABLE_TRUST.equals(action)) { - enableTrust(intent.getStringExtra(EXTRA_MESSAGE), + if (ACTION_GRANT_TRUST.equals(action)) { + grantTrust(intent.getStringExtra(EXTRA_MESSAGE), intent.getLongExtra(EXTRA_DURATION, 0), false /* initiatedByUser */); } else if (ACTION_REVOKE_TRUST.equals(action)) { @@ -79,9 +79,9 @@ public class SampleTrustAgent extends TrustAgentService { } }; - public static void sendEnableTrust(Context context, + public static void sendGrantTrust(Context context, String message, long durationMs, Bundle extra) { - Intent intent = new Intent(ACTION_ENABLE_TRUST); + Intent intent = new Intent(ACTION_GRANT_TRUST); intent.putExtra(EXTRA_MESSAGE, message); intent.putExtra(EXTRA_DURATION, durationMs); intent.putExtra(EXTRA_EXTRA, extra); diff --git a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java index 0a6f675..8e293fb 100644 --- a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java +++ b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgentSettings.java @@ -19,7 +19,6 @@ package com.android.trustagent.test; import android.annotation.Nullable; import android.app.Activity; import android.os.Bundle; -import android.preference.CheckBoxPreference; import android.view.View; import android.widget.CheckBox; import android.widget.CompoundButton; @@ -53,7 +52,7 @@ public class SampleTrustAgentSettings extends Activity implements View.OnClickLi public void onClick(View v) { int id = v.getId(); if (id == R.id.enable_trust) { - SampleTrustAgent.sendEnableTrust(this, "SampleTrustAgent", TRUST_DURATION_MS, + SampleTrustAgent.sendGrantTrust(this, "SampleTrustAgent", TRUST_DURATION_MS, null /* extra */); } else if (id == R.id.revoke_trust) { SampleTrustAgent.sendRevokeTrust(this); -- cgit v1.1