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

Commit 3e586e46 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Refactoring activity method to update recents values."

parents be2ba85c 03a9baed
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -3316,7 +3316,6 @@ package android.app {
    method public final boolean requestWindowFeature(int);
    method public final void runOnUiThread(java.lang.Runnable);
    method public void setActionBar(android.widget.Toolbar);
    method public void setActivityLabelAndIcon(java.lang.CharSequence, android.graphics.Bitmap);
    method public void setActivityTransitionListener(android.app.ActivityOptions.ActivityTransitionListener);
    method public void setContentTransitionManager(android.transition.TransitionManager);
    method public void setContentView(int);
@@ -3334,6 +3333,7 @@ package android.app {
    method public final void setProgressBarIndeterminate(boolean);
    method public final void setProgressBarIndeterminateVisibility(boolean);
    method public final void setProgressBarVisibility(boolean);
    method public void setRecentsActivityValues(android.app.ActivityManager.RecentsActivityValues);
    method public void setRequestedOrientation(int);
    method public final void setResult(int);
    method public final void setResult(int, android.content.Intent);
@@ -3454,8 +3454,7 @@ 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.app.ActivityManager.RecentsActivityValues activityValues;
    field public android.content.Intent baseIntent;
    field public java.lang.CharSequence description;
    field public int id;
@@ -3463,6 +3462,21 @@ package android.app {
    field public int persistentId;
  }
  public static class ActivityManager.RecentsActivityValues implements android.os.Parcelable {
    ctor public ActivityManager.RecentsActivityValues(android.app.ActivityManager.RecentsActivityValues);
    ctor public ActivityManager.RecentsActivityValues(java.lang.CharSequence, android.graphics.Bitmap, int);
    ctor public ActivityManager.RecentsActivityValues(java.lang.CharSequence, android.graphics.Bitmap);
    ctor public ActivityManager.RecentsActivityValues(java.lang.CharSequence);
    ctor public ActivityManager.RecentsActivityValues();
    method public int describeContents();
    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 int colorPrimary;
    field public android.graphics.Bitmap icon;
    field public java.lang.CharSequence label;
  }
  public static class ActivityManager.RunningAppProcessInfo implements android.os.Parcelable {
    ctor public ActivityManager.RunningAppProcessInfo();
    ctor public ActivityManager.RunningAppProcessInfo(java.lang.String, int, java.lang.String[]);
+23 −18
Original line number Diff line number Diff line
@@ -3493,6 +3493,16 @@ public class Activity extends ContextThemeWrapper
            }
            theme.applyStyle(resid, false);
        }

        // Get the primary color and update the RecentsActivityValues for this activity
        TypedArray a = getTheme().obtainStyledAttributes(com.android.internal.R.styleable.Theme);
        int colorPrimary = a.getColor(com.android.internal.R.styleable.Theme_colorPrimary, 0);
        a.recycle();
        if (colorPrimary != 0) {
            ActivityManager.RecentsActivityValues v = new ActivityManager.RecentsActivityValues();
            v.colorPrimary = colorPrimary;
            setRecentsActivityValues(v);
        }
    }

    /**
@@ -4779,31 +4789,26 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * 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}.
     * Sets information describing this Activity for presentation inside the Recents System UI. When
     * {@link ActivityManager#getRecentTasks} is called, the activities of each task are
     * traversed in order from the topmost activity to the bottommost. The traversal continues for
     * each property until a suitable value is found. For each task those values will be returned in
     * {@link android.app.ActivityManager.RecentsActivityValues}.
     *
     * @see ActivityManager#getRecentTasks
     * @see ActivityManager.RecentTaskInfo
     * @see android.app.ActivityManager.RecentsActivityValues
     *
     * @param activityLabel The label to use in the RecentTaskInfo.
     * @param activityIcon The Bitmap to use in the RecentTaskInfo.
     * @param values The Recents values that describe this activity.
     */
    public void setActivityLabelAndIcon(CharSequence activityLabel, Bitmap activityIcon) {
        final Bitmap scaledIcon;
        if (activityIcon != null) {
    public void setRecentsActivityValues(ActivityManager.RecentsActivityValues values) {
        ActivityManager.RecentsActivityValues activityValues =
                new ActivityManager.RecentsActivityValues(values);
        if (values.icon != null) {
            final int size = ActivityManager.getLauncherLargeIconSizeInner(this);
            scaledIcon = Bitmap.createScaledBitmap(activityIcon, size, size, true);
        } else {
            scaledIcon = null;
            activityValues.icon = Bitmap.createScaledBitmap(values.icon, size, size, true);
        }
        try {
            ActivityManagerNative.getDefault().setActivityLabelAndIcon(mToken, activityLabel,
                    scaledIcon);
            ActivityManagerNative.getDefault().setRecentsActivityValues(mToken, activityValues);
        } catch (RemoteException e) {
        }
    }
+114 −17
Original line number Diff line number Diff line
@@ -474,6 +474,111 @@ public class ActivityManager {
                !Resources.getSystem().getBoolean(com.android.internal.R.bool.config_avoidGfxAccel);
    }

    /**
     * Information you can set and retrieve about the current activity within Recents.
     */
    public static class RecentsActivityValues implements Parcelable {
        public CharSequence label;
        public Bitmap icon;
        public int colorPrimary;

        public RecentsActivityValues(RecentsActivityValues values) {
            copyFrom(values);
        }

        /**
         * Creates the RecentsActivityValues to the specified values.
         *
         * @param label A label and description of the current state of this activity.
         * @param icon An icon that represents the current state of this activity.
         * @param color A color to override the theme's primary color.
         */
        public RecentsActivityValues(CharSequence label, Bitmap icon, int color) {
            this.label = label;
            this.icon = icon;
            this.colorPrimary = color;
        }

        /**
         * Creates the RecentsActivityValues to the specified values.
         *
         * @param label A label and description of the current state of this activity.
         * @param icon An icon that represents the current state of this activity.
         */
        public RecentsActivityValues(CharSequence label, Bitmap icon) {
            this(label, icon, 0);
        }

        /**
         * Creates the RecentsActivityValues to the specified values.
         *
         * @param label A label and description of the current state of this activity.
         */
        public RecentsActivityValues(CharSequence label) {
            this(label, null, 0);
        }

        public RecentsActivityValues() {
            this(null, null, 0);
        }

        private RecentsActivityValues(Parcel source) {
            readFromParcel(source);
        }

        /**
         * Do a shallow copy of another set of activity values.
         * @hide
         */
        public void copyFrom(RecentsActivityValues v) {
            if (v != null) {
                label = v.label;
                icon = v.icon;
                colorPrimary = v.colorPrimary;
            }
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            TextUtils.writeToParcel(label, dest,
                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
            if (icon == null) {
                dest.writeInt(0);
            } else {
                dest.writeInt(1);
                icon.writeToParcel(dest, 0);
            }
            dest.writeInt(colorPrimary);
        }

        public void readFromParcel(Parcel source) {
            label = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            icon = source.readInt() > 0 ? Bitmap.CREATOR.createFromParcel(source) : null;
            colorPrimary = source.readInt();
        }

        public static final Creator<RecentsActivityValues> CREATOR
                = new Creator<RecentsActivityValues>() {
            public RecentsActivityValues createFromParcel(Parcel source) {
                return new RecentsActivityValues(source);
            }
            public RecentsActivityValues[] newArray(int size) {
                return new RecentsActivityValues[size];
            }
        };

        @Override
        public String toString() {
            return "RecentsActivityValues Label: " + label + " Icon: " + icon +
                    " colorPrimary: " + colorPrimary;
        }
    }

    /**
     * Information you can retrieve about tasks that the user has most recently
     * started or visited.
@@ -523,16 +628,10 @@ public class ActivityManager {
        public int userId;

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

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

        public RecentTaskInfo() {
        }
@@ -555,13 +654,11 @@ 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 {
            if (activityValues != null) {
                dest.writeInt(1);
                activityIcon.writeToParcel(dest, 0);
                activityValues.writeToParcel(dest, 0);
            } else {
                dest.writeInt(0);
            }
            dest.writeInt(stackId);
            dest.writeInt(userId);
@@ -573,8 +670,8 @@ public class ActivityManager {
            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);
            activityIcon = source.readInt() > 0 ? Bitmap.CREATOR.createFromParcel(source) : null;
            activityValues = source.readInt() > 0 ?
                    RecentsActivityValues.CREATOR.createFromParcel(source) : null;
            stackId = source.readInt();
            userId = source.readInt();
        }
+8 −16
Original line number Diff line number Diff line
@@ -2119,13 +2119,12 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case SET_ACTIVITY_LABEL_ICON_TRANSACTION: {
        case SET_RECENTS_ACTIVITY_VALUES_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            CharSequence activityLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
            Bitmap activityIcon = data.readInt() > 0
                    ? Bitmap.CREATOR.createFromParcel(data) : null;
            setActivityLabelAndIcon(token, activityLabel, activityIcon);
            ActivityManager.RecentsActivityValues values =
                    ActivityManager.RecentsActivityValues.CREATOR.createFromParcel(data);
            setRecentsActivityValues(token, values);
            reply.writeNoException();
            return true;
        }
@@ -4883,21 +4882,14 @@ class ActivityManagerProxy implements IActivityManager
    }

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

    /** @hide */
    public void setActivityLabelAndIcon(IBinder token, CharSequence activityLabel,
            Bitmap activityBitmap) throws RemoteException;
    public void setRecentsActivityValues(IBinder token, ActivityManager.RecentsActivityValues values)
            throws RemoteException;

    /*
     * Private non-Binder interfaces
@@ -734,6 +734,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_ACTIVITY_LABEL_ICON_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
    int SET_RECENTS_ACTIVITY_VALUES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+217;
    int START_VOICE_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+218;
}
Loading