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

Commit d94df45b authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Rework thumbnail API to not suffer from IPC failures.

Thumbnails are now requested separately, so we don't exceed the
IPC buffer size limit.

Also implement issue #3349553a: Please provide a hook to intercept
fragment-breadcrumb clicks

And maybe fix issue #3439199: Music Notification does not turn on
when app switching out of Music app

Change-Id: Ie939e78cc8ded07b18112760e053185947549f61
parent 6c0dc5a5
Loading
Loading
Loading
Loading
+58 −1
Original line number Original line Diff line number Diff line
@@ -25064,6 +25064,17 @@
<parameter name="packageName" type="java.lang.String">
<parameter name="packageName" type="java.lang.String">
</parameter>
</parameter>
</method>
</method>
<field name="MOVE_TASK_NO_USER_ACTION"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="MOVE_TASK_WITH_HOME"
<field name="MOVE_TASK_WITH_HOME"
 type="int"
 type="int"
 transient="false"
 transient="false"
@@ -25495,6 +25506,16 @@
 visibility="public"
 visibility="public"
>
>
</field>
</field>
<field name="persistentId"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
</class>
<class name="ActivityManager.RunningAppProcessInfo"
<class name="ActivityManager.RunningAppProcessInfo"
 extends="java.lang.Object"
 extends="java.lang.Object"
@@ -30692,6 +30713,19 @@
<parameter name="visibleCrumbs" type="int">
<parameter name="visibleCrumbs" type="int">
</parameter>
</parameter>
</method>
</method>
<method name="setOnBreadCrumbClickListener"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="listener" type="android.app.FragmentBreadCrumbs.OnBreadCrumbClickListener">
</parameter>
</method>
<method name="setParentTitle"
<method name="setParentTitle"
 return="void"
 return="void"
 abstract="false"
 abstract="false"
@@ -30725,6 +30759,29 @@
</parameter>
</parameter>
</method>
</method>
</class>
</class>
<interface name="FragmentBreadCrumbs.OnBreadCrumbClickListener"
 abstract="true"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<method name="onBreadCrumbClick"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="backStack" type="android.app.FragmentManager.BackStackEntry">
</parameter>
<parameter name="flags" type="int">
</parameter>
</method>
</interface>
<class name="FragmentManager"
<class name="FragmentManager"
 extends="java.lang.Object"
 extends="java.lang.Object"
 abstract="true"
 abstract="true"
@@ -265799,7 +265856,7 @@
 deprecated="not deprecated"
 deprecated="not deprecated"
 visibility="public"
 visibility="public"
