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

Commit f26047b7 authored by Chris Li's avatar Chris Li
Browse files

Add ActivityWindowInfo into LaunchActivityItem

Bug: 287582673
Test: atest FrameworksCoreTests:ObjectPoolTests
Test: atest FrameworksCoreTests:TransactionParcelTests
Change-Id: I96b9fcd7334842b9ba717c49362e84f6c76a1aeb
parent 8f727bc4
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ import android.view.contentcapture.IContentCaptureOptionsCallback;
import android.view.translation.TranslationSpec;
import android.view.translation.UiTranslationSpec;
import android.webkit.WebView;
import android.window.ActivityWindowInfo;
import android.window.ITaskFragmentOrganizer;
import android.window.SizeConfigurationBuckets;
import android.window.SplashScreen;
@@ -603,6 +604,9 @@ public final class ActivityThread extends ClientTransactionHandler
        boolean hideForNow;
        Configuration createdConfig;
        Configuration overrideConfig;
        @NonNull
        private ActivityWindowInfo mActivityWindowInfo;

        // Used for consolidating configs before sending on to Activity.
        private final Configuration tmpConfig = new Configuration();
        // Callback used for updating activity override config and camera compat control state.
@@ -670,7 +674,8 @@ public final class ActivityThread extends ClientTransactionHandler
                List<ReferrerIntent> pendingNewIntents, SceneTransitionInfo sceneTransitionInfo,
                boolean isForward, ProfilerInfo profilerInfo, ClientTransactionHandler client,
                IBinder assistToken, IBinder shareableActivityToken, boolean launchedFromBubble,
                IBinder taskFragmentToken, IBinder initialCallerInfoAccessToken) {
                IBinder taskFragmentToken, IBinder initialCallerInfoAccessToken,
                ActivityWindowInfo activityWindowInfo) {
            this.token = token;
            this.assistToken = assistToken;
            this.shareableActivityToken = shareableActivityToken;
@@ -691,6 +696,7 @@ public final class ActivityThread extends ClientTransactionHandler
            mSceneTransitionInfo = sceneTransitionInfo;
            mLaunchedFromBubble = launchedFromBubble;
            mTaskFragmentToken = taskFragmentToken;
            mActivityWindowInfo = activityWindowInfo;
            init();
        }

@@ -779,6 +785,11 @@ public final class ActivityThread extends ClientTransactionHandler
            return activity != null && activity.mVisibleFromServer;
        }

        @NonNull
        public ActivityWindowInfo getActivityWindowInfo() {
            return mActivityWindowInfo;
        }

        public String toString() {
            ComponentName componentName = intent != null ? intent.getComponent() : null;
            return "ActivityRecord{"
+21 −8
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.os.IBinder;
import android.os.Parcel;
import android.os.PersistableBundle;
import android.os.Trace;
import android.window.ActivityWindowInfo;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IVoiceInteractor;
@@ -81,6 +82,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
    private boolean mLaunchedFromBubble;
    private IBinder mTaskFragmentToken;
    private IBinder mInitialCallerInfoAccessToken;
    private ActivityWindowInfo mActivityWindowInfo;

    /**
     * It is only non-null if the process is the first time to launch activity. It is only an
     * optimization for quick look up of the interface so the field is ignored for comparison.
@@ -107,7 +110,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
                mOverrideConfig, mReferrer, mVoiceInteractor, mState, mPersistentState,
                mPendingResults, mPendingNewIntents, mSceneTransitionInfo, mIsForward,
                mProfilerInfo, client, mAssistToken, mShareableActivityToken, mLaunchedFromBubble,
                mTaskFragmentToken, mInitialCallerInfoAccessToken);
                mTaskFragmentToken, mInitialCallerInfoAccessToken, mActivityWindowInfo);
        client.handleLaunchActivity(r, pendingActions, mDeviceId, null /* customIntent */);
        Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER);
    }
