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

Commit 3198da42 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Make Task have type ActivityRecord children (55/n)

ActivityRecord now extends AppWindowToken and changing Task to have
type ActivityRecord children will make the Task level merging easier.

Bug: 80414790
Test: Existing tests pass
Change-Id: I331ffe054d942cc5dd58bff369fa890b130a45f4
parent 1a06f153
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1253,7 +1253,7 @@ final class ActivityRecord extends AppWindowToken {

    boolean setOccludesParent(boolean occludesParent) {
        final boolean changed = super.setOccludesParent(occludesParent);
        if (changed) {
        if (changed && task != null) {
            if (!occludesParent) {
                getActivityStack().convertActivityToTranslucent(this);
            }
@@ -3542,7 +3542,7 @@ final class ActivityRecord extends AppWindowToken {
            super.resolveOverrideConfiguration(newParentConfiguration);
            // If the activity has override bounds, the relative configuration (e.g. screen size,
            // layout) needs to be resolved according to the bounds.
            if (!matchParentBounds()) {
            if (task != null && !matchParentBounds()) {
                task.computeConfigResourceOverrides(getResolvedOverrideConfiguration(),
                        newParentConfiguration);
            }
+1 −1
Original line number Diff line number Diff line
@@ -1420,7 +1420,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        mReparenting = true;

        getParent().removeChild(this);
        task.addChild(this, position);
        task.addChild((ActivityRecord) this, position);

        mReparenting = false;

+12 −12
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ import com.android.internal.annotations.VisibleForTesting;
import java.io.PrintWriter;
import java.util.function.Consumer;

class Task extends WindowContainer<AppWindowToken> implements ConfigurationContainerListener{
class Task extends WindowContainer<ActivityRecord> implements ConfigurationContainerListener{
    static final String TAG = TAG_WITH_CLASS_NAME ? "Task" : TAG_WM;

    // TODO: Track parent marks like this in WindowContainer.
@@ -170,14 +170,14 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
    }

    @Override
    void addChild(AppWindowToken wtoken, int position) {
    void addChild(ActivityRecord child, int position) {
        position = getAdjustedAddPosition(position);
        super.addChild(wtoken, position);
        super.addChild(child, position);
        mDeferRemoval = false;
    }

    @Override
    void positionChildAt(int position, AppWindowToken child, boolean includingParents) {
    void positionChildAt(int position, ActivityRecord child, boolean includingParents) {
        position = getAdjustedAddPosition(position);
        super.positionChildAt(position, child, includingParents);
        mDeferRemoval = false;
@@ -279,13 +279,13 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
    }

    @Override
    void removeChild(AppWindowToken token) {
        if (!mChildren.contains(token)) {
    void removeChild(ActivityRecord child) {
        if (!mChildren.contains(child)) {
            Slog.e(TAG, "removeChild: token=" + this + " not found.");
            return;
        }

        super.removeChild(token);
        super.removeChild(child);

        if (mChildren.isEmpty()) {
            EventLog.writeEvent(WM_TASK_REMOVED, mTaskId, "removeAppToken: last token");
@@ -674,18 +674,18 @@ class Task extends WindowContainer<AppWindowToken> implements ConfigurationConta
        return null;
    }

    void positionChildAtTop(AppWindowToken aToken) {
        positionChildAt(aToken, POSITION_TOP);
    void positionChildAtTop(ActivityRecord child) {
        positionChildAt(child, POSITION_TOP);
    }

    void positionChildAt(AppWindowToken aToken, int position) {
        if (aToken == null) {
    void positionChildAt(ActivityRecord child, int position) {
        if (child == null) {
            Slog.w(TAG_WM,
                    "Attempted to position of non-existing app");
            return;
        }

        positionChildAt(position, aToken, false /* includeParents */);
        positionChildAt(position, child, false /* includeParents */);
    }

    void forceWindowsScaleable(boolean force) {
+1 −17
Original line number Diff line number Diff line
@@ -215,23 +215,6 @@ class ActivityTestsBase extends SystemServiceTestsBase {
            return this;
        }

        static Pair<Intent, ActivityInfo> createIntentAndActivityInfo() {
            // TODO: Look into consolidating with dup. code in build() method below.
            final int id = sCurrentActivityId++;
            final ComponentName component = ComponentName.createRelative(
                    DEFAULT_COMPONENT_PACKAGE_NAME, DEFAULT_COMPONENT_CLASS_NAME + id);

            final Intent intent = new Intent();
            intent.setComponent(component);

            final ActivityInfo aInfo = new ActivityInfo();
            aInfo.applicationInfo = new ApplicationInfo();
            aInfo.applicationInfo.packageName = component.getPackageName();
            aInfo.applicationInfo.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT;
            aInfo.packageName = component.getPackageName();
            return new Pair<>(intent, aInfo);
        }

        ActivityRecord build() {
            if (mComponent == null) {
                final int id = sCurrentActivityId++;
@@ -249,6 +232,7 @@ class ActivityTestsBase extends SystemServiceTestsBase {
            intent.setComponent(mComponent);
            final ActivityInfo aInfo = new ActivityInfo();
            aInfo.applicationInfo = new ApplicationInfo();
            aInfo.applicationInfo.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT;
            aInfo.applicationInfo.packageName = mComponent.getPackageName();
            aInfo.applicationInfo.uid = mUid;
            aInfo.packageName = mComponent.getPackageName();
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public class AppChangeTransitionTests extends WindowTestsBase {

    private TaskStack mStack;
    private Task mTask;
    private AppWindowToken mToken;
    private ActivityRecord mToken;

    public void setUpOnDisplay(DisplayContent dc) {
        mStack = createTaskStackOnDisplay(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_STANDARD, dc);
Loading