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

Commit 089c35e9 authored by Tony Mak's avatar Tony Mak
Browse files

Enforce platform level animation in CrossProfileApps.startMainActivity

With this change, whenever apps start an activity in another profile
using CrossProfileApps.startMainActivity, an animation will be enforced.
For now, we are showing the "open task" animation.
We may put something fancier if we have time in P.

Test: cts-tradefed run cts-dev --module DevicePolicyManager --test - com.android.cts.devicepolicy.CrossProfileAppsHostsideTest
Test: atest services/tests/servicestests/src/com/android/server/pm/crossprofile/CrossProfileAppsServiceImplTest.java
Bug: 70799822

Change-Id: I03525080151c6112633108419d69d64e76a511f3
parent 5c9d8019
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11298,7 +11298,7 @@ package android.content.pm.crossprofile {
    method public android.graphics.drawable.Drawable getProfileSwitchingIcon(android.os.UserHandle);
    method public java.lang.CharSequence getProfileSwitchingLabel(android.os.UserHandle);
    method public java.util.List<android.os.UserHandle> getTargetUserProfiles();
    method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
    method public void startMainActivity(android.content.ComponentName, android.os.UserHandle);
  }
}
+16 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.os.IRemoteCallback;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.UserHandle;
import android.transition.Transition;
import android.transition.TransitionListenerAdapter;
import android.transition.TransitionManager;
@@ -265,6 +266,8 @@ public class ActivityOptions {
    public static final int ANIM_CUSTOM_IN_PLACE = 10;
    /** @hide */
    public static final int ANIM_CLIP_REVEAL = 11;
    /** @hide */
    public static final int ANIM_OPEN_CROSS_PROFILE_APPS = 12;

    private String mPackageName;
    private Rect mLaunchBounds;
@@ -485,6 +488,19 @@ public class ActivityOptions {
        return opts;
    }

    /**
     * Creates an {@link ActivityOptions} object specifying an animation where the new activity
     * is started in another user profile by calling {@link
     * android.content.pm.crossprofile.CrossProfileApps#startMainActivity(ComponentName, UserHandle)
     * }.
     * @hide
     */
    public static ActivityOptions makeOpenCrossProfileAppsAnimation() {
        ActivityOptions options = new ActivityOptions();
        options.mAnimationType = ANIM_OPEN_CROSS_PROFILE_APPS;
        return options;
    }

    /**
     * Create an ActivityOptions specifying an animation where a thumbnail
     * is scaled from a given position to the new activity window that is
+2 −8
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package android.content.pm.crossprofile;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
@@ -61,15 +60,10 @@ public class CrossProfileApps {
     * @param user The UserHandle of the profile, must be one of the users returned by
     *        {@link #getTargetUserProfiles()}, otherwise a {@link SecurityException} will
     *        be thrown.
     * @param sourceBounds The Rect containing the source bounds of the clicked icon, see
     *                     {@link android.content.Intent#setSourceBounds(Rect)}.
     * @param startActivityOptions Options to pass to startActivity
     */
    public void startMainActivity(@NonNull ComponentName component, @NonNull UserHandle user,
            @Nullable Rect sourceBounds, @Nullable Bundle startActivityOptions) {
    public void startMainActivity(@NonNull ComponentName component, @NonNull UserHandle user) {
        try {
            mService.startActivityAsUser(mContext.getPackageName(),
                    component, sourceBounds, startActivityOptions, user);
            mService.startActivityAsUser(mContext.getPackageName(), component, user);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
+2 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.UserHandle;
 * @hide
 */
interface ICrossProfileApps {
    void startActivityAsUser(in String callingPackage, in ComponentName component, in Rect sourceBounds, in Bundle startActivityOptions, in UserHandle user);
    void startActivityAsUser(in String callingPackage, in ComponentName component,
        in UserHandle user);
    List<UserHandle> getTargetUserProfiles(in String callingPackage);
}
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -1573,6 +1573,8 @@
  <java-symbol type="anim" name="voice_activity_close_enter" />
  <java-symbol type="anim" name="voice_activity_open_exit" />
  <java-symbol type="anim" name="voice_activity_open_enter" />
  <java-symbol type="anim" name="activity_open_exit" />
  <java-symbol type="anim" name="activity_open_enter" />

  <java-symbol type="array" name="config_autoRotationTiltTolerance" />
  <java-symbol type="array" name="config_keyboardTapVibePattern" />
Loading