@@ -141,7 +144,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
            boolean isForward, @Nullable ProfilerInfo profilerInfo, @NonNull IBinder assistToken,
            @Nullable IActivityClientController activityClientController,
            @NonNull IBinder shareableActivityToken, boolean launchedFromBubble,
            @Nullable IBinder taskFragmentToken, @NonNull IBinder initialCallerInfoAccessToken) {
            @Nullable IBinder taskFragmentToken, @NonNull IBinder initialCallerInfoAccessToken,
            @NonNull ActivityWindowInfo activityWindowInfo) {
        LaunchActivityItem instance = ObjectPool.obtain(LaunchActivityItem.class);
        if (instance == null) {
            instance = new LaunchActivityItem();
@@ -156,7 +160,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
                sceneTransitionInfo, isForward,
                profilerInfo != null ? new ProfilerInfo(profilerInfo) : null,
                assistToken, activityClientController, shareableActivityToken,
                launchedFromBubble, taskFragmentToken, initialCallerInfoAccessToken);
                launchedFromBubble, taskFragmentToken, initialCallerInfoAccessToken,
                new ActivityWindowInfo(activityWindowInfo));

        return instance;
    }
@@ -171,7 +176,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
    @Override
    public void recycle() {
        setValues(this, null, null, 0, null, null, null, 0, null, null, 0, null, null, null, null,
                null, false, null, null, null, null, false, null, null);
                null, false, null, null, null, null, false, null, null, null);
        ObjectPool.recycle(this);
    }

@@ -203,6 +208,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
        dest.writeBoolean(mLaunchedFromBubble);
        dest.writeStrongBinder(mTaskFragmentToken);
        dest.writeStrongBinder(mInitialCallerInfoAccessToken);
        dest.writeTypedObject(mActivityWindowInfo, flags);
    }

    /** Read from Parcel. */
@@ -223,7 +229,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
                in.readStrongBinder(),
                in.readBoolean(),
                in.readStrongBinder(),
                in.readStrongBinder());
                in.readStrongBinder(),
                in.readTypedObject(ActivityWindowInfo.CREATOR));
    }

    public static final @NonNull Creator<LaunchActivityItem> CREATOR = new Creator<>() {
@@ -264,7 +271,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
                && Objects.equals(mShareableActivityToken, other.mShareableActivityToken)
                && Objects.equals(mTaskFragmentToken, other.mTaskFragmentToken)
                && Objects.equals(mInitialCallerInfoAccessToken,
                        other.mInitialCallerInfoAccessToken);
                        other.mInitialCallerInfoAccessToken)
                && Objects.equals(mActivityWindowInfo, other.mActivityWindowInfo);
    }

    @Override
@@ -289,6 +297,7 @@ public class LaunchActivityItem extends ClientTransactionItem {
        result = 31 * result + Objects.hashCode(mShareableActivityToken);
        result = 31 * result + Objects.hashCode(mTaskFragmentToken);
        result = 31 * result + Objects.hashCode(mInitialCallerInfoAccessToken);
        result = 31 * result + Objects.hashCode(mActivityWindowInfo);
        return result;
    }

@@ -335,7 +344,9 @@ public class LaunchActivityItem extends ClientTransactionItem {
                + ",sceneTransitionInfo=" + mSceneTransitionInfo
                + ",profilerInfo=" + mProfilerInfo
                + ",assistToken=" + mAssistToken
                + ",shareableActivityToken=" + mShareableActivityToken + "}";
                + ",shareableActivityToken=" + mShareableActivityToken
                + ",activityWindowInfo=" + mActivityWindowInfo
                + "}";
    }

    // Using the same method to set and clear values to make sure we don't forget anything
