Credential FRP: Add ACTION_CONFIRM_FRP_CREDENTIAL to ConfirmCredential

Bug: 36814845
Test: adb shell settings put global device_provisioned 0 && adb shell am start -a android.app.action.CONFIRM_FRP_CREDENTIAL
Change-Id: Id6ce6bc5ebd9c9e2a88790cc800678aff50e580f
This commit is contained in:
Adrian Roos
2017-03-30 18:02:25 -07:00
parent 6ac7b8c6be
commit 5a9a3cde62
7 changed files with 78 additions and 16 deletions

View File

@@ -1012,7 +1012,24 @@ public final class Utils extends com.android.settingslib.Utils {
return getCredentialOwnerUserId(context);
}
int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
return enforceSameOwner(context, userId);
if (userId == LockPatternUtils.USER_FRP) {
return enforceSystemUser(context, userId);
} else {
return enforceSameOwner(context, userId);
}
}
/**
* Returns the given user id if the current user is the system user.
*
* @throws SecurityException if the current user is not the system user.
*/
public static int enforceSystemUser(Context context, int userId) {
if (UserHandle.myUserId() == UserHandle.USER_SYSTEM) {
return userId;
}
throw new SecurityException("Given user id " + userId + " must only be used from "
+ "USER_SYSTEM, but current user is " + UserHandle.myUserId());
}
/**