diff options
author | Amith Yamasani <yamasani@google.com> | 2012-09-17 12:46:01 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-17 12:46:01 -0700 |
commit | e645324e6bb42075b2e3b37d776e180a51091f96 (patch) | |
tree | 9feebeb4ebecc4d95556dea0e43b176fe45c89d1 /services | |
parent | a41d5db2350108c1d2eceb83b677faed6b7893a8 (diff) | |
parent | 3b49f07a452e0a77c1d22db2065255689a461d31 (diff) | |
download | frameworks_base-e645324e6bb42075b2e3b37d776e180a51091f96.zip frameworks_base-e645324e6bb42075b2e3b37d776e180a51091f96.tar.gz frameworks_base-e645324e6bb42075b2e3b37d776e180a51091f96.tar.bz2 |
Merge "Add UserManager.getUserIcon()" into jb-mr1-dev
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/pm/UserManagerService.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java index a58c4ea..914ff67 100644 --- a/services/java/com/android/server/pm/UserManagerService.java +++ b/services/java/com/android/server/pm/UserManagerService.java @@ -196,7 +196,7 @@ public class UserManagerService extends IUserManager.Stub { synchronized (mPackagesLock) { UserInfo info = mUsers.get(userId); if (info == null) return null; - ParcelFileDescriptor fd = updateIconBitmapLocked(info); + ParcelFileDescriptor fd = openIconBitmapLocked(info, true /* write */); if (fd != null) { writeUserLocked(info); } @@ -205,6 +205,17 @@ public class UserManagerService extends IUserManager.Stub { } @Override + public ParcelFileDescriptor getUserIcon(int userId) { + checkManageUsersPermission("read users"); + synchronized (mPackagesLock) { + UserInfo info = mUsers.get(userId); + if (info == null || info.iconPath == null) return null; + ParcelFileDescriptor fd = openIconBitmapLocked(info, false /* read */); + return fd; + } + } + + @Override public void setGuestEnabled(boolean enable) { checkManageUsersPermission("enable guest users"); synchronized (mPackagesLock) { @@ -278,7 +289,7 @@ public class UserManagerService extends IUserManager.Stub { } } - private ParcelFileDescriptor updateIconBitmapLocked(UserInfo info) { + private ParcelFileDescriptor openIconBitmapLocked(UserInfo info, boolean toWrite) { try { File dir = new File(mUsersDir, Integer.toString(info.id)); File file = new File(dir, USER_PHOTO_FILENAME); @@ -290,8 +301,10 @@ public class UserManagerService extends IUserManager.Stub { -1, -1); } ParcelFileDescriptor fd = ParcelFileDescriptor.open(file, - MODE_CREATE|MODE_READ_WRITE); - info.iconPath = file.getAbsolutePath(); + toWrite ? MODE_CREATE|MODE_READ_WRITE : MODE_READ_WRITE); + if (toWrite) { + info.iconPath = file.getAbsolutePath(); + } return fd; } catch (FileNotFoundException e) { Slog.w(LOG_TAG, "Error setting photo for user ", e); |