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

Commit 56f65c3b authored by wilsonshih's avatar wilsonshih Committed by Vadim Caen
Browse files

Customizable exit splash screen animation.(2/N)

Introduce new APIs to customize exit splash screen animation.
- SplashScreen
  This can be used for Activity to handle the exit splash screen
  animation.
- SplashScreen#OnExitAnimationListener
  When receive onSplashScreenExit, the splash screen view will be on
  top of the activity.
- SplashScreenView
  The view object which represents the view of current starting window.
  There are two APIs for developer to control it:
  - getIconView: get the icon view object.
  - remove: remove the view and release resources.

If an Activity create a OnExitAnimationListener and set on
SplashScreen, the core will request a copy of SplashScreenView
from Shell, then send the parcelable information to client to
reconstruct the view on top of the DecorView, then call
onSplashScreenExit to let the listener able to operating this view.

Bug: 73289295
Test: build/flash, check splash screen starting window.
Test: atest StartingSurfaceDrawerTests ActivityRecordTests
WindowOrganizerTests
Test: atest CtsWindowManagerDeviceTestCases:SplashscreenTests

Change-Id: I9f77fb4471bcf37a7f74d6c18a345ca56c05b716
parent d8385e06
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -3865,6 +3865,7 @@ package android.app {
    method @Nullable public android.net.Uri getReferrer();
    method public int getRequestedOrientation();
    method public final android.view.SearchEvent getSearchEvent();
    method @NonNull public final android.window.SplashScreen getSplashScreen();
    method public int getTaskId();
    method public final CharSequence getTitle();
    method public final int getTitleColor();
@@ -55823,6 +55824,23 @@ package android.widget.inline {
}
package android.window {
  public interface SplashScreen {
    method public void setOnExitAnimationListener(@Nullable android.window.SplashScreen.OnExitAnimationListener);
  }
  public static interface SplashScreen.OnExitAnimationListener {
    method public void onSplashScreenExit(@NonNull android.window.SplashScreenView);
  }
  public final class SplashScreenView extends android.widget.FrameLayout {
    method @Nullable public android.view.View getIconView();
    method public void remove();
  }
}
package javax.microedition.khronos.egl {
  public interface EGL {
+1 −0
Original line number Diff line number Diff line
@@ -2748,6 +2748,7 @@ package android.window {
  public class TaskOrganizer extends android.window.WindowOrganizer {
    ctor public TaskOrganizer();
    method @BinderThread public void addStartingWindow(@NonNull android.window.StartingWindowInfo, @NonNull android.os.IBinder);
    method @BinderThread public void copySplashScreenView(int);
    method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void createRootTask(int, int, @Nullable android.os.IBinder);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public boolean deleteRootTask(@NonNull android.window.WindowContainerToken);
    method @Nullable @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public java.util.List<android.app.ActivityManager.RunningTaskInfo> getChildTasks(@NonNull android.window.WindowContainerToken, @NonNull int[]);
+23 −0
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ import android.view.translation.UiTranslationController;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.Toolbar;
import android.window.SplashScreen;
import android.window.SplashScreenView;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
@@ -961,6 +963,10 @@ public class Activity extends ContextThemeWrapper

    private UiTranslationController mUiTranslationController;

    private SplashScreen mSplashScreen;
    /** @hide */
    SplashScreenView mSplashScreenView;

    private final WindowControllerCallback mWindowControllerCallback =
            new WindowControllerCallback() {
        /**
@@ -1602,6 +1608,23 @@ public class Activity extends ContextThemeWrapper

    }

    /**
     * Get the interface that activity use to talk to the splash screen.
     * @see SplashScreen
     */
    public final @NonNull SplashScreen getSplashScreen() {
        return getOrCreateSplashScreen();
    }

    private SplashScreen getOrCreateSplashScreen() {
        synchronized (this) {
            if (mSplashScreen == null) {
                mSplashScreen = new SplashScreen.SplashScreenImpl(this);
            }
            return mSplashScreen;
        }
    }

    /**
     * Same as {@link #onCreate(android.os.Bundle)} but called for those activities created with
     * the attribute {@link android.R.attr#persistableMode} set to
+13 −2
Original line number Diff line number Diff line
@@ -46,9 +46,9 @@ public class ActivityClient {
    }

    /** Reports {@link Activity#onResume()} is done. */
    public void activityResumed(IBinder token) {
    public void activityResumed(IBinder token, boolean handleSplashScreenExit) {
        try {
            getActivityClientController().activityResumed(token);
            getActivityClientController().activityResumed(token, handleSplashScreenExit);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
@@ -488,6 +488,17 @@ public class ActivityClient {
        }
    }

    /**
     * Reports the splash screen view has attached to client.
     */
    void reportSplashScreenAttached(IBinder token) {
        try {
            getActivityClientController().splashScreenAttached(token);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    public static ActivityClient getInstance() {
        return sInstance.get();
    }
+18 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemService;
import android.annotation.TestApi;
@@ -37,6 +38,7 @@ import android.os.ServiceManager;
import android.util.DisplayMetrics;
import android.util.Singleton;
import android.view.RemoteAnimationDefinition;
import android.window.SplashScreenView.SplashScreenViewParcelable;

import java.util.List;

@@ -242,6 +244,22 @@ public class ActivityTaskManager {
        return sMaxRecentTasks;
    }

    /**
     * Notify the server that splash screen of the given task has been copied"
     *
     * @param taskId Id of task to handle the material to reconstruct the splash screen view.
     * @param parcelable Used to reconstruct the view, null means the surface is un-copyable.
     * @hide
     */
    public void onSplashScreenViewCopyFinished(int taskId,
            @Nullable SplashScreenViewParcelable parcelable) {
        try {
            getService().onSplashScreenViewCopyFinished(taskId, parcelable);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Return the default limit on the number of recents that an app can make.
     * @hide
Loading