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

Commit b15758ab authored by Chong Zhang's avatar Chong Zhang
Browse files

Support scrolling for non-resizeable tasks in side-by-side mode

Display toast when a non-resizeable task is put into side-by-side mode.

Scroll the task upon a two-finger scroll gesture.

bug: 25433902

Change-Id: I69967056a564cfe7773afb80aa7e7ea7167a791a
parent 786e12d9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3934,6 +3934,10 @@
    <!-- Lock-to-app unlock password string -->
    <string name="lock_to_app_unlock_password">Ask for password before unpinning</string>

    <!-- Multi-Window strings -->
    <!-- Warning message when a non-resizeble tasks is docked. -->
    <string name="dock_non_resizeble_text">App is not resizeable, scroll it with two fingers.</string>

    <!-- Notification shown when device owner silently installs a package [CHAR LIMIT=NONE] -->
    <string name="package_installed_device_owner">Installed by your administrator</string>
    <!-- Notification shown when device owner silently updates a package [CHAR LIMIT=NONE] -->
+1 −0
Original line number Diff line number Diff line
@@ -605,6 +605,7 @@
  <java-symbol type="string" name="display_manager_overlay_display_name" />
  <java-symbol type="string" name="display_manager_overlay_display_secure_suffix" />
  <java-symbol type="string" name="display_manager_overlay_display_title" />
  <java-symbol type="string" name="dock_non_resizeble_text" />
  <java-symbol type="string" name="double_tap_toast" />
  <java-symbol type="string" name="durationDays" />
  <java-symbol type="string" name="durationDayHours" />
+11 −1
Original line number Diff line number Diff line
@@ -8809,6 +8809,7 @@ public final class ActivityManagerService extends ActivityManagerNative
            }
            if (task.mResizeable != resizeable) {
                task.mResizeable = resizeable;
                mWindowManager.setTaskResizeable(taskId, resizeable);
                mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
                mStackSupervisor.resumeTopActivitiesLocked();
            }
@@ -8827,6 +8828,16 @@ public final class ActivityManagerService extends ActivityManagerNative
                    Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found");
                    return;
                }
                int stackId = task.stack.mStackId;
                // First, check if this is a non-resizeble task in docked stack or if the task size
                // is affected by the docked stack changing size. If so, instead of resizing, we
                // can only scroll the task. No need to update configuration.
                if (bounds != null && !task.mResizeable
                        && mStackSupervisor.isStackDockedInEffect(stackId)) {
                    mWindowManager.scrollTask(task.taskId, bounds);
                    return;
                }
                // Place the task in the right stack if it isn't there already based on
                // the requested bounds.
                // The stack transition logic is:
@@ -8834,7 +8845,6 @@ public final class ActivityManagerService extends ActivityManagerNative
                // - a non-null bounds on a non-freeform (fullscreen OR docked) task moves
                //   that task to freeform
                // - otherwise the task is not moved
                int stackId = task.stack.mStackId;
                if (!StackId.isTaskResizeAllowed(stackId)) {
                    throw new IllegalArgumentException("resizeTask not allowed on task=" + task);
                }
+2 −0
Original line number Diff line number Diff line
@@ -4700,6 +4700,7 @@ final class ActivityStack {
                (r.info.flags & ActivityInfo.FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId,
                r.info.configChanges, task.voiceSession != null, r.mLaunchTaskBehind,
                bounds, task.mOverrideConfig, !r.isHomeActivity());
        mWindowManager.setTaskResizeable(task.taskId, task.mResizeable);
        r.taskConfigOverride = task.mOverrideConfig;
    }

@@ -4753,6 +4754,7 @@ final class ActivityStack {
        task.updateOverrideConfiguration(bounds);
        mWindowManager.setAppTask(
                r.appToken, task.taskId, task.getLaunchBounds(), task.mOverrideConfig);
        mWindowManager.setTaskResizeable(task.taskId, task.mResizeable);
        r.taskConfigOverride = task.mOverrideConfig;
    }

+29 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
import static com.android.server.am.ActivityManagerDebugConfig.*;
import static com.android.server.am.ActivityManagerService.FIRST_SUPERVISOR_STACK_MSG;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
@@ -120,10 +121,13 @@ import android.view.Display;
import android.view.DisplayInfo;
import android.view.InputEvent;
import android.view.Surface;
import android.widget.Toast;

import com.android.internal.app.HeavyWeightSwitcherActivity;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.content.ReferrerIntent;
import com.android.internal.os.TransferPipe;
import com.android.internal.R;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.LockPatternUtils;
@@ -131,7 +135,6 @@ import com.android.server.LocalServices;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.wm.WindowManagerService;


import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
@@ -181,6 +184,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
    static final int CONTAINER_CALLBACK_TASK_LIST_EMPTY = FIRST_SUPERVISOR_STACK_MSG + 11;
    static final int LAUNCH_TASK_BEHIND_COMPLETE = FIRST_SUPERVISOR_STACK_MSG + 12;
    static final int SHOW_LOCK_TASK_ESCAPE_MESSAGE_MSG = FIRST_SUPERVISOR_STACK_MSG + 13;
    static final int SHOW_NON_RESIZEABLE_DOCK_TOAST = FIRST_SUPERVISOR_STACK_MSG + 14;

    private static final String VIRTUAL_DISPLAY_BASE_NAME = "ActivityViewVirtualDisplay";

@@ -3011,6 +3015,15 @@ public final class ActivityStackSupervisor implements DisplayListener {
        return null;
    }

    /**
     * Returns if a stack should be treated as if it's docked. Returns true if the stack is
     * the docked stack itself, or if it's side-by-side to the docked stack.
     */
    boolean isStackDockedInEffect(int stackId) {
        return stackId == DOCKED_STACK_ID ||
                (StackId.isResizeableByDockedStack(stackId) && getStack(DOCKED_STACK_ID) != null);
    }

    ActivityContainer createVirtualActivityContainer(ActivityRecord parentActivity,
            IActivityContainerCallback callback) {
        ActivityContainer activityContainer =
@@ -3378,6 +3391,10 @@ public final class ActivityStackSupervisor implements DisplayListener {
        // the visibility of the stack / windows.
        ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
        resumeTopActivitiesLocked();

        if (!task.mResizeable && isStackDockedInEffect(stackId)) {
            showNonResizeableDockToast();
        }
    }

    boolean moveTopStackActivityToPinnedStackLocked(int stackId, Rect bounds) {
@@ -4310,6 +4327,10 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
    }

    void showNonResizeableDockToast() {
        mHandler.sendEmptyMessage(SHOW_NON_RESIZEABLE_DOCK_TOAST);
    }

    void showLockTaskToast() {
        mLockTaskNotify.showToast(mLockTaskModeState);
    }
@@ -4622,6 +4643,13 @@ public final class ActivityStackSupervisor implements DisplayListener {
                        }
                    }
                } break;
                case SHOW_NON_RESIZEABLE_DOCK_TOAST: {
                    final Toast toast = Toast.makeText(
                            mService.mContext,
                            mService.mContext.getString(R.string.dock_non_resizeble_text),
                            Toast.LENGTH_LONG);
                    toast.show();
                } break;
            }
        }
    }
Loading