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

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

Merge "Add Activity methods for icons and labels."

parents 9ae0c8ff 2fbd7541
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3156,6 +3156,8 @@ 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);
@@ -3276,6 +3278,8 @@ package android.app {
    method public void readFromParcel(android.os.Parcel);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public android.graphics.Bitmap activityIcon;
    field public java.lang.CharSequence activityLabel;
    field public android.content.Intent baseIntent;
    field public java.lang.CharSequence description;
    field public int id;
+41 −0
Original line number Diff line number Diff line
@@ -4700,6 +4700,47 @@ public class Activity extends ContextThemeWrapper
    protected void onChildTitleChanged(Activity childActivity, CharSequence title) {
    }

    /**
     * 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}
     *
     * @see ActivityManager#getRecentTasks
     *
     * @param recentsLabel The label 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) {
        final Bitmap scaledIcon;
        if (recentsIcon != null) {
            final int size = ActivityManager.getLauncherLargeIconSizeInner(this);
            scaledIcon = Bitmap.createScaledBitmap(recentsIcon, size, size, true);
        } else {
            scaledIcon = null;
        }
        try {
            ActivityManagerNative.getDefault().setRecentsIcon(mToken, scaledIcon);
        } catch (RemoteException e) {
        }
    }

    /**
     * Sets the visibility of the progress bar in the title.
     * <p>
+28 −2
Original line number Diff line number Diff line
@@ -510,11 +510,23 @@ public class ActivityManager {
        public int stackId;

        /**
         * The id the of the user the task was running as.
         * The id of the user the task was running as.
         * @hide
         */
        public int userId;

        /**
         * The label of the highest activity in the task stack to have set a label
         * {@link Activity#setRecentsLabel}.
         */
        public CharSequence activityLabel;

        /**
         * The Bitmap icon of the highest activity in the task stack to set a Bitmap using
         * {@link Activity#setRecentsIcon}.
         */
        public Bitmap activityIcon;

        public RecentTaskInfo() {
        }

@@ -536,6 +548,14 @@ public class ActivityManager {
            ComponentName.writeToParcel(origActivity, dest);
            TextUtils.writeToParcel(description, dest,
                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
            TextUtils.writeToParcel(activityLabel, dest,
                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
            if (activityIcon == null) {
                dest.writeInt(0);
            } else {
                dest.writeInt(1);
                activityIcon.writeToParcel(dest, 0);
            }
            dest.writeInt(stackId);
            dest.writeInt(userId);
        }
@@ -550,6 +570,8 @@ public class ActivityManager {
            }
            origActivity = ComponentName.readFromParcel(source);
            description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            activityLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            activityIcon = source.readInt() > 0 ? Bitmap.CREATOR.createFromParcel(source) : null;
            stackId = source.readInt();
            userId = source.readInt();
        }
@@ -1970,7 +1992,11 @@ public class ActivityManager {
     * @return dimensions of square icons in terms of pixels
     */
    public int getLauncherLargeIconSize() {
        final Resources res = mContext.getResources();
        return getLauncherLargeIconSizeInner(mContext);
    }

    static int getLauncherLargeIconSizeInner(Context context) {
        final Resources res = context.getResources();
        final int size = res.getDimensionPixelSize(android.R.dimen.app_icon_size);
        final int sw = res.getConfiguration().smallestScreenWidthDp;

+50 −0
Original line number Diff line number Diff line
@@ -2128,6 +2128,25 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeInt(isInLockTaskMode ? 1 : 0);
            return true;
        }

        case SET_RECENTS_LABEL_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
                    ? Bitmap.CREATOR.createFromParcel(data) : null;
            setRecentsIcon(token, recentsIcon);
            reply.writeNoException();
            return true;
        }
        }

        return super.onTransact(code, data, reply, flags);
@@ -4899,5 +4918,36 @@ 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
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        if (recentsBitmap != null) {
            data.writeInt(1);
            recentsBitmap.writeToParcel(data, 0);
        } else {
            data.writeInt(0);
        }
        mRemote.transact(SET_RECENTS_ICON_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    private IBinder mRemote;
}
+8 −0
Original line number Diff line number Diff line
@@ -436,6 +436,12 @@ public interface IActivityManager extends IInterface {
    /** @hide */
    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;

    /*
     * Private non-Binder interfaces
     */
@@ -735,4 +741,6 @@ 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;
}
Loading