Add NPE check for method assignDefaultPhoto in Utils.java

When user press back button while adding user, app may crash because
of null context. In this cl, I add NPE check for context in method
assignDefaultPhoto and change this method to return boolean value.
If the return value is false, then stop the following steps(e.g.
creating a dialog after pressing button may also cause crash.)

Bug: 33829308
Test: make -j40 RunSettingsRoboTests
Change-Id: I811b92c268fb20f8c43ab3b0a9ceebe76f5d83be
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 1dbd471..248358c 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -368,10 +368,21 @@
         } catch (IOException ioe) { }
     }
 
-    public static void assignDefaultPhoto(Context context, int userId) {
+    /**
+     * Assign the default photo to user with {@paramref userId}
+     * @param context used to get the {@link UserManager}
+     * @param userId  used to get the icon bitmap
+     * @return true if assign photo successfully, false if failed
+     */
+    public static boolean assignDefaultPhoto(Context context, int userId) {
+        if (context == null) {
+            return false;
+        }
         UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
         Bitmap bitmap = getDefaultUserIconAsBitmap(userId);
         um.setUserIcon(userId, bitmap);
+
+        return true;
     }
 
     public static String getMeProfileName(Context context, boolean full) {