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

Commit 7b766fd3 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add APIs to notify and restart activity in size compatibility mode

- Notify listeners about whether the resumed activity is using the
  native screen configuration.
- Able to restart foreground activity with saved state.

Bug: 112288258
Test: atest ActivityRecordTests#testRestartProcessIfVisible
Test: atest ActivityDisplayTests#testHandleActivitySizeCompatMode

Change-Id: I0b916b25f187e9406154afced0214a41c02c761a
parent 5af401bd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -196,6 +196,9 @@ public abstract class ActivityManagerInternal {
    /** Kill the processes in the list due to their tasks been removed. */
    public abstract void killProcessesForRemovedTask(ArrayList<Object> procsToKill);

    /** Kill the process immediately. */
    public abstract void killProcess(String processName, int uid, String reason);

    /**
     * Returns {@code true} if {@code uid} is running an activity from {@code packageName}.
     */
+10 −0
Original line number Diff line number Diff line
@@ -473,4 +473,14 @@ interface IActivityTaskManager {
     * contain one task.
     */
    void setDisplayToSingleTaskInstance(int displayId);

    /**
     * Restarts the activity by killing its process if it is visible. If the activity is not
     * visible, the activity will not be restarted immediately and just keep the activity record in
     * the stack. It also resets the current override configuration so the activity will use the
     * configuration according to the latest state.
     *
     * @param activityToken The token of the target activity to restart.
     */
    void restartActivityProcessIfVisible(in IBinder activityToken);
}
+12 −0
Original line number Diff line number Diff line
@@ -149,4 +149,16 @@ oneway interface ITaskStackListener {
     * Called when a task snapshot got updated.
     */
    void onTaskSnapshotChanged(int taskId, in ActivityManager.TaskSnapshot snapshot);

    /**
     * Called when the resumed activity is in size compatibility mode and its override configuration
     * is different from the current one of system.
     *
     * @param displayId Id of the display where the activity resides.
     * @param activityToken Token of the size compatibility mode activity. It will be null when
     *                      switching to a activity that is not in size compatibility mode or the
     *                      configuration of the activity.
     * @see com.android.server.wm.AppWindowToken#inSizeCompatMode
     */
    void onSizeCompatModeActivityChanged(int displayId, in IBinder activityToken);
}
+7 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.app;
import android.annotation.UnsupportedAppUsage;
import android.app.ActivityManager.TaskSnapshot;
import android.content.ComponentName;
import android.os.IBinder;
import android.os.RemoteException;

/**
@@ -155,4 +156,10 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    @UnsupportedAppUsage
    public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) throws RemoteException {
    }

    @Override
    @UnsupportedAppUsage
    public void onSizeCompatModeActivityChanged(int displayId, IBinder activityToken)
            throws RemoteException {
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -17622,6 +17622,16 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        @Override
        public void killProcess(String processName, int uid, String reason) {
            synchronized (ActivityManagerService.this) {
                final ProcessRecord proc = getProcessRecordLocked(processName, uid,
                        true /* keepIfLarge */);
                mProcessList.removeProcessLocked(proc, false /* callerWillRestart */,
                        true /* allowRestart */, reason);
            }
        }
        @Override
        public boolean hasRunningActivity(int uid, @Nullable String packageName) {
            if (packageName == null) return false;
Loading