Set user icon to default when updating profile without photo

If the user photo was deleted in the Myself contact, the change
was not reflected neither in Settings/Users nor in expanded
status bar. This was because the ProfileUpdateReceiver did not
handle the case where the updated image was null (deleted).
Fixed by assigning default user icon in UserManager if no photo
found in the profile update.

AOSP change: https://android-review.googlesource.com/#/c/153137

Bug: 28031914
Change-Id: I2f452f78dcf777414f50b133b1a9cee334bbd9a8
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 4dd203c..9693ed9 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -336,24 +336,31 @@
     }
 
     /* Used by UserSettings as well. Call this on a non-ui thread. */
-    public static boolean copyMeProfilePhoto(Context context, UserInfo user) {
+    public static void copyMeProfilePhoto(Context context, UserInfo user) {
         Uri contactUri = Profile.CONTENT_URI;
 
+        int userId = user != null ? user.id : UserHandle.myUserId();
+
         InputStream avatarDataStream = Contacts.openContactPhotoInputStream(
                     context.getContentResolver(),
                     contactUri, true);
         // If there's no profile photo, assign a default avatar
         if (avatarDataStream == null) {
-            return false;
+            assignDefaultPhoto(context, userId);
+        } else {
+            UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+            Bitmap icon = BitmapFactory.decodeStream(avatarDataStream);
+            um.setUserIcon(userId, icon);
         }
-        int userId = user != null ? user.id : UserHandle.myUserId();
-        UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
-        Bitmap icon = BitmapFactory.decodeStream(avatarDataStream);
-        um.setUserIcon(userId, icon);
         try {
             avatarDataStream.close();
         } catch (IOException ioe) { }
-        return true;
+    }
+
+    public static void assignDefaultPhoto(Context context, int userId) {
+        UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
+        Bitmap bitmap = getDefaultUserIconAsBitmap(userId);
+        um.setUserIcon(userId, bitmap);
     }
 
     public static String getMeProfileName(Context context, boolean full) {