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

Commit 400f29c3 authored by Stefan Kuhne's avatar Stefan Kuhne Committed by Android (Google) Code Review
Browse files

Merge "Bring an activity to the front upon click & drag"

parents 43c2091a f36bb0ca
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2760,6 +2760,15 @@ public class Activity extends ContextThemeWrapper
        ActivityManagerNative.getDefault().setActivityBounds(mToken, newBounds);
    }

    /**
     * Activates this activity, hence bringing it to the top and giving it focus.
     * Note: This will only work for activities which are located on the freeform desktop.
     * @hide
     */
    public void activateActivity() throws RemoteException {
        ActivityManagerNative.getDefault().activateActivity(mToken);
    }

    /**
     * Called to process key events.  You can override this to intercept all
     * key events before they are dispatched to the window.  Be sure to call
+21 −1
Original line number Diff line number Diff line
@@ -827,10 +827,18 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case ACTIVATE_ACTIVITY_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            activateActivity(token);
            reply.writeNoException();
            return true;
        }

        case SET_FOCUSED_TASK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
            setFocusedStack(taskId);
            setFocusedTask(taskId);
            reply.writeNoException();
            return true;
        }
@@ -3623,6 +3631,18 @@ class ActivityManagerProxy implements IActivityManager
        return focusedStackId;
    }
    @Override
    public void activateActivity(IBinder token) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(ACTIVATE_ACTIVITY_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
    @Override
    public void setFocusedTask(int taskId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
+2 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ public interface IActivityManager extends IInterface {
    public boolean isInHomeStack(int taskId) throws RemoteException;
    public void setFocusedStack(int stackId) throws RemoteException;
    public int getFocusedStackId() throws RemoteException;
    public void activateActivity(IBinder token) throws RemoteException;
    public void setFocusedTask(int taskId) throws RemoteException;
    public void registerTaskStackListener(ITaskStackListener listener) throws RemoteException;
    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
@@ -892,4 +893,5 @@ public interface IActivityManager extends IInterface {
    int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
    int GET_ACTIVITY_BOUNDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 346;
    int SET_ACTIVITY_BOUNDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 347;
    int ACTIVATE_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 348;
}
+5 −0
Original line number Diff line number Diff line
@@ -510,6 +510,11 @@ public abstract class Window {
         * @param newBounds The new target bounds of the activity in task or stack.
         */
        void setActivityBounds(Rect newBounds) throws RemoteException;

        /**
         * Activates this activity, hence bringing it to the top and giving it focus.
         */
        void activateActivity() throws RemoteException;
    }

    public Window(Context context) {
+16 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ public class NonClientDecorView extends LinearLayout implements View.OnClickList
                    // When there is no decor we should not react to anything.
                    return false;
                }
                // Ensure that the activity is active.
                activateActivity();
                // A drag action is started if we aren't dragging already and the starting event is
                // either a left mouse button or any other input device.
                if (!mDragging &&
@@ -346,4 +348,18 @@ public class NonClientDecorView extends LinearLayout implements View.OnClickList
            }
        }
    }

    /**
     * Activates the activity - means setting the focus and moving it to the top of the stack.
     */
    private void activateActivity() {
        Window.WindowControllerCallback callback = mOwner.getWindowControllerCallback();
        if (callback != null) {
            try {
                callback.activateActivity();
            } catch (RemoteException ex) {
                Log.e(TAG, "Failed to activate the activity.");
            }
        }
    }
}
Loading