Merge "Prevent crash when flattening ComponentKey to string with invalid user." into ub-launcher3-burnaby

This commit is contained in:
Winson Chung
2015-07-30 23:46:11 +00:00
committed by Android (Google) Code Review
@@ -64,8 +64,11 @@ public class ComponentKey {
* Encodes a component key as a string of the form [flattenedComponentString#userId]. * Encodes a component key as a string of the form [flattenedComponentString#userId].
*/ */
public String flattenToString(Context context) { public String flattenToString(Context context) {
return componentName.flattenToString() + "#" + String flattened = componentName.flattenToString();
UserManagerCompat.getInstance(context).getSerialNumberForUser(user); if (user != null) {
flattened += "#" + UserManagerCompat.getInstance(context).getSerialNumberForUser(user);
}
return flattened;
} }
@Override @Override