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

Commit 4a1cb220 authored by Craig Mautner's avatar Craig Mautner
Browse files

Pair ActivityStacks with Displays

- Introduce concept of ActivityStacks residing on Displays and able
to be decoupled and moved around.
- Add a new interface, IActivityContainer for clients to handle
ActivityStacks.
- Abandon ordering of stacks based on mStackState and instead use
ActivityDisplayInfo.stacks<ActivityStack> ordering.

Progress towards closing bug 12078972.

Change-Id: I7785b61c26dc17f432a4803eebee07c7415fcc1f
parent 3bcdbd6b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ LOCAL_SRC_FILES += \
	core/java/android/accounts/IAccountManagerResponse.aidl \
	core/java/android/accounts/IAccountAuthenticator.aidl \
	core/java/android/accounts/IAccountAuthenticatorResponse.aidl \
	core/java/android/app/IActivityContainer.aidl \
	core/java/android/app/IActivityContainerCallback.aidl \
	core/java/android/app/IActivityController.aidl \
	core/java/android/app/IActivityPendingResult.aidl \
	core/java/android/app/IAlarmManager.aidl \
+11 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ package com.android.commands.am;
import android.app.ActivityManager;
import android.app.ActivityManager.StackInfo;
import android.app.ActivityManagerNative;
import android.app.IActivityContainer;
import android.app.IActivityController;
import android.app.IActivityManager;
import android.app.IInstrumentationWatcher;
@@ -35,6 +36,7 @@ import android.graphics.Rect;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -107,7 +109,7 @@ public class Am extends BaseCommand {
                "       am to-intent-uri [INTENT]\n" +
                "       am switch-user <USER_ID>\n" +
                "       am stop-user <USER_ID>\n" +
                "       am stack create <TASK_ID>\n" +
                "       am stack create <TASK_ID> <DISPLAY_ID>\n" +
                "       am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" +
                "       am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" +
                "       am stack list\n" +
@@ -1558,10 +1560,16 @@ public class Am extends BaseCommand {
    private void runStackCreate() throws Exception {
        String taskIdStr = nextArgRequired();
        int taskId = Integer.valueOf(taskIdStr);
        String displayIdStr = nextArgRequired();
        int displayId = Integer.valueOf(displayIdStr);

        try {
            int stackId = mAm.createStack(taskId);
            System.out.println("createStack returned new stackId=" + stackId + "\n\n");
            IBinder homeActivityToken = mAm.getHomeActivityToken();
            IActivityContainer container = mAm.createActivityContainer(homeActivityToken, null);
            final int stackId = container.getStackId();
            System.out.println("createStack returned new stackId=" + stackId + "\n");
            container.attachToDisplay(displayId);
            mAm.moveTaskToStack(taskId, stackId, true);
        } catch (RemoteException e) {
        }
    }
+48 −23
Original line number Diff line number Diff line
@@ -612,15 +612,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case CREATE_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
            int res = createStack(taskId);
            reply.writeNoException();
            reply.writeInt(res);
            return true;
        }

        case MOVE_TASK_TO_STACK_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int taskId = data.readInt();
@@ -2027,6 +2018,26 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeNoException();
            return true;
        }

        case CREATE_ACTIVITY_CONTAINER_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder parentActivityToken = data.readStrongBinder();
            IActivityContainerCallback callback =
                    (IActivityContainerCallback) data.readStrongBinder();
            IActivityContainer activityContainer =
                    createActivityContainer(parentActivityToken, callback);
            reply.writeNoException();
            reply.writeStrongBinder(activityContainer.asBinder());
            return true;
        }

        case GET_HOME_ACTIVITY_TOKEN_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder homeActivityToken = getHomeActivityToken();
            reply.writeNoException();
            reply.writeStrongBinder(homeActivityToken);
            return true;
        }
        }

        return super.onTransact(code, data, reply, flags);
@@ -2714,20 +2725,6 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }
    @Override
    public int createStack(int taskId) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(taskId);
        mRemote.transact(CREATE_STACK_TRANSACTION, data, reply, 0);
        reply.readException();
        int res = reply.readInt();
        data.recycle();
        reply.recycle();
        return res;
    }
    @Override
    public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException
    {
        Parcel data = Parcel.obtain();
@@ -4655,5 +4652,33 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public IActivityContainer createActivityContainer(IBinder parentActivityToken,
            IActivityContainerCallback callback) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(parentActivityToken);
        data.writeStrongBinder((IBinder)callback);
        mRemote.transact(CREATE_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0);
        reply.readException();
        IActivityContainer res =
                IActivityContainer.Stub.asInterface(reply.readStrongBinder());
        data.recycle();
        reply.recycle();
        return res;
    }

    public IBinder getHomeActivityToken() throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        mRemote.transact(GET_HOME_ACTIVITY_TOKEN_TRANSACTION, data, reply, 0);
        reply.readException();
        IBinder res = reply.readStrongBinder();
        data.recycle();
        reply.recycle();
        return res;
    }

    private IBinder mRemote;
}
+29 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2013, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app;

import android.app.IActivityContainerCallback;
import android.content.Intent;
import android.os.IBinder;

/** @hide */
interface IActivityContainer {
    void attachToDisplay(int displayId);
    int getStackId();
    void detachFromDisplay();
    void startActivity(in Intent intent);
}
+24 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2013, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app;

import android.os.IBinder;

/** @hide */
interface IActivityContainerCallback {
    oneway void onLastActivityRemoved(IBinder container);
}
Loading