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

Commit 86e3b12f authored by Ivo Kay's avatar Ivo Kay Committed by Android (Google) Code Review
Browse files

Merge "Use both passed and activity record options to determine activity source" into main

parents c6778fd9 f31bc898
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