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

Commit 221f15d4 authored by Aurimas Liutikas's avatar Aurimas Liutikas
Browse files

Fix/suppress error-prone warnings in framework's fragment.

Bug: 37537860
Test: Compile
Change-Id: I0f30c423a712819ee78d16764acf20386360240f
parent 13dbbaf5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -890,6 +890,7 @@ final class BackStackRecord extends FragmentTransaction implements
     *                      this set of ops
     * @return the new oldPrimaryNav fragment after this record's ops would be run
     */
    @SuppressWarnings("ReferenceEquality")
    Fragment expandOps(ArrayList<Fragment> added, Fragment oldPrimaryNav) {
        for (int opNum = 0; opNum < mOps.size(); opNum++) {
            final Op op = mOps.get(opNum);
+8 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.widget.AdapterView;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;

final class FragmentState implements Parcelable {
    final String mClassName;
@@ -616,7 +617,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
                }
                sClassMap.put(fname, clazz);
            }
            Fragment f = (Fragment)clazz.newInstance();
            Fragment f = (Fragment) clazz.getConstructor().newInstance();
            if (args != null) {
                args.setClassLoader(f.getClass().getClassLoader());
                f.setArguments(args);
@@ -634,6 +635,12 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
            throw new InstantiationException("Unable to instantiate fragment " + fname
                    + ": make sure class name exists, is public, and has an"
                    + " empty constructor that is public", e);
        } catch (NoSuchMethodException e) {
            throw new InstantiationException("Unable to instantiate fragment " + fname
                    + ": could not find Fragment constructor", e);
        } catch (InvocationTargetException e) {
            throw new InstantiationException("Unable to instantiate fragment " + fname
                    + ": calling Fragment constructor caused an exception", e);
        }
    }

+9 −0
Original line number Diff line number Diff line
@@ -1095,6 +1095,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
        return mCurState >= state;
    }

    @SuppressWarnings("ReferenceEquality")
    void moveToState(Fragment f, int newState, int transit, int transitionStyle,
            boolean keepActive) {
        if (DEBUG && false) Log.v(TAG, "moveToState: " + f
@@ -1193,6 +1194,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                        }
                        f.mRetaining = false;
                    }
                    // fall through
                case Fragment.CREATED:
                    // This is outside the if statement below on purpose; we want this to run
                    // even if we do a moveToState from CREATED => *, CREATED => CREATED, and
@@ -1253,16 +1255,19 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                        }
                        f.mSavedFragmentState = null;
                    }
                    // fall through
                case Fragment.ACTIVITY_CREATED:
                    if (newState > Fragment.ACTIVITY_CREATED) {
                        f.mState = Fragment.STOPPED;
                    }
                    // fall through
                case Fragment.STOPPED:
                    if (newState > Fragment.STOPPED) {
                        if (DEBUG) Log.v(TAG, "moveto STARTED: " + f);
                        f.performStart();
                        dispatchOnFragmentStarted(f, false);
                    }
                    // fall through
                case Fragment.STARTED:
                    if (newState > Fragment.STARTED) {
                        if (DEBUG) Log.v(TAG, "moveto RESUMED: " + f);
@@ -1281,12 +1286,14 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                        f.performPause();
                        dispatchOnFragmentPaused(f, false);
                    }
                    // fall through
                case Fragment.STARTED:
                    if (newState < Fragment.STARTED) {
                        if (DEBUG) Log.v(TAG, "movefrom STARTED: " + f);
                        f.performStop();
                        dispatchOnFragmentStopped(f, false);
                    }
                    // fall through
                case Fragment.STOPPED:
                case Fragment.ACTIVITY_CREATED:
                    if (newState < Fragment.ACTIVITY_CREATED) {
@@ -1338,6 +1345,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
                        f.mView = null;
                        f.mInLayout = false;
                    }
                    // fall through
                case Fragment.CREATED:
                    if (newState < Fragment.CREATED) {
                        if (mDestroyed) {
@@ -3047,6 +3055,7 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate
        }
    }

    @SuppressWarnings("ReferenceEquality")
    public void setPrimaryNavigationFragment(Fragment f) {
        if (f != null && (mActive.get(f.mIndex) != f
                || (f.mHost != null && f.getFragmentManager() != this))) {
+2 −1
Original line number Diff line number Diff line
@@ -1236,6 +1236,7 @@ class FragmentTransition {
     *                               added fragments have Views in the hierarchy or false if the
     *                               operations haven't been executed yet.
     */
    @SuppressWarnings("ReferenceEquality")
    private static void addToFirstInLastOut(BackStackRecord transaction, BackStackRecord.Op op,
            SparseArray<FragmentContainerTransition> transitioningFragments, boolean isPop,
            boolean isOptimizedTransaction) {
@@ -1305,7 +1306,7 @@ class FragmentTransition {
                containerTransition.firstOut = null;
            }

            /**
            /*
             * Ensure that fragments that are entering are at least at the CREATED state
             * so that they may load Transitions using TransitionInflater.
             */