Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f4eb8fb authored by Jason Chiu's avatar Jason Chiu Committed by Android (Google) Code Review
Browse files

Merge "Guard against the exceptions when launching a non-existing fragment" into sc-dev

parents f421525d c38978f3
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -574,7 +574,7 @@ public class SettingsActivity extends SettingsBaseActivity
    /**
     * Switch to a specific Fragment with taking care of validation, Title and BackStack
     */
    private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
    private void switchToFragment(String fragmentName, Bundle args, boolean validate,
            int titleResId, CharSequence title) {
        Log.d(LOG_TAG, "Switching to fragment " + fragmentName);
        if (validate && !isValidFragment(fragmentName)) {
@@ -582,6 +582,9 @@ public class SettingsActivity extends SettingsBaseActivity
                    + fragmentName);
        }
        Fragment f = Utils.getTargetFragment(this, fragmentName, args);
        if (f == null) {
            return;
        }
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.main_content, f);
        if (titleResId > 0) {
@@ -592,7 +595,6 @@ public class SettingsActivity extends SettingsBaseActivity
        transaction.commitAllowingStateLoss();
        getSupportFragmentManager().executePendingTransactions();
        Log.d(LOG_TAG, "Executed frag manager pendingTransactions");
        return f;
    }

    private void updateTilesList() {
+11 −7
Original line number Diff line number Diff line
@@ -1158,14 +1158,18 @@ 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;
        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);
                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;
    }