List of usage examples for android.os UserManager isUserUnlocked
public boolean isUserUnlocked()
From source file:com.android.car.trust.CarBleTrustAgent.java
@Override public void onCreate() { super.onCreate(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Bluetooth trust agent starting up"); }//from w w w . jav a2 s . c o m IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_REVOKE_TRUST); filter.addAction(ACTION_ADD_TOKEN); filter.addAction(ACTION_IS_TOKEN_ACTIVE); filter.addAction(ACTION_REMOVE_TOKEN); mLocalBroadcastManager = LocalBroadcastManager.getInstance(this /* context */); mLocalBroadcastManager.registerReceiver(mTrustEventReceiver, filter); // If the user is already unlocked, don't bother starting the BLE service. UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); if (!um.isUserUnlocked()) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "User locked, will now bind CarUnlockService"); } Intent intent = new Intent(this, CarUnlockService.class); bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE); } else { setManagingTrust(true); } }
From source file:com.android.car.trust.CarBleTrustAgent.java
private void unlock(byte[] token, long handle) { UserManager um = (UserManager) getSystemService(Context.USER_SERVICE); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "About to unlock user. Current handle: " + handle + " Time: " + System.currentTimeMillis()); }/*from w w w. j a va2 s .c o m*/ unlockUserWithToken(handle, token, getCurrentUserHandle()); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Attempted to unlock user, is user unlocked? " + um.isUserUnlocked() + " Time: " + System.currentTimeMillis()); } setManagingTrust(true); if (um.isUserUnlocked()) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, getString(R.string.trust_granted_explanation)); } grantTrust("Granting trust from escrow token", TRUST_DURATION_MS, FLAG_GRANT_TRUST_DISMISS_KEYGUARD); // Trust has been granted, disable the BLE server. This trust agent service does // not need to receive additional BLE data. unbindService(mServiceConnection); } }