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

Commit f31bc898 authored by Ivo Kay's avatar Ivo Kay
Browse files

Use both passed and activity record options to determine activity source

Test: manual, regression tests
Bug: 404763922
Flag: EXEMPT, bugfix
Change-Id: I64edee51fab4c491cb82da39a54d39f66bdb0c7b
parent d70786ae
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -370,15 +370,14 @@ class ActivityMetricsLogger {
            if (launchingState.mAssociatedTransitionInfo == null) {
                launchingState.mAssociatedTransitionInfo = this;
            }
            if (options != null) {
                final SourceInfo sourceInfo = options.getSourceInfo();

            final SourceInfo sourceInfo = getSourceInfo(options, r.getOptions());
            if (sourceInfo != null) {
                mSourceType = sourceInfo.type;
                mSourceEventDelayMs = (int) (TimeUnit.NANOSECONDS.toMillis(
                        launchingState.mStartUptimeNs) - sourceInfo.eventTimeMs);
            }
        }
        }

        /**
         * Remembers the latest launched activity to represent the final transition. This also
@@ -409,6 +408,23 @@ class ActivityMetricsLogger {
            mIsDrawn = r.isReportedDrawn();
        }

        /**
         * Obtains {@link android.app.ActivityOptions.SourceInfo} from {@code activityRecordOptions}
         * if {@code passedOptions} do not have source information recorded.
         * <p>
         * This is necessary to correctly determine source info in cases where it is present in the
         * activity options supplied to {@code PendingIntent.send} (used to create
         * {@code activityRecordOptions}), rather than in the pending intent that launches activity
         * (used to create {@code passedOptions}).
         */
        private @Nullable SourceInfo getSourceInfo(@Nullable ActivityOptions passedOptions,
                @Nullable ActivityOptions activityRecordOptions) {
            if (passedOptions != null && passedOptions.getSourceInfo() != null) {
                return passedOptions.getSourceInfo();
            }
            return activityRecordOptions != null ? activityRecordOptions.getSourceInfo() : null;
        }

        /** Returns {@code true} if the incoming activity can belong to this transition. */
        boolean canCoalesce(ActivityRecord r) {
            if (mLastLaunchedActivity.mDisplayContent != r.mDisplayContent