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

Commit fe89d122 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Add infrastructure to track activitiy relaunches

As a preparation to start synchronizing task size
with activity relaunches, we need a infrastructure
so we know in AM/WM when an activity is relaunching
and when it's done relaunching.

Bug: 26311778
Bug: 25015474
Change-Id: Ied3795eddbcd112f6329494afbf13178ca49a799
parent dc249c4a
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -570,6 +570,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

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

        case GET_CALLING_PACKAGE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
@@ -3413,6 +3421,17 @@ class ActivityManagerProxy implements IActivityManager
        data.recycle();
        reply.recycle();
    }
    public void activityRelaunched(IBinder token) throws RemoteException
    {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(ACTIVITY_RELAUNCHED_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
    public String getCallingPackage(IBinder token) throws RemoteException
    {
        Parcel data = Parcel.obtain();
+24 −0
Original line number Diff line number Diff line
@@ -4161,6 +4161,15 @@ public final class ActivityThread {
                            r.pendingIntents = pendingNewIntents;
                        }
                    }

                    // For each relaunch request, activity manager expects an answer
                    if (!r.onlyLocalRequest && fromServer) {
                        try {
                            ActivityManagerNative.getDefault().activityRelaunched(token);
                        } catch (RemoteException e) {
                            e.printStackTrace();
                        }
                    }
                    break;
                }
            }
@@ -4275,6 +4284,13 @@ public final class ActivityThread {
        ActivityClientRecord r = mActivities.get(tmp.token);
        if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handling relaunch of " + r);
        if (r == null) {
            if (!tmp.onlyLocalRequest) {
                try {
                    ActivityManagerNative.getDefault().activityRelaunched(tmp.token);
                } catch (RemoteException e) {
                    // If the system process has died, it's game over for everyone.
                }
            }
            return;
        }

@@ -4320,6 +4336,14 @@ public final class ActivityThread {
        r.overrideConfig = tmp.overrideConfig;

        handleLaunchActivity(r, currentIntent);

        if (!tmp.onlyLocalRequest) {
            try {
                ActivityManagerNative.getDefault().activityRelaunched(r.token);
            } catch (RemoteException e) {
                // If the system process has died, it's game over for everyone.
            }
        }
    }

    private void callCallActivityOnSaveInstanceState(ActivityClientRecord r) {
+3 −1
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ public interface IActivityManager extends IInterface {
            PersistableBundle persistentState, CharSequence description) throws RemoteException;
    public void activitySlept(IBinder token) throws RemoteException;
    public void activityDestroyed(IBinder token) throws RemoteException;
    public void activityRelaunched(IBinder token) throws RemoteException;
    public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
            int[] verticalSizeConfigurations, int[] smallestWidthConfigurations)
            throws RemoteException;
@@ -944,7 +945,8 @@ public interface IActivityManager extends IInterface {
    int IN_PICTURE_IN_PICTURE_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 353;
    int KILL_PACKAGE_DEPENDENTS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 354;
    int ENTER_PICTURE_IN_PICTURE_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 355;
    int SET_VR_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 356;
    int ACTIVITY_RELAUNCHED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 356;
    int GET_URI_PERMISSION_OWNER_FOR_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 357;
    int RESIZE_DOCKED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 358;
    int SET_VR_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 359;
}
+9 −0
Original line number Diff line number Diff line
@@ -6771,6 +6771,15 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public final void activityRelaunched(IBinder token) {
        final long origId = Binder.clearCallingIdentity();
        synchronized (this) {
            mStackSupervisor.activityRelaunchedLocked(token);
        }
        Binder.restoreCallingIdentity(origId);
    }
    @Override
    public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
            int[] verticalSizeConfigurations, int[] smallestSizeConfigurations) {
+1 −0
Original line number Diff line number Diff line
@@ -4314,6 +4314,7 @@ final class ActivityStack {
            r.app.thread.scheduleRelaunchActivity(r.appToken, results, newIntents, changes,
                    !andResume, new Configuration(mService.mConfiguration),
                    new Configuration(r.task.mOverrideConfig), preserveWindow);
            mStackSupervisor.activityRelaunchingLocked(r);
            // Note: don't need to call pauseIfSleepingLocked() here, because
            // the caller will only pass in 'andResume' if this activity is
            // currently resumed, which implies we aren't sleeping.
Loading