1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.app; 18 19 import android.app.ActivityManager; 20 import android.app.ActivityTaskManager; 21 import android.app.ApplicationErrorReport; 22 import android.app.ContentProviderHolder; 23 import android.app.GrantedUriPermission; 24 import android.app.IApplicationThread; 25 import android.app.IActivityClientController; 26 import android.app.IActivityController; 27 import android.app.IAppTask; 28 import android.app.IAssistDataReceiver; 29 import android.app.IInstrumentationWatcher; 30 import android.app.IProcessObserver; 31 import android.app.IServiceConnection; 32 import android.app.IStopUserCallback; 33 import android.app.ITaskStackListener; 34 import android.app.IUiAutomationConnection; 35 import android.app.IUidObserver; 36 import android.app.IUserSwitchObserver; 37 import android.app.Notification; 38 import android.app.PendingIntent; 39 import android.app.PictureInPictureUiState; 40 import android.app.ProfilerInfo; 41 import android.app.WaitResult; 42 import android.app.assist.AssistContent; 43 import android.app.assist.AssistStructure; 44 import android.content.ComponentName; 45 import android.content.IIntentReceiver; 46 import android.content.IIntentSender; 47 import android.content.Intent; 48 import android.content.IntentFilter; 49 import android.content.IntentSender; 50 import android.content.pm.ApplicationInfo; 51 import android.content.pm.ConfigurationInfo; 52 import android.content.pm.IPackageDataObserver; 53 import android.content.pm.ParceledListSlice; 54 import android.content.pm.ProviderInfo; 55 import android.content.pm.UserInfo; 56 import android.content.res.Configuration; 57 import android.graphics.Bitmap; 58 import android.graphics.GraphicBuffer; 59 import android.graphics.Point; 60 import android.graphics.Rect; 61 import android.net.Uri; 62 import android.os.Bundle; 63 import android.os.Debug; 64 import android.os.IBinder; 65 import android.os.IProgressListener; 66 import android.os.ParcelFileDescriptor; 67 import android.os.StrictMode; 68 import android.os.WorkSource; 69 import android.service.voice.IVoiceInteractionSession; 70 import android.view.IRecentsAnimationRunner; 71 import android.view.IRemoteAnimationRunner; 72 import android.view.IWindowFocusObserver; 73 import android.view.RemoteAnimationDefinition; 74 import android.view.RemoteAnimationAdapter; 75 import android.window.BackAnimationAdaptor; 76 import android.window.IWindowOrganizerController; 77 import android.window.BackNavigationInfo; 78 import android.window.SplashScreenView; 79 import com.android.internal.app.IVoiceInteractor; 80 import com.android.internal.os.IResultReceiver; 81 82 import java.util.List; 83 84 /** 85 * System private API for talking with the activity task manager that handles how activities are 86 * managed on screen. 87 * 88 * {@hide} 89 */ 90 // TODO(b/174040395): Make this interface private to ActivityTaskManager.java and have external 91 // caller go through that call instead. This would help us better separate and control the API 92 // surface exposed. 93 // TODO(b/174041603): Create a builder interface for things like startActivityXXX(...) to reduce 94 // interface duplication. 95 interface IActivityTaskManager { startActivity(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options)96 int startActivity(in IApplicationThread caller, in String callingPackage, 97 in String callingFeatureId, in Intent intent, in String resolvedType, 98 in IBinder resultTo, in String resultWho, int requestCode, 99 int flags, in ProfilerInfo profilerInfo, in Bundle options); startActivities(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent[] intents, in String[] resolvedTypes, in IBinder resultTo, in Bundle options, int userId)100 int startActivities(in IApplicationThread caller, in String callingPackage, 101 in String callingFeatureId, in Intent[] intents, in String[] resolvedTypes, 102 in IBinder resultTo, in Bundle options, int userId); startActivityAsUser(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, int userId)103 int startActivityAsUser(in IApplicationThread caller, in String callingPackage, 104 in String callingFeatureId, in Intent intent, in String resolvedType, 105 in IBinder resultTo, in String resultWho, int requestCode, int flags, 106 in ProfilerInfo profilerInfo, in Bundle options, int userId); startNextMatchingActivity(in IBinder callingActivity, in Intent intent, in Bundle options)107 boolean startNextMatchingActivity(in IBinder callingActivity, 108 in Intent intent, in Bundle options); 109 110 /** 111 * The DreamActivity has to be started in a special way that does not involve the PackageParser. 112 * The DreamActivity is a framework component inserted in the dream application process. Hence, 113 * it is not declared in the application's manifest and cannot be parsed. startDreamActivity 114 * creates the activity and starts it without reaching out to the PackageParser. 115 */ startDreamActivity(in Intent intent)116 boolean startDreamActivity(in Intent intent); startActivityIntentSender(in IApplicationThread caller, in IIntentSender target, in IBinder whitelistToken, in Intent fillInIntent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flagsMask, int flagsValues, in Bundle options)117 int startActivityIntentSender(in IApplicationThread caller, 118 in IIntentSender target, in IBinder whitelistToken, in Intent fillInIntent, 119 in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, 120 int flagsMask, int flagsValues, in Bundle options); startActivityAndWait(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, int userId)121 WaitResult startActivityAndWait(in IApplicationThread caller, in String callingPackage, 122 in String callingFeatureId, in Intent intent, in String resolvedType, 123 in IBinder resultTo, in String resultWho, int requestCode, int flags, 124 in ProfilerInfo profilerInfo, in Bundle options, int userId); startActivityWithConfig(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int startFlags, in Configuration newConfig, in Bundle options, int userId)125 int startActivityWithConfig(in IApplicationThread caller, in String callingPackage, 126 in String callingFeatureId, in Intent intent, in String resolvedType, 127 in IBinder resultTo, in String resultWho, int requestCode, int startFlags, 128 in Configuration newConfig, in Bundle options, int userId); startVoiceActivity(in String callingPackage, in String callingFeatureId, int callingPid, int callingUid, in Intent intent, in String resolvedType, in IVoiceInteractionSession session, in IVoiceInteractor interactor, int flags, in ProfilerInfo profilerInfo, in Bundle options, int userId)129 int startVoiceActivity(in String callingPackage, in String callingFeatureId, int callingPid, 130 int callingUid, in Intent intent, in String resolvedType, 131 in IVoiceInteractionSession session, in IVoiceInteractor interactor, int flags, 132 in ProfilerInfo profilerInfo, in Bundle options, int userId); getVoiceInteractorPackageName(in IBinder callingVoiceInteractor)133 String getVoiceInteractorPackageName(in IBinder callingVoiceInteractor); startAssistantActivity(in String callingPackage, in String callingFeatureId, int callingPid, int callingUid, in Intent intent, in String resolvedType, in Bundle options, int userId)134 int startAssistantActivity(in String callingPackage, in String callingFeatureId, int callingPid, 135 int callingUid, in Intent intent, in String resolvedType, in Bundle options, int userId); 136 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MANAGE_GAME_ACTIVITY)") startActivityFromGameSession(IApplicationThread caller, in String callingPackage, in String callingFeatureId, int callingPid, int callingUid, in Intent intent, int taskId, int userId)137 int startActivityFromGameSession(IApplicationThread caller, in String callingPackage, 138 in String callingFeatureId, int callingPid, int callingUid, in Intent intent, 139 int taskId, int userId); startRecentsActivity(in Intent intent, in long eventTime, in IRecentsAnimationRunner recentsAnimationRunner)140 void startRecentsActivity(in Intent intent, in long eventTime, 141 in IRecentsAnimationRunner recentsAnimationRunner); startActivityFromRecents(int taskId, in Bundle options)142 int startActivityFromRecents(int taskId, in Bundle options); startActivityAsCaller(in IApplicationThread caller, in String callingPackage, in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, boolean ignoreTargetSecurity, int userId)143 int startActivityAsCaller(in IApplicationThread caller, in String callingPackage, 144 in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, 145 int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, 146 boolean ignoreTargetSecurity, int userId); 147 isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType, int userId)148 boolean isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType, 149 int userId); 150 unhandledBack()151 void unhandledBack(); 152 153 /** Returns an interface to control the activity related operations. */ getActivityClientController()154 IActivityClientController getActivityClientController(); 155 getFrontActivityScreenCompatMode()156 int getFrontActivityScreenCompatMode(); setFrontActivityScreenCompatMode(int mode)157 void setFrontActivityScreenCompatMode(int mode); setFocusedTask(int taskId)158 void setFocusedTask(int taskId); removeTask(int taskId)159 boolean removeTask(int taskId); removeAllVisibleRecentTasks()160 void removeAllVisibleRecentTasks(); getTasks(int maxNum, boolean filterOnlyVisibleRecents, boolean keepIntentExtra, int displayId)161 List<ActivityManager.RunningTaskInfo> getTasks(int maxNum, boolean filterOnlyVisibleRecents, 162 boolean keepIntentExtra, int displayId); moveTaskToFront(in IApplicationThread app, in String callingPackage, int task, int flags, in Bundle options)163 void moveTaskToFront(in IApplicationThread app, in String callingPackage, int task, 164 int flags, in Bundle options); getRecentTasks(int maxNum, int flags, int userId)165 ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags, 166 int userId); isTopActivityImmersive()167 boolean isTopActivityImmersive(); getTaskDescription(int taskId)168 ActivityManager.TaskDescription getTaskDescription(int taskId); reportAssistContextExtras(in IBinder assistToken, in Bundle extras, in AssistStructure structure, in AssistContent content, in Uri referrer)169 void reportAssistContextExtras(in IBinder assistToken, in Bundle extras, 170 in AssistStructure structure, in AssistContent content, in Uri referrer); 171 setFocusedRootTask(int taskId)172 void setFocusedRootTask(int taskId); getFocusedRootTaskInfo()173 ActivityTaskManager.RootTaskInfo getFocusedRootTaskInfo(); getTaskBounds(int taskId)174 Rect getTaskBounds(int taskId); 175 cancelRecentsAnimation(boolean restoreHomeRootTaskPosition)176 void cancelRecentsAnimation(boolean restoreHomeRootTaskPosition); updateLockTaskPackages(int userId, in String[] packages)177 void updateLockTaskPackages(int userId, in String[] packages); isInLockTaskMode()178 boolean isInLockTaskMode(); getLockTaskModeState()179 int getLockTaskModeState(); getAppTasks(in String callingPackage)180 List<IBinder> getAppTasks(in String callingPackage); startSystemLockTaskMode(int taskId)181 void startSystemLockTaskMode(int taskId); stopSystemLockTaskMode()182 void stopSystemLockTaskMode(); finishVoiceTask(in IVoiceInteractionSession session)183 void finishVoiceTask(in IVoiceInteractionSession session); addAppTask(in IBinder activityToken, in Intent intent, in ActivityManager.TaskDescription description, in Bitmap thumbnail)184 int addAppTask(in IBinder activityToken, in Intent intent, 185 in ActivityManager.TaskDescription description, in Bitmap thumbnail); getAppTaskThumbnailSize()186 Point getAppTaskThumbnailSize(); 187 releaseSomeActivities(in IApplicationThread app)188 oneway void releaseSomeActivities(in IApplicationThread app); getTaskDescriptionIcon(in String filename, int userId)189 Bitmap getTaskDescriptionIcon(in String filename, int userId); registerTaskStackListener(in ITaskStackListener listener)190 void registerTaskStackListener(in ITaskStackListener listener); unregisterTaskStackListener(in ITaskStackListener listener)191 void unregisterTaskStackListener(in ITaskStackListener listener); setTaskResizeable(int taskId, int resizeableMode)192 void setTaskResizeable(int taskId, int resizeableMode); 193 194 /** 195 * Resize the task with given bounds 196 * 197 * @param taskId The id of the task to set the bounds for. 198 * @param bounds The new bounds. 199 * @param resizeMode Resize mode defined as {@code ActivityTaskManager#RESIZE_MODE_*} constants. 200 * @return Return true on success. Otherwise false. 201 */ resizeTask(int taskId, in Rect bounds, int resizeMode)202 boolean resizeTask(int taskId, in Rect bounds, int resizeMode); moveRootTaskToDisplay(int taskId, int displayId)203 void moveRootTaskToDisplay(int taskId, int displayId); 204 moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop)205 void moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop); 206 207 /** 208 * Removes root tasks in the input windowing modes from the system if they are of activity type 209 * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED 210 */ removeRootTasksInWindowingModes(in int[] windowingModes)211 void removeRootTasksInWindowingModes(in int[] windowingModes); 212 /** Removes root tasks of the activity types from the system. */ removeRootTasksWithActivityTypes(in int[] activityTypes)213 void removeRootTasksWithActivityTypes(in int[] activityTypes); 214 getAllRootTaskInfos()215 List<ActivityTaskManager.RootTaskInfo> getAllRootTaskInfos(); getRootTaskInfo(int windowingMode, int activityType)216 ActivityTaskManager.RootTaskInfo getRootTaskInfo(int windowingMode, int activityType); getAllRootTaskInfosOnDisplay(int displayId)217 List<ActivityTaskManager.RootTaskInfo> getAllRootTaskInfosOnDisplay(int displayId); getRootTaskInfoOnDisplay(int windowingMode, int activityType, int displayId)218 ActivityTaskManager.RootTaskInfo getRootTaskInfoOnDisplay(int windowingMode, int activityType, int displayId); 219 220 /** 221 * Informs ActivityTaskManagerService that the keyguard is showing. 222 * 223 * @param showingKeyguard True if the keyguard is showing, false otherwise. 224 * @param showingAod True if AOD is showing, false otherwise. 225 */ setLockScreenShown(boolean showingKeyguard, boolean showingAod)226 void setLockScreenShown(boolean showingKeyguard, boolean showingAod); getAssistContextExtras(int requestType)227 Bundle getAssistContextExtras(int requestType); requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver, in Bundle receiverExtras, in IBinder activityToken, boolean focused, boolean newSessionId)228 boolean requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver, 229 in Bundle receiverExtras, in IBinder activityToken, 230 boolean focused, boolean newSessionId); requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras, in IBinder activityToken, int flags)231 boolean requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras, 232 in IBinder activityToken, int flags); isAssistDataAllowedOnCurrentActivity()233 boolean isAssistDataAllowedOnCurrentActivity(); requestAssistDataForTask(in IAssistDataReceiver receiver, int taskId, in String callingPackageName)234 boolean requestAssistDataForTask(in IAssistDataReceiver receiver, int taskId, 235 in String callingPackageName); 236 237 /** 238 * Notify the system that the keyguard is going away. 239 * 240 * @param flags See 241 * {@link android.view.WindowManagerPolicyConstants#KEYGUARD_GOING_AWAY_FLAG_TO_SHADE} 242 * etc. 243 */ keyguardGoingAway(int flags)244 void keyguardGoingAway(int flags); 245 suppressResizeConfigChanges(boolean suppress)246 void suppressResizeConfigChanges(boolean suppress); 247 248 /** Returns an interface enabling the management of window organizers. */ getWindowOrganizerController()249 IWindowOrganizerController getWindowOrganizerController(); 250 251 /** 252 * Sets whether we are currently in an interactive split screen resize operation where we 253 * are changing the docked stack size. 254 */ setSplitScreenResizing(boolean resizing)255 void setSplitScreenResizing(boolean resizing); supportsLocalVoiceInteraction()256 boolean supportsLocalVoiceInteraction(); 257 258 // Get device configuration getDeviceConfigurationInfo()259 ConfigurationInfo getDeviceConfigurationInfo(); 260 261 /** Cancels the window transitions for the given task. */ cancelTaskWindowTransition(int taskId)262 void cancelTaskWindowTransition(int taskId); 263 264 /** 265 * @param taskId the id of the task to retrieve the sAutoapshots for 266 * @param isLowResolution if set, if the snapshot needs to be loaded from disk, this will load 267 * a reduced resolution of it, which is much faster 268 * @param takeSnapshotIfNeeded if set, call {@link #takeTaskSnapshot} to trigger the snapshot 269 if no cache exists. 270 * @return a graphic buffer representing a screenshot of a task 271 */ getTaskSnapshot( int taskId, boolean isLowResolution, boolean takeSnapshotIfNeeded)272 android.window.TaskSnapshot getTaskSnapshot( 273 int taskId, boolean isLowResolution, boolean takeSnapshotIfNeeded); 274 275 /** 276 * @param taskId the id of the task to take a snapshot of 277 * @return a graphic buffer representing a screenshot of a task 278 */ takeTaskSnapshot(int taskId)279 android.window.TaskSnapshot takeTaskSnapshot(int taskId); 280 281 /** 282 * Return the user id of last resumed activity. 283 */ getLastResumedActivityUserId()284 int getLastResumedActivityUserId(); 285 286 /** 287 * Updates global configuration and applies changes to the entire system. 288 * @param values Update values for global configuration. If null is passed it will request the 289 * Window Manager to compute new config for the default display. 290 * @throws RemoteException 291 * @return Returns true if the configuration was updated. 292 */ updateConfiguration(in Configuration values)293 boolean updateConfiguration(in Configuration values); updateLockTaskFeatures(int userId, int flags)294 void updateLockTaskFeatures(int userId, int flags); 295 296 /** 297 * Registers a remote animation to be run for all activity starts from a certain package during 298 * a short predefined amount of time. 299 */ registerRemoteAnimationForNextActivityStart(in String packageName, in RemoteAnimationAdapter adapter, in IBinder launchCookie)300 void registerRemoteAnimationForNextActivityStart(in String packageName, 301 in RemoteAnimationAdapter adapter, in IBinder launchCookie); 302 303 /** 304 * Registers remote animations for a display. 305 */ registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition)306 void registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition); 307 308 /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */ alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity)309 void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity); 310 setVrThread(int tid)311 void setVrThread(int tid); setPersistentVrThread(int tid)312 void setPersistentVrThread(int tid); stopAppSwitches()313 void stopAppSwitches(); resumeAppSwitches()314 void resumeAppSwitches(); setActivityController(in IActivityController watcher, boolean imAMonkey)315 void setActivityController(in IActivityController watcher, boolean imAMonkey); setVoiceKeepAwake(in IVoiceInteractionSession session, boolean keepAwake)316 void setVoiceKeepAwake(in IVoiceInteractionSession session, boolean keepAwake); 317 getPackageScreenCompatMode(in String packageName)318 int getPackageScreenCompatMode(in String packageName); setPackageScreenCompatMode(in String packageName, int mode)319 void setPackageScreenCompatMode(in String packageName, int mode); getPackageAskScreenCompat(in String packageName)320 boolean getPackageAskScreenCompat(in String packageName); setPackageAskScreenCompat(in String packageName, boolean ask)321 void setPackageAskScreenCompat(in String packageName, boolean ask); 322 323 /** 324 * Clears launch params for given packages. 325 */ clearLaunchParamsForPackages(in List<String> packageNames)326 void clearLaunchParamsForPackages(in List<String> packageNames); 327 328 /** 329 * A splash screen view has copied. 330 */ onSplashScreenViewCopyFinished(int taskId, in SplashScreenView.SplashScreenViewParcelable material)331 void onSplashScreenViewCopyFinished(int taskId, 332 in SplashScreenView.SplashScreenViewParcelable material); 333 334 /** 335 * When the Picture-in-picture state has changed. 336 */ onPictureInPictureStateChanged(in PictureInPictureUiState pipState)337 void onPictureInPictureStateChanged(in PictureInPictureUiState pipState); 338 339 /** 340 * Re-attach navbar to the display during a recents transition. 341 * TODO(188595497): Remove this once navbar attachment is in shell. 342 */ detachNavigationBarFromApp(in IBinder transition)343 void detachNavigationBarFromApp(in IBinder transition); 344 345 /** 346 * Marks a process as a delegate for the currently playing remote transition animation. This 347 * must be called from a process that is already a remote transition player or delegate. Any 348 * marked delegates are cleaned-up automatically at the end of the transition. 349 * @param caller is the IApplicationThread representing the calling process. 350 */ setRunningRemoteTransitionDelegate(in IApplicationThread caller)351 void setRunningRemoteTransitionDelegate(in IApplicationThread caller); 352 353 /** 354 * Prepare the back navigation in the server. This setups the leashed for sysui to animate 355 * the back gesture and returns the data needed for the animation. 356 * @param requestAnimation true if the caller wishes to animate the back navigation 357 * @param focusObserver a remote callback to nofify shell when the focused window lost focus. 358 */ startBackNavigation(in boolean requestAnimation, in IWindowFocusObserver focusObserver, in BackAnimationAdaptor adaptor)359 android.window.BackNavigationInfo startBackNavigation(in boolean requestAnimation, 360 in IWindowFocusObserver focusObserver, in BackAnimationAdaptor adaptor); 361 } 362