New api in LockSettingsService to get StrongAuth synchronously

Not all client needs to monitor the StrongAuth, e.g. ConfirmDeviceCredentialBaseFragment
Provide a quick method to get StrongAuth

Bug: 28752364
Change-Id: Iecfd217046da38e43297bdd5832cf7d637b979ed
This commit is contained in:
Victor Chang
2016-05-16 19:36:08 +01:00
parent 8e96faae78
commit a0940d33dc
3 changed files with 63 additions and 3 deletions

View File

@@ -44,4 +44,5 @@ interface ILockSettings {
void requireStrongAuth(int strongAuthReason, int userId);
void systemReady();
void userPresent(int userId);
int getStrongAuthForUser(int userId);
}

View File

@@ -1451,6 +1451,32 @@ public class LockPatternUtils {
}
}
/**
* @see StrongAuthTracker#getStrongAuthForUser
*/
public int getStrongAuthForUser(int userId) {
try {
return getLockSettings().getStrongAuthForUser(userId);
} catch (RemoteException e) {
Log.e(TAG, "Could not get StrongAuth", e);
return StrongAuthTracker.getDefaultFlags(mContext);
}
}
/**
* @see StrongAuthTracker#isTrustAllowedForUser
*/
public boolean isTrustAllowedForUser(int userId) {
return getStrongAuthForUser(userId) == StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
}
/**
* @see StrongAuthTracker#isFingerprintAllowedForUser
*/
public boolean isFingerprintAllowedForUser(int userId) {
return (getStrongAuthForUser(userId) & ~StrongAuthTracker.ALLOWING_FINGERPRINT) == 0;
}
/**
* Tracks the global strong authentication state.
*/
@@ -1556,9 +1582,8 @@ public class LockPatternUtils {
public void onStrongAuthRequiredChanged(int userId) {
}
void handleStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
protected void handleStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
int userId) {
int oldValue = getStrongAuthForUser(userId);
if (strongAuthFlags != oldValue) {
if (strongAuthFlags == mDefaultStrongAuthFlags) {
@@ -1571,7 +1596,7 @@ public class LockPatternUtils {
}
final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() {
protected final IStrongAuthTracker.Stub mStub = new IStrongAuthTracker.Stub() {
@Override
public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
int userId) {