summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/Utils.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-09-17 18:31:45 -0700
committerAmith Yamasani <yamasani@google.com>2012-09-17 22:47:37 -0700
commitf34a85d5d54738b4b6d091c36f828788ff67ede1 (patch)
tree2d2b4333ad296fca8edb5047c0c0e2dad7078d89 /src/com/android/settings/Utils.java
parent64c6ee20bae6cbf868ec4a0a3ffc7ce6fd10bdd6 (diff)
downloadpackages_apps_settings-f34a85d5d54738b4b6d091c36f828788ff67ede1.zip
packages_apps_settings-f34a85d5d54738b4b6d091c36f828788ff67ede1.tar.gz
packages_apps_settings-f34a85d5d54738b4b6d091c36f828788ff67ede1.tar.bz2
Use Bitmap instead of ParcelFileDescriptor to get the user's icon.
Change-Id: I1dd7261b47ba98a2a0834dbfb8c22de369e6cc58
Diffstat (limited to 'src/com/android/settings/Utils.java')
-rw-r--r--src/com/android/settings/Utils.java24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 1d4a6da..1a5c82c 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -27,6 +27,8 @@ import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.LinkProperties;
@@ -473,24 +475,12 @@ public class Utils {
}
int userId = user != null ? user.id : UserHandle.myUserId();
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
- ParcelFileDescriptor fd = um.setUserIcon(userId);
- FileOutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
- byte[] buffer = new byte[4096];
- int readSize;
+ Bitmap icon = BitmapFactory.decodeStream(avatarDataStream);
+ um.setUserIcon(userId, icon);
try {
- while ((readSize = avatarDataStream.read(buffer)) > 0) {
- os.write(buffer, 0, readSize);
- }
- return true;
- } catch (IOException ioe) {
- Log.e("copyProfilePhoto", "Error copying profile photo " + ioe);
- } finally {
- try {
- os.close();
- avatarDataStream.close();
- } catch (IOException ioe) { }
- }
- return false;
+ avatarDataStream.close();
+ } catch (IOException ioe) { }
+ return true;
}
public static String getMeProfileName(Context context) {