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

Commit 35fc6a02 authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Implement setActivityLabelAndIcon()."

parents 93160828 688b5105
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -3262,6 +3262,7 @@ package android.app {
    method public void reportFullyDrawn();
    method public final boolean requestWindowFeature(int);
    method public final void runOnUiThread(java.lang.Runnable);
    method public void setActivityLabelAndIcon(java.lang.CharSequence, android.graphics.Bitmap);
    method public void setContentTransitionManager(android.transition.TransitionManager);
    method public void setContentView(int);
    method public void setContentView(android.view.View);
@@ -3278,8 +3279,6 @@ package android.app {
    method public final void setProgressBarIndeterminate(boolean);
    method public final void setProgressBarIndeterminateVisibility(boolean);
    method public final void setProgressBarVisibility(boolean);
    method public void setRecentsIcon(android.graphics.Bitmap);
    method public void setRecentsLabel(java.lang.CharSequence);
    method public void setRequestedOrientation(int);
    method public final void setResult(int);
    method public final void setResult(int, android.content.Intent);
+17 −26
Original line number Diff line number Diff line
@@ -4701,42 +4701,33 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * Set a label to be used in the Recents task display. The activities of a task are traversed
     * in order from the topmost activity to the bottommost. As soon as one activity returns a
     * non-null Recents label the traversal is ended and that value will be used in
     * {@link ActivityManager.RecentTaskInfo#activityLabel}
     * Set a label and icon to be used in the Recents task display. When {@link
     * ActivityManager#getRecentTasks} is called, the activities of each task are
     * traversed in order from the topmost activity to the bottommost. As soon as one activity is
     * found with either a non-null label or a non-null icon set by this call the traversal is
     * ended. For each task those values will be returned in {@link
     * ActivityManager.RecentTaskInfo#activityLabel} and {@link
     * ActivityManager.RecentTaskInfo#activityIcon}. The {link Intent} for the activity that set
     * activityLabel and activityIcon will be returned in {@link
     * ActivityManager.RecentTaskInfo#activityIntent}
     *
     * @see ActivityManager#getRecentTasks
     * @see ActivityManager.RecentTaskInfo
     *
     * @param recentsLabel The label to use in the RecentTaskInfo.
     * @param activityLabel The label to use in the RecentTaskInfo.
     * @param activityIcon The Bitmap to use in the RecentTaskInfo.
     */
    public void setRecentsLabel(CharSequence recentsLabel) {
        try {
            ActivityManagerNative.getDefault().setRecentsLabel(mToken, recentsLabel);
        } catch (RemoteException e) {
        }
    }

    /**
     * Set an icon to be used in the Recents task display. The activities of a task are traversed
     * in order from the topmost activity to the bottommost. As soon as one activity returns a
     * non-null Recents icon the traversal is ended and that value will be used in
     * {@link ActivityManager.RecentTaskInfo#activityIcon}.
     *
     * @see ActivityManager#getRecentTasks
     *
     * @param recentsIcon The Bitmap to use in the RecentTaskInfo.
     */
    public void setRecentsIcon(Bitmap recentsIcon) {
    public void setActivityLabelAndIcon(CharSequence activityLabel, Bitmap activityIcon) {
        final Bitmap scaledIcon;
        if (recentsIcon != null) {
        if (activityIcon != null) {
            final int size = ActivityManager.getLauncherLargeIconSizeInner(this);
            scaledIcon = Bitmap.createScaledBitmap(recentsIcon, size, size, true);
            scaledIcon = Bitmap.createScaledBitmap(activityIcon, size, size, true);
        } else {
            scaledIcon = null;
        }
        try {
            ActivityManagerNative.getDefault().setRecentsIcon(mToken, scaledIcon);
            ActivityManagerNative.getDefault().setActivityLabelAndIcon(mToken, activityLabel,
                    scaledIcon);
        } catch (RemoteException e) {
        }
    }
+4 −8
Original line number Diff line number Diff line
@@ -516,14 +516,14 @@ public class ActivityManager {
        public int userId;

        /**
         * The label of the highest activity in the task stack to have set a label
         * {@link Activity#setRecentsLabel}.
         * The label of the highest activity in the task stack to have set a label using
         * {@link Activity#setActivityLabelAndIcon(CharSequence, android.graphics.Bitmap)}.
         */
        public CharSequence activityLabel;

        /**
         * The Bitmap icon of the highest activity in the task stack to set a Bitmap using
         * {@link Activity#setRecentsIcon}.
         * {@link Activity#setActivityLabelAndIcon(CharSequence, android.graphics.Bitmap)}.
         */
        public Bitmap activityIcon;

@@ -563,11 +563,7 @@ public class ActivityManager {
        public void readFromParcel(Parcel source) {
            id = source.readInt();
            persistentId = source.readInt();
            if (source.readInt() != 0) {
                baseIntent = Intent.CREATOR.createFromParcel(source);
            } else {
                baseIntent = null;
            }
            baseIntent = source.readInt() > 0 ? Intent.CREATOR.createFromParcel(source) : null;
            origActivity = ComponentName.readFromParcel(source);
            description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            activityLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
+11 −29
Original line number Diff line number Diff line
@@ -2129,21 +2129,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case SET_RECENTS_LABEL_TRANSACTION: {
        case SET_ACTIVITY_LABEL_ICON_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            CharSequence recentsLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
            setRecentsLabel(token, recentsLabel);
            reply.writeNoException();
            return true;
        }

        case SET_RECENTS_ICON_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            Bitmap recentsIcon = data.readInt() != 0
            CharSequence activityLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
            Bitmap activityIcon = data.readInt() > 0
                    ? Bitmap.CREATOR.createFromParcel(data) : null;
            setRecentsIcon(token, recentsIcon);
            setActivityLabelAndIcon(token, activityLabel, activityIcon);
            reply.writeNoException();
            return true;
        }
@@ -4918,32 +4910,22 @@ class ActivityManagerProxy implements IActivityManager
        return isInLockTaskMode;
    }

    public void setRecentsLabel(IBinder token, CharSequence recentsLabel) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        TextUtils.writeToParcel(recentsLabel, data, 0);
        mRemote.transact(SET_RECENTS_LABEL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    public void setRecentsIcon(IBinder token, Bitmap recentsBitmap) throws RemoteException
    @Override
    public void setActivityLabelAndIcon(IBinder token, CharSequence activityLabel,
            Bitmap activityIcon) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        if (recentsBitmap != null) {
        TextUtils.writeToParcel(activityLabel, data, 0);
        if (activityIcon != null) {
            data.writeInt(1);
            recentsBitmap.writeToParcel(data, 0);
            activityIcon.writeToParcel(data, 0);
        } else {
            data.writeInt(0);
        }
        mRemote.transact(SET_RECENTS_ICON_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
        mRemote.transact(SET_ACTIVITY_LABEL_ICON_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
        reply.readException();
        data.recycle();
        reply.recycle();
+3 −6
Original line number Diff line number Diff line
@@ -437,10 +437,8 @@ public interface IActivityManager extends IInterface {
    public boolean isInLockTaskMode() throws RemoteException;

    /** @hide */
    public void setRecentsLabel(IBinder token, CharSequence recentsLabel) throws RemoteException;

    /** @hide */
    public void setRecentsIcon(IBinder token, Bitmap recentsBitmap) throws RemoteException;
    public void setActivityLabelAndIcon(IBinder token, CharSequence activityLabel,
            Bitmap activityBitmap) throws RemoteException;

    /*
     * Private non-Binder interfaces
@@ -741,6 +739,5 @@ public interface IActivityManager extends IInterface {
    int START_LOCK_TASK_BY_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+214;
    int STOP_LOCK_TASK_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+215;
    int IS_IN_LOCK_TASK_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+216;
    int SET_RECENTS_LABEL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
    int SET_RECENTS_ICON_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+218;
    int SET_ACTIVITY_LABEL_ICON_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
}
Loading