Fields Summary |
---|
private static final String | EXTRA_COMPONENT_NAME |
private static final String | TRUST_EXPIRED_ACTION |
private static final String | PERMISSION |
private static final boolean | DEBUG |
private static final String | TAG |
private static final int | MSG_GRANT_TRUST |
private static final int | MSG_REVOKE_TRUST |
private static final int | MSG_TRUST_TIMEOUT |
private static final int | MSG_RESTART_TIMEOUT |
private static final int | MSG_SET_TRUST_AGENT_FEATURES_COMPLETED |
private static final int | MSG_MANAGING_TRUST |
private static final long | RESTART_TIMEOUT_MILLISTime in uptime millis that we wait for the service connection, both when starting
and when the service disconnects. |
private static final String | DATA_DURATIONLong extra for {@link #MSG_GRANT_TRUST} |
private final TrustManagerService | mTrustManagerService |
private final int | mUserId |
private final android.content.Context | mContext |
private final android.content.ComponentName | mName |
private android.service.trust.ITrustAgentService | mTrustAgentService |
private boolean | mBound |
private long | mScheduledRestartUptimeMillis |
private long | mMaximumTimeToLock |
private boolean | mTrusted |
private CharSequence | mMessage |
private boolean | mTrustDisabledByDpm |
private boolean | mManagingTrust |
private android.os.IBinder | mSetTrustAgentFeaturesToken |
private android.app.AlarmManager | mAlarmManager |
private final android.content.Intent | mAlarmIntent |
private android.app.PendingIntent | mAlarmPendingIntent |
private final android.content.BroadcastReceiver | mBroadcastReceiver |
private final android.os.Handler | mHandler |
private android.service.trust.ITrustAgentServiceCallback | mCallback |
private final android.content.ServiceConnection | mConnection |
Methods Summary |
---|
public void | destroy()
mHandler.removeMessages(MSG_RESTART_TIMEOUT);
if (!mBound) {
return;
}
if (DEBUG) Log.v(TAG, "TrustAgent unbound : " + mName.flattenToShortString());
mTrustManagerService.mArchive.logAgentStopped(mUserId, mName);
mContext.unbindService(mConnection);
mBound = false;
mTrustAgentService = null;
mSetTrustAgentFeaturesToken = null;
mHandler.sendEmptyMessage(MSG_REVOKE_TRUST);
|
public java.lang.CharSequence | getMessage()
return mMessage;
|
public long | getScheduledRestartUptimeMillis()If not connected, returns the time at which the agent is restarted.
return mScheduledRestartUptimeMillis;
|
public boolean | isBound()
return mBound;
|
public boolean | isConnected()
return mTrustAgentService != null;
|
public boolean | isManagingTrust()
return mManagingTrust && !mTrustDisabledByDpm;
|
public boolean | isTrusted()
return mTrusted && mManagingTrust && !mTrustDisabledByDpm;
|
public void | onDeviceLocked()
try {
if (mTrustAgentService != null) mTrustAgentService.onDeviceLocked();
} catch (RemoteException e) {
onError(e);
}
|
public void | onDeviceUnlocked()
try {
if (mTrustAgentService != null) mTrustAgentService.onDeviceUnlocked();
} catch (RemoteException e) {
onError(e);
}
|
private void | onError(java.lang.Exception e)
Slog.w(TAG , "Remote Exception", e);
|
private void | onTrustTimeout()
try {
if (mTrustAgentService != null) mTrustAgentService.onTrustTimeout();
} catch (RemoteException e) {
onError(e);
}
|
public void | onUnlockAttempt(boolean successful)
try {
if (mTrustAgentService != null) mTrustAgentService.onUnlockAttempt(successful);
} catch (RemoteException e) {
onError(e);
}
|
private void | scheduleRestart()
mHandler.removeMessages(MSG_RESTART_TIMEOUT);
mScheduledRestartUptimeMillis = SystemClock.uptimeMillis() + RESTART_TIMEOUT_MILLIS;
mHandler.sendEmptyMessageAtTime(MSG_RESTART_TIMEOUT, mScheduledRestartUptimeMillis);
|
private void | setCallback(android.service.trust.ITrustAgentServiceCallback callback)
try {
if (mTrustAgentService != null) {
mTrustAgentService.setCallback(callback);
}
} catch (RemoteException e) {
onError(e);
}
|
boolean | updateDevicePolicyFeatures()
boolean trustDisabled = false;
if (DEBUG) Slog.v(TAG, "updateDevicePolicyFeatures(" + mName + ")");
try {
if (mTrustAgentService != null) {
DevicePolicyManager dpm =
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
if ((dpm.getKeyguardDisabledFeatures(null, mUserId)
& DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0) {
List<PersistableBundle> config = dpm.getTrustAgentConfiguration(
null, mName, mUserId);
trustDisabled = true;
if (DEBUG) Slog.v(TAG, "Detected trust agents disabled. Config = " + config);
if (config != null && config.size() > 0) {
if (DEBUG) {
Slog.v(TAG, "TrustAgent " + mName.flattenToShortString()
+ " disabled until it acknowledges "+ config);
}
mSetTrustAgentFeaturesToken = new Binder();
mTrustAgentService.onConfigure(config, mSetTrustAgentFeaturesToken);
}
}
final long maxTimeToLock = dpm.getMaximumTimeToLock(null);
if (maxTimeToLock != mMaximumTimeToLock) {
// If the timeout changes, cancel the alarm and send a timeout event to have
// the agent re-evaluate trust.
mMaximumTimeToLock = maxTimeToLock;
if (mAlarmPendingIntent != null) {
mAlarmManager.cancel(mAlarmPendingIntent);
mAlarmPendingIntent = null;
mHandler.sendEmptyMessage(MSG_TRUST_TIMEOUT);
}
}
}
} catch (RemoteException e) {
onError(e);
}
if (mTrustDisabledByDpm != trustDisabled) {
mTrustDisabledByDpm = trustDisabled;
mTrustManagerService.updateTrust(mUserId, false);
}
return trustDisabled;
|