>
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</parameter>
</method>
</method>
</interface>
</interface>
+24 −19
Original line number Original line Diff line number Diff line
@@ -111,6 +111,11 @@ public class ActivityManager {
         */
         */
        public int id;
        public int id;


        /**
         * The true identifier of this task, valid even if it is not running.
         */
        public int persistentId;
        
        /**
        /**
         * The original Intent used to launch the task.  You can use this
         * The original Intent used to launch the task.  You can use this
         * Intent to re-launch the task (if it is no longer running) or bring
         * Intent to re-launch the task (if it is no longer running) or bring
@@ -126,14 +131,6 @@ public class ActivityManager {
         */
         */
        public ComponentName origActivity;
        public ComponentName origActivity;


        /**
         * Thumbnail representation of the task's last state.  Must
         * use {@link ActivityManager#TASKS_GET_THUMBNAILS} to have this set.
         * @hide -- this is not scalable, need to have a separate API to get
         * the bitmap.
         */
        public Bitmap thumbnail;

        /**
        /**
         * Description of the task's last state.
         * Description of the task's last state.
         */
         */
@@ -148,6 +145,7 @@ public class ActivityManager {


        public void writeToParcel(Parcel dest, int flags) {
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(id);
            dest.writeInt(id);
            dest.writeInt(persistentId);
            if (baseIntent != null) {
            if (baseIntent != null) {
                dest.writeInt(1);
                dest.writeInt(1);
                baseIntent.writeToParcel(dest, 0);
                baseIntent.writeToParcel(dest, 0);
@@ -155,29 +153,19 @@ public class ActivityManager {
                dest.writeInt(0);
                dest.writeInt(0);
            }
            }
            ComponentName.writeToParcel(origActivity, dest);
            ComponentName.writeToParcel(origActivity, dest);
            if (thumbnail != null) {
                dest.writeInt(1);
                thumbnail.writeToParcel(dest, 0);
            } else {
                dest.writeInt(0);
            }
            TextUtils.writeToParcel(description, dest,
            TextUtils.writeToParcel(description, dest,
                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
        }
        }


        public void readFromParcel(Parcel source) {
        public void readFromParcel(Parcel source) {
            id = source.readInt();
            id = source.readInt();
            persistentId = source.readInt();
            if (source.readInt() != 0) {
            if (source.readInt() != 0) {
                baseIntent = Intent.CREATOR.createFromParcel(source);
                baseIntent = Intent.CREATOR.createFromParcel(source);
            } else {
            } else {
                baseIntent = null;
                baseIntent = null;
            }
            }
            origActivity = ComponentName.readFromParcel(source);
            origActivity = ComponentName.readFromParcel(source);
            if (source.readInt() != 0) {
                thumbnail = Bitmap.CREATOR.createFromParcel(source);
            } else {
                thumbnail = null;
            }
            description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
            description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
        }
        }
        
        
@@ -401,6 +389,16 @@ public class ActivityManager {
        return getRunningTasks(maxNum, 0, null);
        return getRunningTasks(maxNum, 0, null);
    }
    }


    /** @hide */
    public Bitmap getTaskThumbnail(int id) throws SecurityException {
        try {
            return ActivityManagerNative.getDefault().getTaskThumbnail(id);
        } catch (RemoteException e) {
            // System dead, we will be dead too soon!
            return null;
        }
    }
    
    /**
    /**
     * Flag for {@link #moveTaskToFront(int, int)}: also move the "home"
     * Flag for {@link #moveTaskToFront(int, int)}: also move the "home"
     * activity along with the task, so it is positioned immediately behind
     * activity along with the task, so it is positioned immediately behind
@@ -408,6 +406,13 @@ public class ActivityManager {
     */
     */
    public static final int MOVE_TASK_WITH_HOME = 0x00000001;
    public static final int MOVE_TASK_WITH_HOME = 0x00000001;


    /**
     * Flag for {@link #moveTaskToFront(int, int)}: don't count this as a
     * user-instigated action, so the current activity will not receive a
     * hint that the user is leaving.
     */
    public static final int MOVE_TASK_NO_USER_ACTION = 0x00000002;

    /**
    /**
     * Ask that the task associated with a given task ID be moved to the
     * Ask that the task associated with a given task ID be moved to the
     * front of the stack, so it is now visible to the user.  Requires that
     * front of the stack, so it is now visible to the user.  Requires that
+29 −0
Original line number Original line Diff line number Diff line
@@ -442,6 +442,20 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
            return true;
        }
        }
        
        
        case GET_TASK_THUMBNAIL_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int id = data.readInt();
            Bitmap bm = getTaskThumbnail(id);
            reply.writeNoException();
            if (bm != null) {
                reply.writeInt(1);
                bm.writeToParcel(reply, 0);
            } else {
                reply.writeInt(0);
            }
            return true;
        }
        
        case GET_SERVICES_TRANSACTION: {
        case GET_SERVICES_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            data.enforceInterface(IActivityManager.descriptor);
            int maxNum = data.readInt();
            int maxNum = data.readInt();
@@ -1816,6 +1830,21 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
        reply.recycle();
        return list;
        return list;
    }
    }
    public Bitmap getTaskThumbnail(int id) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(id);
        mRemote.transact(GET_TASK_THUMBNAIL_TRANSACTION, data, reply, 0);
        reply.readException();
        Bitmap bm = null;
        if (reply.readInt() != 0) {
            bm = Bitmap.CREATOR.createFromParcel(reply);
        }
        data.recycle();
        reply.recycle();
        return bm;
    }
    public List getServices(int maxNum, int flags) throws RemoteException {
    public List getServices(int maxNum, int flags) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        Parcel reply = Parcel.obtain();
+42 −2
Original line number Original line Diff line number Diff line
@@ -50,6 +50,26 @@ public class FragmentBreadCrumbs extends ViewGroup
    /** Listener to inform when a parent entry is clicked */
    /** Listener to inform when a parent entry is clicked */
    private OnClickListener mParentClickListener;
    private OnClickListener mParentClickListener;


    private OnBreadCrumbClickListener mOnBreadCrumbClickListener;
    
    /**
     * Interface to intercept clicks on the bread crumbs.
     */
    public interface OnBreadCrumbClickListener {
        /**
         * Called when a bread crumb is clicked.
         * 
         * @param backStack The BackStackEntry whose bread crumb was clicked.
         * May be null, if this bread crumb is for the root of the back stack.
         * @param flags Additional information about the entry.  Currently
         * always 0.
         * 
         * @return Return true to consume this click.  Return to false to allow
         * the default action (popping back stack to this entry) to occur.
         */
        public boolean onBreadCrumbClick(BackStackEntry backStack, int flags);
    }
    
    public FragmentBreadCrumbs(Context context) {
    public FragmentBreadCrumbs(Context context) {
        this(context, null);
        this(context, null);
    }
    }
@@ -107,6 +127,16 @@ public class FragmentBreadCrumbs extends ViewGroup
        updateCrumbs();
        updateCrumbs();
    }
    }


    /**
     * Sets a listener for clicks on the bread crumbs.  This will be called before
     * the default click action is performed.
     * 
     * @param listener The new listener to set.  Replaces any existing listener.
     */
    public void setOnBreadCrumbClickListener(OnBreadCrumbClickListener listener) {
        mOnBreadCrumbClickListener = listener;
    }
    
    private BackStackRecord createBackStackEntry(CharSequence title, CharSequence shortTitle) {
    private BackStackRecord createBackStackEntry(CharSequence title, CharSequence shortTitle) {
        if (title == null) return null;
        if (title == null) return null;


@@ -266,8 +296,18 @@ public class FragmentBreadCrumbs extends ViewGroup
                        mParentClickListener.onClick(v);
                        mParentClickListener.onClick(v);
                    }
                    }
                } else {
                } else {
                    mActivity.getFragmentManager().popBackStack(bse.getId(),
                    if (mOnBreadCrumbClickListener != null) {
                            bse == mTopEntry? FragmentManager.POP_BACK_STACK_INCLUSIVE : 0);
                        if (mOnBreadCrumbClickListener.onBreadCrumbClick(
                                bse == mTopEntry ? null : bse, 0)) {
                            return;
                        }
                    }
                    if (bse == mTopEntry) {
                        // Pop everything off the back stack.
                        mActivity.getFragmentManager().popBackStack();
                    } else {
                        mActivity.getFragmentManager().popBackStack(bse.getId(), 0);
                    }
                }
                }
            }
            }
        }
        }
+2 −1
Original line number Original line Diff line number Diff line
@@ -133,6 +133,7 @@ public interface IActivityManager extends IInterface {
                         IThumbnailReceiver receiver) throws RemoteException;
                         IThumbnailReceiver receiver) throws RemoteException;
    public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
    public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
            int flags) throws RemoteException;
            int flags) throws RemoteException;
    public Bitmap getTaskThumbnail(int taskId) throws RemoteException;
    public List getServices(int maxNum, int flags) throws RemoteException;
    public List getServices(int maxNum, int flags) throws RemoteException;
    public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
    public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
            throws RemoteException;
            throws RemoteException;
@@ -514,7 +515,7 @@ public interface IActivityManager extends IInterface {
    int FORCE_STOP_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+78;
    int FORCE_STOP_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+78;
    int KILL_PIDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+79;
    int KILL_PIDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+79;
    int GET_SERVICES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+80;
    int GET_SERVICES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+80;

    int GET_TASK_THUMBNAIL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+81;
    int GET_RUNNING_APP_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+82;
    int GET_RUNNING_APP_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+82;
    int GET_DEVICE_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+83;
    int GET_DEVICE_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+83;
    int PEEK_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+84;
    int PEEK_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+84;
Loading