Guard against the exceptions when launching a non-existing fragment
Test: robotest Bug: 190371550 Change-Id: I2bb7d4bdb23756634526db7e272563a1587c9640
This commit is contained in:
@@ -1158,13 +1158,17 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
== ProfileSelectFragment.ProfileType.PERSONAL : false;
|
||||
final boolean isWork = args != null ? args.getInt(ProfileSelectFragment.EXTRA_PROFILE)
|
||||
== ProfileSelectFragment.ProfileType.WORK : false;
|
||||
if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
|
||||
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
|
||||
&& !isWork && !isPersonal) {
|
||||
f = Fragment.instantiate(activity, ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName),
|
||||
args);
|
||||
} else {
|
||||
f = Fragment.instantiate(activity, fragmentName, args);
|
||||
try {
|
||||
if (activity.getSystemService(UserManager.class).getUserProfiles().size() > 1
|
||||
&& ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName) != null
|
||||
&& !isWork && !isPersonal) {
|
||||
f = Fragment.instantiate(activity,
|
||||
ProfileFragmentBridge.FRAGMENT_MAP.get(fragmentName), args);
|
||||
} else {
|
||||
f = Fragment.instantiate(activity, fragmentName, args);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Unable to get target fragment", e);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user