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

Commit 1ac286d1 authored by Yisroel Forta's avatar Yisroel Forta
Browse files

Update startinfo equals for intent

With intent now persisting package behind a flag, update
appstartinfo equals to check intent.

For tests, update component to use the regular (not short) class
name. This is necessary because ComponentName equals does not
match short and long classname, this should possibly be fixed
separately and then updated here.

Test: run all appstartinfo tests with flag enabled and disabled
Bug: 369856202
Flag: android.content.flags.intent_save_to_xml_package

Change-Id: If13803ff61fb04518d3e9f526a85a62774265af7
parent c9585939
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -1082,6 +1082,15 @@ public final class ApplicationStartInfo implements Parcelable {


        final ApplicationStartInfo o = (ApplicationStartInfo) other;
        final ApplicationStartInfo o = (ApplicationStartInfo) other;


        boolean intentEquals = true;
        if (android.content.flags.Flags.intentSaveToXmlPackage()) {
            if (mStartIntent == null) {
                intentEquals = o.mStartIntent == null;
            } else {
                intentEquals = mStartIntent.filterEquals(o.mStartIntent);
            }
        }

        return mPid == o.mPid
        return mPid == o.mPid
                && mRealUid == o.mRealUid
                && mRealUid == o.mRealUid
                && mPackageUid == o.mPackageUid
                && mPackageUid == o.mPackageUid
@@ -1095,14 +1104,16 @@ public final class ApplicationStartInfo implements Parcelable {
                && timestampsEquals(o)
                && timestampsEquals(o)
                && mWasForceStopped == o.mWasForceStopped
                && mWasForceStopped == o.mWasForceStopped
                && mMonotonicCreationTimeMs == o.mMonotonicCreationTimeMs
                && mMonotonicCreationTimeMs == o.mMonotonicCreationTimeMs
                && mStartComponent == o.mStartComponent;
                && mStartComponent == o.mStartComponent
                && intentEquals;
    }
    }


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(mPid, mRealUid, mPackageUid, mDefiningUid, mReason, mStartupState,
        return Objects.hash(mPid, mRealUid, mPackageUid, mDefiningUid, mReason, mStartupState,
                mStartType, mLaunchMode, mPackageName, mProcessName, mStartupTimestampsNs,
                mStartType, mLaunchMode, mPackageName, mProcessName, mStartupTimestampsNs,
                mMonotonicCreationTimeMs, mStartComponent);
                mMonotonicCreationTimeMs, mStartComponent,
                android.content.flags.Flags.intentSaveToXmlPackage() ? mStartIntent : null);
    }
    }


    private boolean timestampsEquals(@NonNull ApplicationStartInfo other) {
    private boolean timestampsEquals(@NonNull ApplicationStartInfo other) {
+2 −1
Original line number Original line Diff line number Diff line
@@ -79,7 +79,8 @@ import java.util.ArrayList;
public class ApplicationStartInfoTest {
public class ApplicationStartInfoTest {


    private static final String TAG = ApplicationStartInfoTest.class.getSimpleName();
    private static final String TAG = ApplicationStartInfoTest.class.getSimpleName();
    private static final ComponentName COMPONENT = new ComponentName("com.android.test", ".Foo");
    private static final ComponentName COMPONENT =
            new ComponentName("com.android.test", "com.android.test.Foo");


    private static final int APP_1_UID = 10123;
    private static final int APP_1_UID = 10123;
    private static final int APP_1_PID_1 = 12345;
    private static final int APP_1_PID_1 = 12345;