Merge "New api in LockSettingsService to get StrongAuth synchronously" into nyc-dev
am: d86ac8116b
* commit 'd86ac8116bfc64c61d8124ff8d3e92be5e55cd3e':
New api in LockSettingsService to get StrongAuth synchronously
Change-Id: I07d18fd5c472f1ab3f3ad4c37583e9092f4431b4
This commit is contained in:
@@ -44,4 +44,5 @@ interface ILockSettings {
|
|||||||
void requireStrongAuth(int strongAuthReason, int userId);
|
void requireStrongAuth(int strongAuthReason, int userId);
|
||||||
void systemReady();
|
void systemReady();
|
||||||
void userPresent(int userId);
|
void userPresent(int userId);
|
||||||
|
int getStrongAuthForUser(int userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
* Tracks the global strong authentication state.
|
||||||
*/
|
*/
|
||||||
@@ -1556,9 +1582,8 @@ public class LockPatternUtils {
|
|||||||
public void onStrongAuthRequiredChanged(int userId) {
|
public void onStrongAuthRequiredChanged(int userId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
|
protected void handleStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
|
||||||
int userId) {
|
int userId) {
|
||||||
|
|
||||||
int oldValue = getStrongAuthForUser(userId);
|
int oldValue = getStrongAuthForUser(userId);
|
||||||
if (strongAuthFlags != oldValue) {
|
if (strongAuthFlags != oldValue) {
|
||||||
if (strongAuthFlags == mDefaultStrongAuthFlags) {
|
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
|
@Override
|
||||||
public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
|
public void onStrongAuthRequiredChanged(@StrongAuthFlags int strongAuthFlags,
|
||||||
int userId) {
|
int userId) {
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ public class LockSettingsService extends ILockSettings.Stub {
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final LockSettingsStorage mStorage;
|
private final LockSettingsStorage mStorage;
|
||||||
private final LockSettingsStrongAuth mStrongAuth;
|
private final LockSettingsStrongAuth mStrongAuth;
|
||||||
|
private final SynchronizedStrongAuthTracker mStrongAuthTracker;
|
||||||
|
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private boolean mFirstCallToVold;
|
private boolean mFirstCallToVold;
|
||||||
@@ -177,6 +178,30 @@ public class LockSettingsService extends ILockSettings.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SynchronizedStrongAuthTracker extends LockPatternUtils.StrongAuthTracker {
|
||||||
|
public SynchronizedStrongAuthTracker(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleStrongAuthRequiredChanged(int strongAuthFlags, int userId) {
|
||||||
|
synchronized (this) {
|
||||||
|
super.handleStrongAuthRequiredChanged(strongAuthFlags, userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStrongAuthForUser(int userId) {
|
||||||
|
synchronized (this) {
|
||||||
|
return super.getStrongAuthForUser(userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void register() {
|
||||||
|
mStrongAuth.registerStrongAuthTracker(this.mStub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tie managed profile to primary profile if it is in unified mode and not tied before.
|
* Tie managed profile to primary profile if it is in unified mode and not tied before.
|
||||||
*
|
*
|
||||||
@@ -245,6 +270,9 @@ public class LockSettingsService extends ILockSettings.Stub {
|
|||||||
mNotificationManager = (NotificationManager)
|
mNotificationManager = (NotificationManager)
|
||||||
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||||
|
mStrongAuthTracker = new SynchronizedStrongAuthTracker(mContext);
|
||||||
|
mStrongAuthTracker.register();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1398,6 +1426,12 @@ public class LockSettingsService extends ILockSettings.Stub {
|
|||||||
mStrongAuth.reportUnlock(userId);
|
mStrongAuth.reportUnlock(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStrongAuthForUser(int userId) {
|
||||||
|
checkPasswordReadPermission(userId);
|
||||||
|
return mStrongAuthTracker.getStrongAuthForUser(userId);
|
||||||
|
}
|
||||||
|
|
||||||
private static final String[] VALID_SETTINGS = new String[] {
|
private static final String[] VALID_SETTINGS = new String[] {
|
||||||
LockPatternUtils.LOCKOUT_PERMANENT_KEY,
|
LockPatternUtils.LOCKOUT_PERMANENT_KEY,
|
||||||
LockPatternUtils.LOCKOUT_ATTEMPT_DEADLINE,
|
LockPatternUtils.LOCKOUT_ATTEMPT_DEADLINE,
|
||||||
|
|||||||
Reference in New Issue
Block a user