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

Commit e25a8292 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Added am command to suppress config. changes during task resize."

parents 04246b87 83301a93
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ public class Am extends BaseCommand {
                "       am task drag-task-test <TASK_ID> <STEP_SIZE> [DELAY_MS] \n" +
                "       am task size-task-test <TASK_ID> <STEP_SIZE> [DELAY_MS] \n" +
                "       am get-config\n" +
                "       am suppress-resize-config-changes <true|false>\n" +
                "       am set-inactive [--user <USER_ID>] <PACKAGE> true|false\n" +
                "       am get-inactive [--user <USER_ID>] <PACKAGE>\n" +
                "       am send-trim-memory [--user <USER_ID>] <PROCESS>\n" +
@@ -326,6 +327,8 @@ public class Am extends BaseCommand {
                "\n" +
                "am get-config: retrieve the configuration and any recent configurations\n" +
                "  of the device.\n" +
                "am suppress-resize-config-changes: suppresses configuration changes due to\n" +
                "  user resizing an activity/task.\n" +
                "\n" +
                "am set-inactive: sets the inactive state of an app.\n" +
                "\n" +
@@ -453,6 +456,8 @@ public class Am extends BaseCommand {
            runTask();
        } else if (op.equals("get-config")) {
            runGetConfig();
        } else if (op.equals("suppress-resize-config-changes")) {
            runSuppressResizeConfigChanges();
        } else if (op.equals("set-inactive")) {
            runSetInactive();
        } else if (op.equals("get-inactive")) {
@@ -2606,6 +2611,16 @@ public class Am extends BaseCommand {
        }
    }

    private void runSuppressResizeConfigChanges() throws Exception {
        boolean suppress = Boolean.valueOf(nextArgRequired());

        try {
            mAm.suppressResizeConfigChanges(suppress);
        } catch (RemoteException e) {
            System.err.println("Error suppressing resize config changes: " + e);
        }
    }

    private void runSetInactive() throws Exception {
        int userId = UserHandle.USER_CURRENT;

+19 −0
Original line number Diff line number Diff line
@@ -2682,6 +2682,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reportSizeConfigurations(token, horizontal, vertical);
            return true;
        }
        case SUPPRESS_RESIZE_CONFIG_CHANGES_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            final boolean suppress = data.readInt() == 1;
            suppressResizeConfigChanges(suppress);
            reply.writeNoException();
            return true;
        }
        }

        return super.onTransact(code, data, reply, flags);
@@ -6216,5 +6223,17 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    @Override
    public void suppressResizeConfigChanges(boolean suppress) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeInt(suppress ? 1 : 0);
        mRemote.transact(SUPPRESS_RESIZE_CONFIG_CHANGES_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    private IBinder mRemote;
}
+3 −0
Original line number Diff line number Diff line
@@ -535,6 +535,8 @@ public interface IActivityManager extends IInterface {
    public int getActivityStackId(IBinder token) throws RemoteException;
    public void moveActivityToStack(IBinder token, int stackId) throws RemoteException;

    public void suppressResizeConfigChanges(boolean suppress) throws RemoteException;

    /*
     * Private non-Binder interfaces
     */
@@ -891,4 +893,5 @@ public interface IActivityManager extends IInterface {
    int MOVE_ACTIVITY_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 344;
    int REPORT_SIZE_CONFIGURATIONS = IBinder.FIRST_CALL_TRANSACTION + 345;
    int MOVE_TASK_TO_DOCKED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 346;
    int SUPPRESS_RESIZE_CONFIG_CHANGES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 347;
}
+11 −0
Original line number Diff line number Diff line
@@ -994,6 +994,8 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    int mConfigurationSeq = 0;
    boolean mSuppressResizeConfigChanges = false;
    /**
     * Hardware-reported OpenGLES version.
     */
@@ -17514,6 +17516,15 @@ public final class ActivityManagerService extends ActivityManagerNative
        return ci;
    }
    @Override
    public void suppressResizeConfigChanges(boolean suppress) throws RemoteException {
        enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
                "suppressResizeConfigChanges()");
        synchronized (this) {
            mSuppressResizeConfigChanges = suppress;
        }
    }
    @Override
    public void updatePersistentConfiguration(Configuration values) {
        enforceCallingPermission(android.Manifest.permission.CHANGE_CONFIGURATION,
+6 −4
Original line number Diff line number Diff line
@@ -4181,8 +4181,12 @@ final class ActivityStack {
                | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE | ActivityInfo.CONFIG_ORIENTATION)) == 0;
    }

    private boolean relaunchActivityLocked(ActivityRecord r, int changes, boolean andResume,
            boolean preserveWindow) {
    private void relaunchActivityLocked(
            ActivityRecord r, int changes, boolean andResume, boolean preserveWindow) {
        if (mService.mSuppressResizeConfigChanges && preserveWindow) {
            return;
        }

        List<ResultInfo> results = null;
        List<ReferrerIntent> newIntents = null;
        if (andResume) {
@@ -4222,8 +4226,6 @@ final class ActivityStack {
            mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r);
            r.state = ActivityState.PAUSED;
        }

        return true;
    }

    boolean willActivityBeVisibleLocked(IBinder token) {