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

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

Allow ShortcutInfo to specify a theme for splash screen.(5/N)

Provides new APIs so that shortcuts can preset the theme of the splash
screen window.
- Static way: android:splashScreenTheme
  Preset the splash screen theme from xml.
- Dynamic way: ShortcutInfo.Builder#setStartingTheme
  Preset the splash screen theme when construct the ShortcutInfo
  programmatically.

Bug: 73289295
Test: build/flash
Test: atest AppWindowTokenTests ActivityRecordTests
Change-Id: Ie5e73f9b22fea22659e496c12198c942f4bc93cd
parent 8ac1b581
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1295,6 +1295,7 @@ package android {
    field public static final int spinnerMode = 16843505; // 0x10102f1
    field public static final int spinnerStyle = 16842881; // 0x1010081
    field public static final int spinnersShown = 16843595; // 0x101034b
    field public static final int splashScreenTheme = 16844336; // 0x1010630
    field public static final int splitMotionEvents = 16843503; // 0x10102ef
    field public static final int splitName = 16844105; // 0x1010549
    field public static final int splitTrack = 16843852; // 0x101044c
@@ -12783,6 +12784,7 @@ package android.content.pm {
    method @NonNull public android.content.pm.ShortcutInfo.Builder setPersons(@NonNull android.app.Person[]);
    method @NonNull public android.content.pm.ShortcutInfo.Builder setRank(int);
    method @NonNull public android.content.pm.ShortcutInfo.Builder setShortLabel(@NonNull CharSequence);
    method @NonNull public android.content.pm.ShortcutInfo.Builder setStartingTheme(int);
  }
  public class ShortcutManager {
+19 −0
Original line number Diff line number Diff line
@@ -159,6 +159,12 @@ public class ActivityOptions {
     */
    public static final String KEY_ANIM_START_LISTENER = "android:activity.animStartListener";

    /**
     * Specific a theme for a splash screen window.
     * @hide
     */
    public static final String KEY_SPLASH_SCREEN_THEME = "android.activity.splashScreenTheme";

    /**
     * Callback for when the last frame of the animation is played.
     * @hide
@@ -398,6 +404,7 @@ public class ActivityOptions {
    private IBinder mLaunchCookie;
    private IRemoteTransition mRemoteTransition;
    private boolean mOverrideTaskTransition;
    private int mSplashScreenThemeResId;

    /**
     * Create an ActivityOptions specifying a custom animation to run when
@@ -1147,6 +1154,7 @@ public class ActivityOptions {
        mRemoteTransition = IRemoteTransition.Stub.asInterface(opts.getBinder(
                KEY_REMOTE_TRANSITION));
        mOverrideTaskTransition = opts.getBoolean(KEY_OVERRIDE_TASK_TRANSITION);
        mSplashScreenThemeResId = opts.getInt(KEY_SPLASH_SCREEN_THEME);
    }

    /**
@@ -1332,6 +1340,14 @@ public class ActivityOptions {
        return mLockTaskMode;
    }

    /**
     * Gets whether the activity want to be launched as other theme for the splash screen.
     * @hide
     */
    public int getSplashScreenThemeResId() {
        return mSplashScreenThemeResId;
    }

    /**
     * Sets whether the activity is to be launched into LockTask mode.
     *
@@ -1838,6 +1854,9 @@ public class ActivityOptions {
        if (mOverrideTaskTransition) {
            b.putBoolean(KEY_OVERRIDE_TASK_TRANSITION, mOverrideTaskTransition);
        }
        if (mSplashScreenThemeResId != 0) {
            b.putInt(KEY_SPLASH_SCREEN_THEME, mSplashScreenThemeResId);
        }
        return b;
    }

+1 −1
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ public class AppSearchShortcutInfo extends GenericDocument {
                text, 0, null, disabledMessage, 0, null,
                categoriesSet, intents, rank, extras,
                getCreationTimestampMillis(), flags, iconResId, iconResName, bitmapPath, iconUri,
                disabledReason, persons, locusId);
                disabledReason, persons, locusId, 0);
    }

    /** @hide */
+36 −1
Original line number Diff line number Diff line
@@ -434,6 +434,8 @@ public final class ShortcutInfo implements Parcelable {

    private int mDisabledReason;

    private int mStartingThemeResId;

    private ShortcutInfo(Builder b) {
        mUserId = b.mContext.getUserId();

@@ -462,6 +464,7 @@ public final class ShortcutInfo implements Parcelable {
        mLocusId = b.mLocusId;

        updateTimestamp();
        mStartingThemeResId = b.mStartingThemeResId;
    }

    /**
@@ -608,6 +611,7 @@ public final class ShortcutInfo implements Parcelable {
            // Set this bit.
            mFlags |= FLAG_KEY_FIELDS_ONLY;
        }
        mStartingThemeResId = source.mStartingThemeResId;
    }

    /**
@@ -931,6 +935,9 @@ public final class ShortcutInfo implements Parcelable {
        if (source.mLocusId != null) {
            mLocusId = source.mLocusId;
        }
        if (source.mStartingThemeResId != 0) {
            mStartingThemeResId = source.mStartingThemeResId;
        }
    }

    /**
@@ -1000,6 +1007,8 @@ public final class ShortcutInfo implements Parcelable {

        private LocusId mLocusId;

        private int mStartingThemeResId;

        /**
         * Old style constructor.
         * @hide
@@ -1101,6 +1110,15 @@ public final class ShortcutInfo implements Parcelable {
            return this;
        }

        /**
         * Sets a theme resource id for the splash screen.
         */
        @NonNull
        public Builder setStartingTheme(int themeResId) {
            mStartingThemeResId = themeResId;
            return this;
        }

        /**
         * @hide We don't support resource strings for dynamic shortcuts for now.  (But unit tests
         * use it.)
@@ -1420,6 +1438,14 @@ public final class ShortcutInfo implements Parcelable {
        return mIcon;
    }

    /**
     * Returns the theme resource id used for the splash screen.
     * @hide
     */
    public int getStartingThemeResId() {
        return mStartingThemeResId;
    }

    /** @hide -- old signature, the internal code still uses it. */
    @Nullable
    @Deprecated
@@ -2138,6 +2164,7 @@ public final class ShortcutInfo implements Parcelable {
        mPersons = source.readParcelableArray(cl, Person.class);
        mLocusId = source.readParcelable(cl);
        mIconUri = source.readString8();
        mStartingThemeResId = source.readInt();
    }

    @Override
@@ -2189,6 +2216,7 @@ public final class ShortcutInfo implements Parcelable {
        dest.writeParcelableArray(mPersons, flags);
        dest.writeParcelable(mLocusId, flags);
        dest.writeString8(mIconUri);
        dest.writeInt(mStartingThemeResId);
    }

    public static final @NonNull Creator<ShortcutInfo> CREATOR =
@@ -2345,6 +2373,12 @@ public final class ShortcutInfo implements Parcelable {
        sb.append("disabledReason=");
        sb.append(getDisabledReasonDebugString(mDisabledReason));

        if (mStartingThemeResId != 0) {
            addIndentOrComma(sb, indent);
            sb.append("SplashScreenThemeResId=");
            sb.append(Integer.toHexString(mStartingThemeResId));
        }

        addIndentOrComma(sb, indent);

        sb.append("categories=");
@@ -2430,7 +2464,7 @@ public final class ShortcutInfo implements Parcelable {
            Set<String> categories, Intent[] intentsWithExtras, int rank, PersistableBundle extras,
            long lastChangedTimestamp,
            int flags, int iconResId, String iconResName, String bitmapPath, String iconUri,
            int disabledReason, Person[] persons, LocusId locusId) {
            int disabledReason, Person[] persons, LocusId locusId, int startingThemeResId) {
        mUserId = userId;
        mId = id;
        mPackageName = packageName;
@@ -2459,5 +2493,6 @@ public final class ShortcutInfo implements Parcelable {
        mDisabledReason = disabledReason;
        mPersons = persons;
        mLocusId = locusId;
        mStartingThemeResId = startingThemeResId;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -71,6 +71,13 @@ public abstract class ShortcutServiceInternal {
    public abstract int getShortcutIconResId(int launcherUserId, @NonNull String callingPackage,
            @NonNull String packageName, @NonNull String shortcutId, int userId);

    /**
     * Get the theme res ID of the starting window, it can be 0 if not specified.
     */
    public abstract int getShortcutStartingThemeResId(int launcherUserId,
            @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId,
            int userId);

    public abstract ParcelFileDescriptor getShortcutIconFd(int launcherUserId,
            @NonNull String callingPackage,
            @NonNull String packageName, @NonNull String shortcutId, int userId);
Loading