@@ -351,7 +362,8 @@ public class LaunchActivityItem extends ClientTransactionItem {
            @Nullable ProfilerInfo profilerInfo, @Nullable IBinder assistToken,
            @Nullable IActivityClientController activityClientController,
            @Nullable IBinder shareableActivityToken, boolean launchedFromBubble,
            @Nullable IBinder taskFragmentToken, @Nullable IBinder initialCallerInfoAccessToken) {
            @Nullable IBinder taskFragmentToken, @Nullable IBinder initialCallerInfoAccessToken,
            @Nullable ActivityWindowInfo activityWindowInfo) {
        instance.mActivityToken = activityToken;
        instance.mIntent = intent;
        instance.mIdent = ident;
@@ -375,5 +387,6 @@ public class LaunchActivityItem extends ClientTransactionItem {
        instance.mLaunchedFromBubble = launchedFromBubble;
        instance.mTaskFragmentToken = taskFragmentToken;
        instance.mInitialCallerInfoAccessToken = initialCallerInfoAccessToken;
        instance.mActivityWindowInfo = activityWindowInfo;
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.PersistableBundle;
import android.platform.test.annotations.Presubmit;
import android.window.ActivityWindowInfo;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -124,6 +125,7 @@ public class ObjectPoolTests {
        final int deviceId = 3;
        final IBinder taskFragmentToken = new Binder();
        final IBinder initialCallerInfoAccessToken = new Binder();
        final ActivityWindowInfo activityWindowInfo = new ActivityWindowInfo();

        testRecycle(() -> new LaunchActivityItemBuilder(
                activityToken, intent, activityInfo)
@@ -142,6 +144,7 @@ public class ObjectPoolTests {
                .setTaskFragmentToken(taskFragmentToken)
                .setDeviceId(deviceId)
                .setInitialCallerInfoAccessToken(initialCallerInfoAccessToken)
                .setActivityWindowInfo(activityWindowInfo)
                .build());
    }

+11 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.PersistableBundle;
import android.util.MergedConfiguration;
import android.window.ActivityWindowInfo;

import com.android.internal.app.IVoiceInteractor;
import com.android.internal.content.ReferrerIntent;
@@ -134,6 +135,8 @@ class TestUtils {
        private IBinder mTaskFragmentToken;
        @Nullable
        private IBinder mInitialCallerInfoAccessToken;
        @NonNull
        private ActivityWindowInfo mActivityWindowInfo = new ActivityWindowInfo();

        LaunchActivityItemBuilder(@NonNull IBinder activityToken, @NonNull Intent intent,
                @NonNull ActivityInfo info) {
@@ -259,6 +262,13 @@ class TestUtils {
            return this;
        }

        @NonNull
        LaunchActivityItemBuilder setActivityWindowInfo(
                @NonNull ActivityWindowInfo activityWindowInfo) {
            mActivityWindowInfo.set(activityWindowInfo);
            return this;
        }

        @NonNull
        LaunchActivityItem build() {
            return LaunchActivityItem.obtain(mActivityToken, mIntent, mIdent, mInfo,
@@ -267,7 +277,7 @@ class TestUtils {
                    mActivityOptions != null ? mActivityOptions.getSceneTransitionInfo() : null,
                    mIsForward, mProfilerInfo, mAssistToken, null /* activityClientController */,
                    mShareableActivityToken, mLaunchedFromBubble, mTaskFragmentToken,
                    mInitialCallerInfoAccessToken);
                    mInitialCallerInfoAccessToken, mActivityWindowInfo);
        }
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
@@ -40,6 +41,7 @@ import android.os.Parcelable;
import android.os.PersistableBundle;
import android.platform.test.annotations.Presubmit;
import android.platform.test.flag.junit.SetFlagsRule;
import android.window.ActivityWindowInfo;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -180,6 +182,9 @@ public class TransactionParcelTests {
        bundle.putParcelable("data", new ParcelableData(1));
        final PersistableBundle persistableBundle = new PersistableBundle();
        persistableBundle.putInt("k", 4);
        final ActivityWindowInfo activityWindowInfo = new ActivityWindowInfo();
        activityWindowInfo.set(true /* isEmbedded */, new Rect(0, 0, 500, 1000),
                new Rect(0, 0, 500, 500));

        final LaunchActivityItem item = new LaunchActivityItemBuilder(
                activityToken, intent, activityInfo)
@@ -198,6 +203,7 @@ public class TransactionParcelTests {
                .setShareableActivityToken(new Binder())
                .setTaskFragmentToken(new Binder())
                .setInitialCallerInfoAccessToken(new Binder())
                .setActivityWindowInfo(activityWindowInfo)
                .build();

        writeAndPrepareForReading(item);
Loading