FileDocCategorySizeDatePackage
TrustManager.javaAPI DocAndroid 5.1 API6785Thu Mar 12 22:22:10 GMT 2015android.app.trust

TrustManager

public class TrustManager extends Object
See {@link com.android.server.trust.TrustManagerService}
hide

Fields Summary
private static final int
MSG_TRUST_CHANGED
private static final int
MSG_TRUST_MANAGED_CHANGED
private static final String
TAG
private static final String
DATA_INITIATED_BY_USER
private final ITrustManager
mService
private final android.util.ArrayMap
mTrustListeners
private final android.os.Handler
mHandler
Constructors Summary
public TrustManager(android.os.IBinder b)


       
        mService = ITrustManager.Stub.asInterface(b);
        mTrustListeners = new ArrayMap<TrustListener, ITrustListener>();
    
Methods Summary
private voidonError(java.lang.Exception e)

        Log.e(TAG, "Error while calling TrustManagerService", e);
    
public voidregisterTrustListener(android.app.trust.TrustManager$TrustListener trustListener)
Registers a listener for trust events. Requires the {@link android.Manifest.permission#TRUST_LISTENER} permission.

        try {
            ITrustListener.Stub iTrustListener = new ITrustListener.Stub() {
                @Override
                public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) {
                    Message m = mHandler.obtainMessage(MSG_TRUST_CHANGED, (enabled ? 1 : 0), userId,
                            trustListener);
                    if (initiatedByUser) {
                        m.getData().putBoolean(DATA_INITIATED_BY_USER, initiatedByUser);
                    }
                    m.sendToTarget();
                }

                @Override
                public void onTrustManagedChanged(boolean managed, int userId) {
                    mHandler.obtainMessage(MSG_TRUST_MANAGED_CHANGED, (managed ? 1 : 0), userId,
                            trustListener).sendToTarget();
                }
            };
            mService.registerTrustListener(iTrustListener);
            mTrustListeners.put(trustListener, iTrustListener);
        } catch (RemoteException e) {
            onError(e);
        }
    
public voidreportEnabledTrustAgentsChanged(int userId)
Reports that the list of enabled trust agents changed for user {@param userId}. Requires the {@link android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE} permission.

        try {
            mService.reportEnabledTrustAgentsChanged(userId);
        } catch (RemoteException e) {
            onError(e);
        }
    
public voidreportKeyguardShowingChanged()
Reports that the visibility of the keyguard has changed. Requires the {@link android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE} permission.

        try {
            mService.reportKeyguardShowingChanged();
        } catch (RemoteException e) {
            onError(e);
        }
    
public voidreportRequireCredentialEntry(int userId)
Reports that trust is disabled until credentials have been entered for user {@param userId}. Requires the {@link android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE} permission.

param
userId either an explicit user id or {@link android.os.UserHandle#USER_ALL}

        try {
            mService.reportRequireCredentialEntry(userId);
        } catch (RemoteException e) {
            onError(e);
        }
    
public voidreportUnlockAttempt(boolean successful, int userId)
Reports that user {@param userId} has tried to unlock the device.

param
successful if true, the unlock attempt was successful. Requires the {@link android.Manifest.permission#ACCESS_KEYGUARD_SECURE_STORAGE} permission.

        try {
            mService.reportUnlockAttempt(successful, userId);
        } catch (RemoteException e) {
            onError(e);
        }
    
public voidunregisterTrustListener(android.app.trust.TrustManager$TrustListener trustListener)
Unregisters a listener for trust events. Requires the {@link android.Manifest.permission#TRUST_LISTENER} permission.

        ITrustListener iTrustListener = mTrustListeners.remove(trustListener);
        if (iTrustListener != null) {
            try {
                mService.unregisterTrustListener(iTrustListener);
            } catch (RemoteException e) {
                onError(e);
            }
        }