Merge "Cache IMountService for isUserKeyUnlocked() calls." into nyc-dev am: 36cbf5ca37

am: 6843da1aa8

* commit '6843da1aa8da6374dde23ef20bad2abfed6aaba2':
  Cache IMountService for isUserKeyUnlocked() calls.

Change-Id: Ie9aff29f7488bd78d13c6915874a3d1ef53e6715
This commit is contained in:
Jeff Sharkey
2016-05-27 03:00:53 +00:00
committed by android-build-merger

View File

@@ -114,6 +114,8 @@ public class StorageManager {
/** {@hide} */
public static final int FLAG_INCLUDE_INVISIBLE = 1 << 10;
private static volatile IMountService sMountService = null;
private final Context mContext;
private final ContentResolver mResolver;
@@ -1064,15 +1066,17 @@ public class StorageManager {
/** {@hide} */
public static boolean isUserKeyUnlocked(int userId) {
final IMountService mount = IMountService.Stub
.asInterface(ServiceManager.getService("mount"));
if (mount == null) {
if (sMountService == null) {
sMountService = IMountService.Stub
.asInterface(ServiceManager.getService("mount"));
}
if (sMountService == null) {
Slog.w(TAG, "Early during boot, assuming locked");
return false;
}
final long token = Binder.clearCallingIdentity();
try {
return mount.isUserKeyUnlocked(userId);
return sMountService.isUserKeyUnlocked(userId);
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
} finally {