From c86c3fdd9a0307b8df6e4bed70f9e514f911858b Mon Sep 17 00:00:00 2001 From: Fyodor Kupolov Date: Mon, 18 Apr 2016 13:57:31 -0700 Subject: [PATCH] Return null when user is locked In getUserData, peekAuthToken return null instead of crashing when a user is locked. As per JavaDoc authenticators are expected to handle null return values. Bug: 28217043 Change-Id: I06d5a2965fe685cad21215958d5d94f413f77677 --- .../android/server/accounts/AccountManagerService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/core/java/com/android/server/accounts/AccountManagerService.java b/services/core/java/com/android/server/accounts/AccountManagerService.java index 47918187e22ae..49cf834093827 100644 --- a/services/core/java/com/android/server/accounts/AccountManagerService.java +++ b/services/core/java/com/android/server/accounts/AccountManagerService.java @@ -828,6 +828,10 @@ public class AccountManagerService account.type); throw new SecurityException(msg); } + if (!isUserUnlocked(userId)) { + Log.w(TAG, "User " + userId + " data is locked. callingUid " + callingUid); + return null; + } long identityToken = clearCallingIdentity(); try { UserAccounts accounts = getUserAccounts(userId); @@ -1788,6 +1792,11 @@ public class AccountManagerService account.type); throw new SecurityException(msg); } + if (!isUserUnlocked(userId)) { + Log.w(TAG, "Authtoken not available - user " + userId + " data is locked. callingUid " + + callingUid); + return null; + } long identityToken = clearCallingIdentity(); try { UserAccounts accounts = getUserAccounts(userId);