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

Commit 2176d951 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow checking if an activity is organized" into sc-v2-dev

parents 20569604 bf54c4ad
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -44,4 +44,10 @@ interface ITaskFragmentOrganizerController {
     * Unregisters remote animations per transition type for the organizer.
     */
    void unregisterRemoteAnimations(in ITaskFragmentOrganizer organizer);

    /**
      * Checks if an activity organized by a {@link android.window.TaskFragmentOrganizer} and
      * only occupies a portion of Task bounds.
      */
    boolean isActivityEmbedded(in IBinder activityToken);
}
+13 −0
Original line number Diff line number Diff line
@@ -216,4 +216,17 @@ public class TaskFragmentOrganizer extends WindowOrganizer {
            return null;
        }
    }

    /**
     * Checks if an activity organized by a {@link android.window.TaskFragmentOrganizer} and
     * only occupies a portion of Task bounds.
     * @hide
     */
    public boolean isActivityEmbedded(@NonNull IBinder activityToken) {
        try {
            return getController().isActivityEmbedded(activityToken);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -860,4 +860,12 @@ public class SplitController implements JetpackTaskFragmentOrganizer.TaskFragmen
                    launchingContainer.getTaskFragmentToken());
        }
    }

    /**
     * Checks if an activity is embedded and its presentation is customized by a
     * {@link android.window.TaskFragmentOrganizer} to only occupy a portion of Task bounds.
     */
    public boolean isActivityEmbedded(@NonNull Activity activity) {
        return mPresenter.isActivityEmbedded(activity.getActivityToken());
    }
}
+23 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static com.android.server.wm.WindowOrganizerController.configurationsAreE
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
@@ -579,4 +580,26 @@ public class TaskFragmentOrganizerController extends ITaskFragmentOrganizerContr
                        event.mException);
        }
    }

    // TODO(b/204399167): change to push the embedded state to the client side
    @Override
    public boolean isActivityEmbedded(IBinder activityToken) {
        synchronized (mGlobalLock) {
            final ActivityRecord activity = ActivityRecord.forTokenLocked(activityToken);
            if (activity == null) {
                return false;
            }
            final TaskFragment taskFragment = activity.getOrganizedTaskFragment();
            if (taskFragment == null) {
                return false;
            }
            final Task parentTask = taskFragment.getTask();
            if (parentTask != null) {
                final Rect taskBounds = parentTask.getBounds();
                final Rect taskFragBounds = taskFragment.getBounds();
                return !taskBounds.equals(taskFragBounds) && taskBounds.contains(taskFragBounds);
            }
            return false;
        }
    }
}