* Called when we launched an activity that we forced to be resizable.
*/
void onActivityForcedResizable(String packageName, int taskId);
+
+ /**
+ * Callen when we launched an activity that is dismissed the docked stack.
+ */
+ void onActivityDismissingDockedStack();
}
<!-- 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 an app that got forced to be resizable gets shown in split-screen -->
- <string name="dock_forced_resizable">App may not work with split-screen.</string>
- <!-- Warning message when we try to dock a non-resizeble tasks and launch it in fullscreen instead. -->
- <string name="dock_non_resizeble_failed_to_dock_text">App does not support split-screen.</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] -->
<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_forced_resizable" />
- <java-symbol type="string" name="dock_non_resizeble_failed_to_dock_text" />
<java-symbol type="string" name="double_tap_toast" />
<java-symbol type="string" name="durationDays" />
<java-symbol type="string" name="durationDayHours" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:text="@string/forced_resizable_info_text"
+ android:text="@string/dock_forced_resizable"
android:textColor="#ffffff"/>
</FrameLayout>
\ No newline at end of file
<!-- Accessibility action for moving down the docked stack divider [CHAR LIMIT=NONE] -->
<string name="accessibility_action_divider_move_right">Move right</string>
- <!-- Text that gets shown on top of current activity to inform the user that the system force-resized the current activity and that things might crash/not work properly [CHAR LIMIT=NONE] -->
- <string name="forced_resizable_info_text">App may not work with multi-window</string>
-
<!-- Accessibility description of a QS tile while editing positions [CHAR LIMIT=NONE] -->
<string name="accessibility_qs_edit_tile_label">Position <xliff:g id="position" example="2">%1$d</xliff:g>, <xliff:g id="tile_name" example="Wi-Fi">%2$s</xliff:g>. Double tap to edit.</string>
<!-- Accessibility label for window when QS editing is happening [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_quick_settings_edit">Quick settings editor.</string>
+ <!-- Multi-Window strings -->
+ <!-- Text that gets shown on top of current activity to inform the user that the system force-resized the current activity and that things might crash/not work properly [CHAR LIMIT=NONE] -->
+ <string name="dock_forced_resizable">App may not work with split-screen.</string>
+ <!-- Warning message when we try to dock a non-resizeble tasks and launch it in fullscreen instead. -->
+ <string name="dock_non_resizeble_failed_to_dock_text">App does not support split-screen.</string>
+
</resources>
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
-import com.android.systemui.recents.events.activity.ForcedResizableEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
import com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent;
loader.loadTasks(mContext, plan, launchOpts);
}
}
-
- @Override
- public void onActivityForcedResizable(String packageName, int taskId) {
- EventBus.getDefault().sendOntoMainThread(
- new ForcedResizableEvent(packageName, taskId));
-
- }
}
protected static RecentsTaskLoadPlan sInstanceLoadPlan;
+++ /dev/null
-/*
- * Copyright (C) 2016 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 com.android.systemui.recents.events.activity;
-
-import com.android.systemui.recents.events.EventBus;
-
-/**
- * Sent when recents received the information that an activity got forced resizable, and we need
- * to inform the user about that.
- */
-public class ForcedResizableEvent extends EventBus.Event {
-
- public final String packageName;
- public final int taskId;
-
- public ForcedResizableEvent(String packageName, int taskId) {
- this.packageName = packageName;
- this.taskId = taskId;
- }
-}
public void onPinnedActivityRestartAttempt() { }
public void onPinnedStackAnimationEnded() { }
public void onActivityForcedResizable(String packageName, int taskId) { }
+ public void onActivityDismissingDockedStack() { }
}
/**
mHandler.obtainMessage(H.ON_ACTIVITY_FORCED_RESIZABLE, taskId, 0, packageName)
.sendToTarget();
}
+
+ @Override
+ public void onActivityDismissingDockedStack() throws RemoteException {
+ mHandler.sendEmptyMessage(H.ON_ACTIVITY_DISMISSING_DOCKED_STACK);
+ }
};
/**
private static final int ON_PINNED_ACTIVITY_RESTART_ATTEMPT = 3;
private static final int ON_PINNED_STACK_ANIMATION_ENDED = 4;
private static final int ON_ACTIVITY_FORCED_RESIZABLE = 5;
+ private static final int ON_ACTIVITY_DISMISSING_DOCKED_STACK = 6;
@Override
public void handleMessage(Message msg) {
}
break;
}
+ case ON_ACTIVITY_DISMISSING_DOCKED_STACK: {
+ for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
+ mTaskStackListeners.get(i).onActivityDismissingDockedStack();
+ }
+ break;
+ }
}
}
}
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
-import android.util.ArrayMap;
import android.util.ArraySet;
+import android.widget.Toast;
+import com.android.systemui.R;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.AppTransitionFinishedEvent;
-import com.android.systemui.recents.events.activity.ForcedResizableEvent;
+import com.android.systemui.recents.misc.SystemServicesProxy;
+import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
import com.android.systemui.stackdivider.events.StartedDragingEvent;
import com.android.systemui.stackdivider.events.StoppedDragingEvent;
public ForcedResizableInfoActivityController(Context context) {
mContext = context;
EventBus.getDefault().register(this);
+ SystemServicesProxy.getInstance(context).registerTaskStackListener(
+ new TaskStackListener() {
+ @Override
+ public void onActivityForcedResizable(String packageName, int taskId) {
+ activityForcedResizable(packageName, taskId);
+ }
+
+ @Override
+ public void onActivityDismissingDockedStack() {
+ activityDismissingDockedStack();
+ }
+ });
}
public void notifyDockedStackExistsChanged(boolean exists) {
}
}
- public final void onBusEvent(ForcedResizableEvent forcedResizableEvent) {
- if (debounce(forcedResizableEvent.packageName)) {
- return;
- }
- mPendingTaskIds.add(forcedResizableEvent.taskId);
- postTimeout();
- }
-
public final void onBusEvent(AppTransitionFinishedEvent event) {
if (!mDividerDraging) {
showPending();
showPending();
}
+ private void activityForcedResizable(String packageName, int taskId) {
+ if (debounce(packageName)) {
+ return;
+ }
+ mPendingTaskIds.add(taskId);
+ postTimeout();
+ }
+
+ private void activityDismissingDockedStack() {
+ Toast toast = Toast.makeText(mContext, R.string.dock_non_resizeble_failed_to_dock_text,
+ Toast.LENGTH_SHORT);
+ toast.show();
+ }
+
private void showPending() {
mHandler.removeCallbacks(mTimeoutRunnable);
for (int i = mPendingTaskIds.size() - 1; i >= 0; i--) {
static final int NOTIFY_PINNED_ACTIVITY_RESTART_ATTEMPT_LISTENERS_MSG = 65;
static final int NOTIFY_PINNED_STACK_ANIMATION_ENDED_LISTENERS_MSG = 66;
static final int NOTIFY_FORCED_RESIZABLE_MSG = 67;
+ static final int NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG = 68;
static final int FIRST_ACTIVITY_STACK_MSG = 100;
static final int FIRST_BROADCAST_QUEUE_MSG = 200;
}
break;
}
+ case NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG: {
+ synchronized (ActivityManagerService.this) {
+ for (int i = mTaskStackListeners.beginBroadcast() - 1; i >= 0; i--) {
+ try {
+ // Make a one-way callback to the listener
+ mTaskStackListeners.getBroadcastItem(i)
+ .onActivityDismissingDockedStack();
+ } catch (RemoteException e){
+ // Handled by the RemoteCallbackList
+ }
+ }
+ mTaskStackListeners.finishBroadcast();
+ }
+ break;
+ }
case NOTIFY_CLEARTEXT_NETWORK_MSG: {
final int uid = msg.arg1;
final byte[] firstPacket = (byte[]) msg.obj;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.am.ActivityManagerService.ANIMATE;
import static com.android.server.am.ActivityManagerService.FIRST_SUPERVISOR_STACK_MSG;
+import static com.android.server.am.ActivityManagerService.NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG;
import static com.android.server.am.ActivityManagerService.NOTIFY_FORCED_RESIZABLE_MSG;
import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
if (DEBUG_STACK) Slog.d(TAG_STACK,
"findTaskToMoveToFront: moved to front of stack=" + task.stack);
- showNonResizeableDockToastIfNeeded(task, INVALID_STACK_ID, task.stack.mStackId);
+ handleNonResizableTaskIfNeeded(task, INVALID_STACK_ID, task.stack.mStackId);
}
boolean canUseActivityOptionsLaunchBounds(ActivityOptions options, int launchStackId) {
resumeFocusedStackTopActivityLocked();
}
- showNonResizeableDockToastIfNeeded(task, preferredLaunchStackId, stackId);
+ handleNonResizableTaskIfNeeded(task, preferredLaunchStackId, stackId);
return (preferredLaunchStackId == stackId);
}
}
}
- void showNonResizeableDockToastIfNeeded(
+ void handleNonResizableTaskIfNeeded(
TaskRecord task, int preferredStackId, int actualStackId) {
- if (!isStackDockedInEffect(actualStackId) && preferredStackId != DOCKED_STACK_ID) {
+ if ((!isStackDockedInEffect(actualStackId) && preferredStackId != DOCKED_STACK_ID)
+ || task.isHomeTask()) {
return;
}
if (!task.canGoInDockedStack()) {
// Display a warning toast that we tried to put a non-dockable task in the docked stack.
- mWindowManager.scheduleShowNonResizeableDockToast(task.taskId);
+ mService.mHandler.sendEmptyMessage(NOTIFY_ACTIVITY_DISMISSING_DOCKED_STACK_MSG);
+
+ // Dismiss docked stack.
+ mService.moveTasksToFullscreenStack(DOCKED_STACK_ID, false);
} else if (task.mResizeMode == RESIZE_MODE_FORCE_RESIZEABLE) {
String packageName = task.getTopActivity() != null
? task.getTopActivity().appInfo.packageName : null;
}
top.deliverNewIntentLocked(
mCallingUid, mStartActivity.intent, mStartActivity.launchedFromPackage);
- mSupervisor.showNonResizeableDockToastIfNeeded(mStartActivity.task,
+ mSupervisor.handleNonResizableTaskIfNeeded(mStartActivity.task,
preferredLaunchStackId, topStack.mStackId);
return START_DELIVERED_TO_TOP;
}
}
mSupervisor.updateUserStackLocked(mStartActivity.userId, mTargetStack);
- mSupervisor.showNonResizeableDockToastIfNeeded(
+ mSupervisor.handleNonResizableTaskIfNeeded(
mStartActivity.task, preferredLaunchStackId, mTargetStack.mStackId);
return START_SUCCESS;
mTargetStack.moveToFront("intentActivityFound");
}
+ mSupervisor.handleNonResizableTaskIfNeeded(intentActivity.task, INVALID_STACK_ID,
+ mTargetStack.mStackId);
+
// If the caller has requested that the target task be reset, then do so.
if ((mLaunchFlags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) != 0) {
return mTargetStack.resetTaskIfNeededLocked(intentActivity, mStartActivity);
package com.android.server.wm;
+import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
-import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
-import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
-import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
-import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
-import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
+import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_RESIZE;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK;
+import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.H.RESIZE_TASK;
-import static com.android.server.wm.WindowManagerService.H.SHOW_NON_RESIZEABLE_DOCK_TOAST;
-import static android.view.WindowManager.DOCKED_INVALID;
-import static android.view.WindowManager.DOCKED_LEFT;
-import static android.view.WindowManager.DOCKED_RIGHT;
-import static android.view.WindowManager.DOCKED_TOP;
import android.app.ActivityManager.StackId;
import android.content.pm.ActivityInfo;
import android.view.DisplayInfo;
import android.view.Surface;
-import com.android.internal.R;
import com.android.server.EventLogTags;
import java.io.PrintWriter;
// Resize mode of the task. See {@link ActivityInfo#resizeMode}
private int mResizeMode;
- // Whether we need to show toast about the app being non-resizeable when it becomes visible.
- // This flag is set when a non-resizeable task is docked (or side-by-side). It's cleared
- // after we show the toast.
- private boolean mShowNonResizeableDockToast;
-
// Whether the task is currently being drag-resized
private boolean mDragResizing;
private int mDragResizeMode;
return mStack.getDisplayContent();
}
- void setShowNonResizeableDockToast() {
- mShowNonResizeableDockToast = true;
- }
-
- void scheduleShowNonResizeableDockToastIfNeeded() {
- if (!mShowNonResizeableDockToast) {
- return;
- }
- final DisplayContent displayContent = mStack.getDisplayContent();
- // If docked stack is not yet visible, we don't want to show the toast yet,
- // since we need the visible rect of the docked task to position the toast.
- if (displayContent == null || displayContent.getDockedStackLocked() == null) {
- return;
- }
-
- mShowNonResizeableDockToast = false;
-
- if (mResizeMode == RESIZE_MODE_UNRESIZEABLE) {
- final String text =
- mService.mContext.getString(R.string.dock_non_resizeble_failed_to_dock_text);
- mService.mH.obtainMessage(SHOW_NON_RESIZEABLE_DOCK_TOAST, 0, 0, text).sendToTarget();
- }
- }
-
void addAppToken(int addPos, AppWindowToken wtoken, int resizeMode, boolean homeTask) {
final int lastPos = mAppTokens.size();
if (addPos >= lastPos) {
}
}
- public void scheduleShowNonResizeableDockToast(int taskId) {
- synchronized (mWindowMap) {
- Task task = mTaskIdToTask.get(taskId);
- if (task == null) {
- if (DEBUG_STACK) Slog.i(TAG_WM, "scheduleShowToast: could not find taskId=" + taskId);
- return;
- }
- task.setShowNonResizeableDockToast();
- }
- }
-
@Override
public void getStackBounds(int stackId, Rect bounds) {
synchronized (mWindowMap) {
public static final int RESIZE_TASK = 43;
public static final int TWO_FINGER_SCROLL_START = 44;
- public static final int SHOW_NON_RESIZEABLE_DOCK_TOAST = 45;
public static final int WINDOW_REPLACEMENT_TIMEOUT = 46;
}
}
break;
- case SHOW_NON_RESIZEABLE_DOCK_TOAST: {
- final Toast toast = Toast.makeText(
- mContext, (String) msg.obj, Toast.LENGTH_SHORT);
- final int gravity = toast.getGravity();
- final int xOffset = toast.getXOffset() + msg.arg1;
- final int yOffset = toast.getYOffset() + msg.arg2;
- toast.setGravity(gravity, xOffset, yOffset);
- toast.show();
- }
- break;
case WINDOW_REPLACEMENT_TIMEOUT: {
final AppWindowToken token = (AppWindowToken) msg.obj;
synchronized (mWindowMap) {
}
}
w.mToken.hasVisible = true;
-
- final Task task = w.getTask();
- if (task != null) {
- task.scheduleShowNonResizeableDockToastIfNeeded();
- }
}
}