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

Commit 868a5e16 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Support for an activity to change and/or query it's associated stack

Change-Id: I4fc1b47e5d6196a56a6e40f10fae97219554722c
parent 706ed793
Loading
Loading
Loading
Loading
+24 −1
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import android.transition.Scene;
import android.transition.TransitionManager;
import android.transition.TransitionManager;
import android.util.ArrayMap;
import android.util.ArrayMap;
import android.util.SuperNotCalledException;
import android.util.SuperNotCalledException;
import android.view.Window.WindowStackCallback;
import android.widget.Toolbar;
import android.widget.Toolbar;


import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.IVoiceInteractor;
@@ -672,7 +673,7 @@ public class Activity extends ContextThemeWrapper
        implements LayoutInflater.Factory2,
        implements LayoutInflater.Factory2,
        Window.Callback, KeyEvent.Callback,
        Window.Callback, KeyEvent.Callback,
        OnCreateContextMenuListener, ComponentCallbacks2,
        OnCreateContextMenuListener, ComponentCallbacks2,
        Window.OnWindowDismissedCallback {
        Window.OnWindowDismissedCallback, WindowStackCallback {
    private static final String TAG = "Activity";
    private static final String TAG = "Activity";
    private static final boolean DEBUG_LIFECYCLE = false;
    private static final boolean DEBUG_LIFECYCLE = false;


@@ -2700,6 +2701,28 @@ public class Activity extends ContextThemeWrapper
        finish(finishTask ? FINISH_TASK_WITH_ACTIVITY : DONT_FINISH_TASK_WITH_ACTIVITY);
        finish(finishTask ? FINISH_TASK_WITH_ACTIVITY : DONT_FINISH_TASK_WITH_ACTIVITY);
    }
    }



    /** Called to move the window and its activity/task to a different stack container.
     * For example, a window can move between
     * {@link android.app.ActivityManager#FULLSCREEN_WORKSPACE_STACK_ID} stack and
     * {@link android.app.ActivityManager#FREEFORM_WORKSPACE_STACK_ID} stack.
     *
     * @param stackId stack Id to change to.
     * @hide
     */
    @Override
    public void changeWindowStack(int stackId) throws RemoteException {
        ActivityManagerNative.getDefault().moveActivityToStack(mToken, stackId);
    }

    /** Returns the current stack Id for the window.
     * @hide
     */
    @Override
    public int getWindowStackId() throws RemoteException {
        return ActivityManagerNative.getDefault().getActivityStackId(mToken);
    }

    /**
    /**
     * Called to process key events.  You can override this to intercept all
     * 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
     * key events before they are dispatched to the window.  Be sure to call
+1 −1
Original line number Original line Diff line number Diff line
@@ -405,7 +405,7 @@ public class ActivityManager {
    public static final int COMPAT_MODE_TOGGLE = 2;
    public static final int COMPAT_MODE_TOGGLE = 2;


    /**
    /**
     * First static stack stack ID.
     * First static stack ID.
     * @hide
     * @hide
     */
     */
    public static final int FIRST_STATIC_STACK_ID = 0;
    public static final int FIRST_STATIC_STACK_ID = 0;
+43 −0
Original line number Original line Diff line number Diff line
@@ -2636,6 +2636,22 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeInt(res ? 1 : 0);
            reply.writeInt(res ? 1 : 0);
            return true;
            return true;
        }
        }
        case GET_ACTIVITY_STACK_ID_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            int stackId = getActivityStackId(token);
            reply.writeNoException();
            reply.writeInt(stackId);
            return true;
        }
        case MOVE_ACTIVITY_TO_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            int stackId = data.readInt();
            moveActivityToStack(token, stackId);
            reply.writeNoException();
            return true;
        }
        }
        }


        return super.onTransact(code, data, reply, flags);
        return super.onTransact(code, data, reply, flags);
@@ -6101,5 +6117,32 @@ class ActivityManagerProxy implements IActivityManager
        return res != 0;
        return res != 0;
    }
    }


    @Override
    public void moveActivityToStack(IBinder token, int stackId) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        data.writeInt(stackId);
        mRemote.transact(MOVE_ACTIVITY_TO_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    @Override
    public int getActivityStackId(IBinder token) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(GET_ACTIVITY_STACK_ID_TRANSACTION, data, reply, 0);
        reply.readException();
        int stackId = reply.readInt();
        data.recycle();
        reply.recycle();
        return stackId;
    }

    private IBinder mRemote;
    private IBinder mRemote;
}
}
+5 −0
Original line number Original line Diff line number Diff line
@@ -527,6 +527,9 @@ public interface IActivityManager extends IInterface {
    // descriptor.
    // descriptor.
    public boolean stopBinderTrackingAndDump(ParcelFileDescriptor fd) throws RemoteException;
    public boolean stopBinderTrackingAndDump(ParcelFileDescriptor fd) throws RemoteException;


    public int getActivityStackId(IBinder token) throws RemoteException;
    public void moveActivityToStack(IBinder token, int stackId) throws RemoteException;

    /*
    /*
     * Private non-Binder interfaces
     * Private non-Binder interfaces
     */
     */
@@ -879,4 +882,6 @@ public interface IActivityManager extends IInterface {
    int START_BINDER_TRACKING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 340;
    int START_BINDER_TRACKING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 340;
    int STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 341;
    int STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 341;
    int POSITION_TASK_IN_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 342;
    int POSITION_TASK_IN_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 342;
    int GET_ACTIVITY_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 343;
    int MOVE_ACTIVITY_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
}
}
+16 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import android.media.session.MediaController;
import android.net.Uri;
import android.net.Uri;
import android.os.Bundle;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.os.SystemProperties;
import android.transition.Scene;
import android.transition.Scene;
import android.transition.Transition;
import android.transition.Transition;
@@ -476,6 +477,21 @@ public abstract class Window {
        void onWindowDismissed(boolean finishTask);
        void onWindowDismissed(boolean finishTask);
    }
    }


    /** @hide */
    public interface WindowStackCallback {
        /** Called to move the window and its activity/task to a different stack container.
         * For example, a window can move between
         * {@link android.app.ActivityManager#FULLSCREEN_WORKSPACE_STACK_ID} stack and
         * {@link android.app.ActivityManager#FREEFORM_WORKSPACE_STACK_ID} stack.
         *
         * @param stackId stack Id to change to.
         */
        void changeWindowStack(int stackId) throws RemoteException;

        /** Returns the current stack Id for the window. */
        int getWindowStackId() throws RemoteException;
    }

    public Window(Context context) {
    public Window(Context context) {
        mContext = context;
        mContext = context;
        mFeatures = mLocalFeatures = getDefaultFeatures(context);
        mFeatures = mLocalFeatures = getDefaultFeatures(context);
Loading