Methods Summary |
---|
public final void | grantTrust(java.lang.CharSequence message, long durationMs, boolean initiatedByUser)Call to grant trust on the device.
synchronized (mLock) {
if (!mManagingTrust) {
throw new IllegalStateException("Cannot grant trust if agent is not managing trust."
+ " Call setManagingTrust(true) first.");
}
if (mCallback != null) {
try {
mCallback.grantTrust(message.toString(), durationMs, initiatedByUser);
} catch (RemoteException e) {
onError("calling enableTrust()");
}
} else {
// Remember trust has been granted so we can effectively grant it once the service
// is bound.
mPendingGrantTrustTask = new Runnable() {
@Override
public void run() {
grantTrust(message, durationMs, initiatedByUser);
}
};
}
}
|
public final android.os.IBinder | onBind(android.content.Intent intent)
if (DEBUG) Slog.v(TAG, "onBind() intent = " + intent);
return new TrustAgentServiceWrapper();
|
public boolean | onConfigure(java.util.List options)Called when device policy admin wants to enable specific options for agent in response to
{@link DevicePolicyManager#setKeyguardDisabledFeatures(ComponentName, int)} and
{@link DevicePolicyManager#setTrustAgentConfiguration(ComponentName, ComponentName,
PersistableBundle)}.
Agents that support configuration options should overload this method and return 'true'.
return false;
|
public void | onCreate()
super.onCreate();
ComponentName component = new ComponentName(this, getClass());
try {
ServiceInfo serviceInfo = getPackageManager().getServiceInfo(component, 0 /* flags */);
if (!Manifest.permission.BIND_TRUST_AGENT.equals(serviceInfo.permission)) {
throw new IllegalStateException(component.flattenToShortString()
+ " is not declared with the permission "
+ "\"" + Manifest.permission.BIND_TRUST_AGENT + "\"");
}
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Can't get ServiceInfo for " + component.toShortString());
}
|
public void | onDeviceLocked()Called when the device enters a state where a PIN, pattern or
password must be entered to unlock it.
|
public void | onDeviceUnlocked()Called when the device leaves a state where a PIN, pattern or
password must be entered to unlock it.
|
private void | onError(java.lang.String msg)
Slog.v(TAG, "Remote exception while " + msg);
|
public void | onTrustTimeout()Called when the timeout provided by the agent expires. Note that this may be called earlier
than requested by the agent if the trust timeout is adjusted by the system or
{@link DevicePolicyManager}. The agent is expected to re-evaluate the trust state and only
call {@link #grantTrust(CharSequence, long, boolean)} if the trust state should be
continued.
|
public void | onUnlockAttempt(boolean successful)Called after the user attempts to authenticate in keyguard with their device credentials,
such as pin, pattern or password.
|
public final void | revokeTrust()Call to revoke trust on the device.
synchronized (mLock) {
if (mPendingGrantTrustTask != null) {
mPendingGrantTrustTask = null;
}
if (mCallback != null) {
try {
mCallback.revokeTrust();
} catch (RemoteException e) {
onError("calling revokeTrust()");
}
}
}
|
public final void | setManagingTrust(boolean managingTrust)Call to notify the system if the agent is ready to manage trust.
This property is not persistent across recreating the service and defaults to false.
Therefore this method is typically called when initializing the agent in {@link #onCreate}.
synchronized (mLock) {
if (mManagingTrust != managingTrust) {
mManagingTrust = managingTrust;
if (mCallback != null) {
try {
mCallback.setManagingTrust(managingTrust);
} catch (RemoteException e) {
onError("calling setManagingTrust()");
}
}
}
}
|