summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2018-06-12 18:18:48 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-06-12 18:18:48 +0000
commit6006f76ad7e15e360141369fb9deef5a76699261 (patch)
treecbbb224b553bfab482c4aea256528ccad6955a92 /core/java/android
parent1211216baee03ad882c7e1d7f3e8e0f3362572c0 (diff)
parent65ebd955e1b19a0d3c995e66d1d749bae5dc8575 (diff)
Merge "Split interfaces and service for activities from current AM interfaces (1/n)"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActivityManager.java227
-rw-r--r--core/java/android/app/ActivityOptions.java2
-rw-r--r--core/java/android/app/ActivityTaskManager.java253
-rw-r--r--core/java/android/app/IActivityManager.aidl17
-rw-r--r--core/java/android/app/IActivityTaskManager.aidl124
-rw-r--r--core/java/android/app/SystemServiceRegistry.java8
-rw-r--r--core/java/android/content/Context.java10
-rw-r--r--core/java/android/content/pm/PackageParser.java4
8 files changed, 402 insertions, 243 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index e7d352588652..9ff8223474d4 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -123,8 +123,6 @@ import java.util.List;
public class ActivityManager {
private static String TAG = "ActivityManager";
- private static int gMaxRecentTasks = -1;
-
private final Context mContext;
private static volatile boolean sSystemReady = false;
@@ -746,83 +744,6 @@ public class ActivityManager {
SystemProperties.getBoolean("debug.force_low_ram", false);
/** @hide */
- @TestApi
- public static class StackId {
-
- private StackId() {
- }
-
- /** Invalid stack ID. */
- public static final int INVALID_STACK_ID = -1;
-
- }
-
- /**
- * Parameter to {@link android.app.IActivityManager#setTaskWindowingModeSplitScreenPrimary}
- * which specifies the position of the created docked stack at the top half of the screen if
- * in portrait mode or at the left half of the screen if in landscape mode.
- * @hide
- */
- @TestApi
- public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0;
-
- /**
- * Parameter to {@link android.app.IActivityManager#setTaskWindowingModeSplitScreenPrimary}
- * which
- * specifies the position of the created docked stack at the bottom half of the screen if
- * in portrait mode or at the right half of the screen if in landscape mode.
- * @hide
- */
- @TestApi
- public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize doesn't need to preserve the window, and can be skipped if bounds
- * is unchanged. This mode is used by window manager in most cases.
- * @hide
- */
- public static final int RESIZE_MODE_SYSTEM = 0;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize should preserve the window if possible.
- * @hide
- */
- public static final int RESIZE_MODE_PRESERVE_WINDOW = (0x1 << 0);
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize should be performed even if the bounds appears unchanged.
- * @hide
- */
- public static final int RESIZE_MODE_FORCED = (0x1 << 1);
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} used by window
- * manager during a screen rotation.
- * @hide
- */
- public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION = RESIZE_MODE_PRESERVE_WINDOW;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} used when the
- * resize is due to a drag action.
- * @hide
- */
- public static final int RESIZE_MODE_USER = RESIZE_MODE_PRESERVE_WINDOW;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize should preserve the window if possible, and should not be skipped
- * even if the bounds is unchanged. Usually used to force a resizing when a drag action
- * is ending.
- * @hide
- */
- public static final int RESIZE_MODE_USER_FORCED =
- RESIZE_MODE_PRESERVE_WINDOW | RESIZE_MODE_FORCED;
-
- /** @hide */
public int getFrontActivityScreenCompatMode() {
try {
return getService().getFrontActivityScreenCompatMode();
@@ -977,57 +898,13 @@ public class ActivityManager {
}
/**
- * Return the maximum number of recents entries that we will maintain and show.
+ * TODO(b/80414790): Remove once no longer on hiddenapi-light-greylist.txt
* @hide
+ * @deprecated Use {@link ActivityTaskManager#getMaxRecentTasksStatic()}
*/
+ @Deprecated
static public int getMaxRecentTasksStatic() {
- if (gMaxRecentTasks < 0) {
- return gMaxRecentTasks = isLowRamDeviceStatic() ? 36 : 48;
- }
- return gMaxRecentTasks;
- }
-
- /**
- * Return the default limit on the number of recents that an app can make.
- * @hide
- */
- static public int getDefaultAppRecentsLimitStatic() {
- return getMaxRecentTasksStatic() / 6;
- }
-
- /**
- * Return the maximum limit on the number of recents that an app can make.
- * @hide
- */
- static public int getMaxAppRecentsLimitStatic() {
- return getMaxRecentTasksStatic() / 2;
- }
-
- /**
- * Returns true if the system supports at least one form of multi-window.
- * E.g. freeform, split-screen, picture-in-picture.
- * @hide
- */
- @TestApi
- static public boolean supportsMultiWindow(Context context) {
- // On watches, multi-window is used to present essential system UI, and thus it must be
- // supported regardless of device memory characteristics.
- boolean isWatch = context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WATCH);
- return (!isLowRamDeviceStatic() || isWatch)
- && Resources.getSystem().getBoolean(
- com.android.internal.R.bool.config_supportsMultiWindow);
- }
-
- /**
- * Returns true if the system supports split screen multi-window.
- * @hide
- */
- @TestApi
- static public boolean supportsSplitScreenMultiWindow(Context context) {
- return supportsMultiWindow(context)
- && Resources.getSystem().getBoolean(
- com.android.internal.R.bool.config_supportsSplitScreenMultiWindow);
+ return ActivityTaskManager.getMaxRecentTasksStatic();
}
/** @removed */
@@ -1998,102 +1875,6 @@ public class ActivityManager {
}
/**
- * Sets the windowing mode for a specific task. Only works on tasks of type
- * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
- * @param taskId The id of the task to set the windowing mode for.
- * @param windowingMode The windowing mode to set for the task.
- * @param toTop If the task should be moved to the top once the windowing mode changes.
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop)
- throws SecurityException {
- try {
- getService().setTaskWindowingMode(taskId, windowingMode, toTop);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Moves the input task to the primary-split-screen stack.
- * @param taskId Id of task to move.
- * @param createMode The mode the primary split screen stack should be created in if it doesn't
- * exist already. See
- * {@link android.app.ActivityManager#SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT}
- * and
- * {@link android.app.ActivityManager
- * #SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT}
- * @param toTop If the task and stack should be moved to the top.
- * @param animate Whether we should play an animation for the moving the task
- * @param initialBounds If the primary stack gets created, it will use these bounds for the
- * docked stack. Pass {@code null} to use default bounds.
- * @param showRecents If the recents activity should be shown on the other side of the task
- * going into split-screen mode.
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
- boolean animate, Rect initialBounds, boolean showRecents) throws SecurityException {
- try {
- getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, animate,
- initialBounds, showRecents);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Resizes the input stack id to the given bounds.
- * @param stackId Id of the stack to resize.
- * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void resizeStack(int stackId, Rect bounds) throws SecurityException {
- try {
- getService().resizeStack(stackId, bounds, false /* allowResizeInDockedMode */,
- false /* preserveWindows */, false /* animate */, -1 /* animationDuration */);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Removes stacks in the windowing modes from the system if they are of activity type
- * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
- *
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException {
- try {
- getService().removeStacksInWindowingModes(windowingModes);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Removes stack of the activity types from the system.
- *
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException {
- try {
- getService().removeStacksWithActivityTypes(activityTypes);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
* Represents a task snapshot.
* @hide
*/
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index ecd99a7b5402..89408cc340d9 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -17,7 +17,7 @@
package android.app;
import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.Display.INVALID_DISPLAY;
diff --git a/core/java/android/app/ActivityTaskManager.java b/core/java/android/app/ActivityTaskManager.java
new file mode 100644
index 000000000000..398644afd17a
--- /dev/null
+++ b/core/java/android/app/ActivityTaskManager.java
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) 2018 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 android.app;
+
+import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
+import android.annotation.TestApi;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.graphics.Rect;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Singleton;
+
+/**
+ * This class gives information about, and interacts with activities and their containers like task,
+ * stacks, and displays.
+ *
+ * @hide
+ */
+@TestApi
+@SystemService(Context.ACTIVITY_TASK_SERVICE)
+public class ActivityTaskManager {
+
+ /** Invalid stack ID. */
+ public static final int INVALID_STACK_ID = -1;
+
+ /**
+ * Parameter to {@link IActivityTaskManager#setTaskWindowingModeSplitScreenPrimary} which
+ * specifies the position of the created docked stack at the top half of the screen if
+ * in portrait mode or at the left half of the screen if in landscape mode.
+ */
+ public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0;
+
+ /**
+ * Parameter to {@link IActivityTaskManager#setTaskWindowingModeSplitScreenPrimary} which
+ * specifies the position of the created docked stack at the bottom half of the screen if
+ * in portrait mode or at the right half of the screen if in landscape mode.
+ */
+ public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize doesn't need to preserve the window, and can be skipped if bounds
+ * is unchanged. This mode is used by window manager in most cases.
+ * @hide
+ */
+ public static final int RESIZE_MODE_SYSTEM = 0;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize should preserve the window if possible.
+ * @hide
+ */
+ public static final int RESIZE_MODE_PRESERVE_WINDOW = (0x1 << 0);
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} used when the
+ * resize is due to a drag action.
+ * @hide
+ */
+ public static final int RESIZE_MODE_USER = RESIZE_MODE_PRESERVE_WINDOW;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} used by window
+ * manager during a screen rotation.
+ * @hide
+ */
+ public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION = RESIZE_MODE_PRESERVE_WINDOW;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize should be performed even if the bounds appears unchanged.
+ * @hide
+ */
+ public static final int RESIZE_MODE_FORCED = (0x1 << 1);
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize should preserve the window if possible, and should not be skipped
+ * even if the bounds is unchanged. Usually used to force a resizing when a drag action
+ * is ending.
+ * @hide
+ */
+ public static final int RESIZE_MODE_USER_FORCED =
+ RESIZE_MODE_PRESERVE_WINDOW | RESIZE_MODE_FORCED;
+
+ private static int sMaxRecentTasks = -1;
+
+ ActivityTaskManager(Context context, Handler handler) {
+ }
+
+ /** @hide */
+ public static IActivityTaskManager getService() {
+ return IActivityTaskManagerSingleton.get();
+ }
+
+ private static final Singleton<IActivityTaskManager> IActivityTaskManagerSingleton =
+ new Singleton<IActivityTaskManager>() {
+ @Override
+ protected IActivityTaskManager create() {
+ final IBinder b = ServiceManager.getService(Context.ACTIVITY_TASK_SERVICE);
+ return IActivityTaskManager.Stub.asInterface(b);
+ }
+ };
+
+ /**
+ * Sets the windowing mode for a specific task. Only works on tasks of type
+ * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
+ * @param taskId The id of the task to set the windowing mode for.
+ * @param windowingMode The windowing mode to set for the task.
+ * @param toTop If the task should be moved to the top once the windowing mode changes.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop)
+ throws SecurityException {
+ try {
+ getService().setTaskWindowingMode(taskId, windowingMode, toTop);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Moves the input task to the primary-split-screen stack.
+ * @param taskId Id of task to move.
+ * @param createMode The mode the primary split screen stack should be created in if it doesn't
+ * exist already. See
+ * {@link ActivityTaskManager#SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT}
+ * and
+ * {@link android.app.ActivityManager
+ * #SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT}
+ * @param toTop If the task and stack should be moved to the top.
+ * @param animate Whether we should play an animation for the moving the task
+ * @param initialBounds If the primary stack gets created, it will use these bounds for the
+ * docked stack. Pass {@code null} to use default bounds.
+ * @param showRecents If the recents activity should be shown on the other side of the task
+ * going into split-screen mode.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
+ boolean animate, Rect initialBounds, boolean showRecents) throws SecurityException {
+ try {
+ getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, animate,
+ initialBounds, showRecents);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Resizes the input stack id to the given bounds.
+ * @param stackId Id of the stack to resize.
+ * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void resizeStack(int stackId, Rect bounds) throws SecurityException {
+ try {
+ getService().resizeStack(stackId, bounds, false /* allowResizeInDockedMode */,
+ false /* preserveWindows */, false /* animate */, -1 /* animationDuration */);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Removes stacks in the windowing modes from the system if they are of activity type
+ * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException {
+ try {
+ getService().removeStacksInWindowingModes(windowingModes);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /** Removes stack of the activity types from the system. */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException {
+ try {
+ getService().removeStacksWithActivityTypes(activityTypes);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Return the maximum number of recents entries that we will maintain and show.
+ * @hide
+ */
+ public static int getMaxRecentTasksStatic() {
+ if (sMaxRecentTasks < 0) {
+ return sMaxRecentTasks = ActivityManager.isLowRamDeviceStatic() ? 36 : 48;
+ }
+ return sMaxRecentTasks;
+ }
+
+ /**
+ * Return the default limit on the number of recents that an app can make.
+ * @hide
+ */
+ public static int getDefaultAppRecentsLimitStatic() {
+ return getMaxRecentTasksStatic() / 6;
+ }
+
+ /**
+ * Return the maximum limit on the number of recents that an app can make.
+ * @hide
+ */
+ public static int getMaxAppRecentsLimitStatic() {
+ return getMaxRecentTasksStatic() / 2;
+ }
+
+ /**
+ * Returns true if the system supports at least one form of multi-window.
+ * E.g. freeform, split-screen, picture-in-picture.
+ */
+ public static boolean supportsMultiWindow(Context context) {
+ // On watches, multi-window is used to present essential system UI, and thus it must be
+ // supported regardless of device memory characteristics.
+ boolean isWatch = context.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WATCH);
+ return (!ActivityManager.isLowRamDeviceStatic() || isWatch)
+ && Resources.getSystem().getBoolean(
+ com.android.internal.R.bool.config_supportsMultiWindow);
+ }
+
+ /** Returns true if the system supports split screen multi-window. */
+ public static boolean supportsSplitScreenMultiWindow(Context context) {
+ return supportsMultiWindow(context)
+ && Resources.getSystem().getBoolean(
+ com.android.internal.R.bool.config_supportsSplitScreenMultiWindow);
+ }
+}
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index d22f578eeea9..d99084f74f8d 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -393,14 +393,6 @@ interface IActivityManager {
void setUserIsMonkey(boolean monkey);
void hang(in IBinder who, boolean allowRestart);
- /**
- * Sets the windowing mode for a specific task. Only works on tasks of type
- * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
- * @param taskId The id of the task to set the windowing mode for.
- * @param windowingMode The windowing mode to set for the task.
- * @param toTop If the task should be moved to the top once the windowing mode changes.
- */
- void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop);
void moveTaskToStack(int taskId, int stackId, boolean toTop);
/**
* Resizes the input stack id to the given bounds.
@@ -527,8 +519,6 @@ interface IActivityManager {
void exitFreeformMode(in IBinder token);
void reportSizeConfigurations(in IBinder token, in int[] horizontalSizeConfiguration,
in int[] verticalSizeConfigurations, in int[] smallestWidthConfigurations);
- boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
- boolean animate, in Rect initialBounds, boolean showRecents);
/**
* Dismisses split-screen multi-window mode.
* {@param toTop} If true the current primary split-screen stack will be placed or left on top.
@@ -596,13 +586,6 @@ interface IActivityManager {
void notifyPinnedStackAnimationStarted();
void notifyPinnedStackAnimationEnded();
void removeStack(int stackId);
- /**
- * Removes stacks in the input windowing modes from the system if they are of activity type
- * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
- */
- void removeStacksInWindowingModes(in int[] windowingModes);
- /** Removes stack of the activity types from the system. */
- void removeStacksWithActivityTypes(in int[] activityTypes);
void makePackageIdle(String packageName, int userId);
int getMemoryTrimLevel();
/**
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl
new file mode 100644
index 000000000000..8dfd6ab75b10
--- /dev/null
+++ b/core/java/android/app/IActivityTaskManager.aidl
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2018 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 android.app;
+
+import android.app.ActivityManager;
+import android.app.ApplicationErrorReport;
+import android.app.ContentProviderHolder;
+import android.app.GrantedUriPermission;
+import android.app.IApplicationThread;
+import android.app.IActivityController;
+import android.app.IAppTask;
+import android.app.IAssistDataReceiver;
+import android.app.IInstrumentationWatcher;
+import android.app.IProcessObserver;
+import android.app.IServiceConnection;
+import android.app.IStopUserCallback;
+import android.app.ITaskStackListener;
+import android.app.IUiAutomationConnection;
+import android.app.IUidObserver;
+import android.app.IUserSwitchObserver;
+import android.app.Notification;
+import android.app.PendingIntent;
+import android.app.PictureInPictureParams;
+import android.app.ProfilerInfo;
+import android.app.WaitResult;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
+import android.content.ComponentName;
+import android.content.IIntentReceiver;
+import android.content.IIntentSender;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.IntentSender;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.ConfigurationInfo;
+import android.content.pm.IPackageDataObserver;
+import android.content.pm.ParceledListSlice;
+import android.content.pm.ProviderInfo;
+import android.content.pm.UserInfo;
+import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.graphics.GraphicBuffer;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Debug;
+import android.os.IBinder;
+import android.os.IProgressListener;
+import android.os.ParcelFileDescriptor;
+import android.os.PersistableBundle;
+import android.os.StrictMode;
+import android.os.WorkSource;
+import android.service.voice.IVoiceInteractionSession;
+import android.view.IRecentsAnimationRunner;
+import android.view.RemoteAnimationDefinition;
+import android.view.RemoteAnimationAdapter;
+import com.android.internal.app.IVoiceInteractor;
+import com.android.internal.os.IResultReceiver;
+import com.android.internal.policy.IKeyguardDismissCallback;
+
+import java.util.List;
+
+/**
+ * System private API for talking with the activity task manager that handles how activities are
+ * managed on screen.
+ *
+ * {@hide}
+ */
+interface IActivityTaskManager {
+ List<ActivityManager.RunningTaskInfo> getTasks(int maxNum);
+ List<ActivityManager.RunningTaskInfo> getFilteredTasks(int maxNum, int ignoreActivityType,
+ int ignoreWindowingMode);
+ /**
+ * Sets the windowing mode for a specific task. Only works on tasks of type
+ * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
+ * @param taskId The id of the task to set the windowing mode for.
+ * @param windowingMode The windowing mode to set for the task.
+ * @param toTop If the task should be moved to the top once the windowing mode changes.
+ */
+ void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop);
+ void moveTaskToStack(int taskId, int stackId, boolean toTop);
+ /**
+ * Resizes the input stack id to the given bounds.
+ *
+ * @param stackId Id of the stack to resize.
+ * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
+ * @param allowResizeInDockedMode True if the resize should be allowed when the docked stack is
+ * active.
+ * @param preserveWindows True if the windows of activities contained in the stack should be
+ * preserved.
+ * @param animate True if the stack resize should be animated.
+ * @param animationDuration The duration of the resize animation in milliseconds or -1 if the
+ * default animation duration should be used.
+ * @throws RemoteException
+ */
+ void resizeStack(int stackId, in Rect bounds, boolean allowResizeInDockedMode,
+ boolean preserveWindows, boolean animate, int animationDuration);
+ boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
+ boolean animate, in Rect initialBounds, boolean showRecents);
+
+
+ /**
+ * Removes stacks in the input windowing modes from the system if they are of activity type
+ * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
+ */
+ void removeStacksInWindowingModes(in int[] windowingModes);
+ /** Removes stack of the activity types from the system. */
+ void removeStacksWithActivityTypes(in int[] activityTypes);
+}
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index e8ca4ff9e91c..2ad00e0a7fd8 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -215,6 +215,14 @@ final class SystemServiceRegistry {
return new ActivityManager(ctx.getOuterContext(), ctx.mMainThread.getHandler());
}});
+ registerService(Context.ACTIVITY_TASK_SERVICE, ActivityTaskManager.class,
+ new CachedServiceFetcher<ActivityTaskManager>() {
+ @Override
+ public ActivityTaskManager createService(ContextImpl ctx) {
+ return new ActivityTaskManager(
+ ctx.getOuterContext(), ctx.mMainThread.getHandler());
+ }});
+
registerService(Context.ALARM_SERVICE, AlarmManager.class,
new CachedServiceFetcher<AlarmManager>() {
@Override
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 1da77a24621e..c0cfb90e6676 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3328,6 +3328,16 @@ public abstract class Context {
/**
* Use with {@link #getSystemService(String)} to retrieve a
+ * {@link android.app.ActivityTaskManager} for interacting with the global system state.
+ *
+ * @see #getSystemService(String)
+ * @see android.app.ActivityTaskManager
+ * @hide
+ */
+ public static final String ACTIVITY_TASK_SERVICE = "activity_task";
+
+ /**
+ * Use with {@link #getSystemService(String)} to retrieve a
* {@link android.app.AlarmManager} for receiving intents at a
* time of your choosing.
*
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 9dbb2df697ac..950070ee7d6e 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -46,7 +46,7 @@ import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
-import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -4232,7 +4232,7 @@ public class PackageParser {
ActivityInfo.DOCUMENT_LAUNCH_NONE);
a.info.maxRecents = sa.getInt(
R.styleable.AndroidManifestActivity_maxRecents,
- ActivityManager.getDefaultAppRecentsLimitStatic());
+ ActivityTaskManager.getDefaultAppRecentsLimitStatic());
a.info.configChanges = getActivityConfigChanges(
sa.getInt(R.styleable.AndroidManifestActivity_configChanges, 0),
sa.getInt(R.styleable.AndroidManifestActivity_recreateOnConfigChanges, 0));