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.IAssistDataReceiver; 28 import android.app.IInstrumentationWatcher; 29 import android.app.IProcessObserver; 30 import android.app.IScreenCaptureObserver; 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.RemoteCallback; 68 import android.os.StrictMode; 69 import android.os.WorkSource; 70 import android.service.voice.IVoiceInteractionSession; 71 import android.view.IRecentsAnimationRunner; 72 import android.view.IRemoteAnimationRunner; 73 import android.view.RemoteAnimationDefinition; 74 import android.view.RemoteAnimationAdapter; 75 import android.window.IWindowOrganizerController; 76 import android.window.BackAnimationAdapter; 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); 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)109 int startActivityIntentSender(in IApplicationThread caller, 110 in IIntentSender target, in IBinder whitelistToken, in Intent fillInIntent, 111 in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, 112 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)113 WaitResult startActivityAndWait(in IApplicationThread caller, in String callingPackage, 114 in String callingFeatureId, in Intent intent, in String resolvedType, 115 in IBinder resultTo, in String resultWho, int requestCode, int flags, 116 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)117 int startActivityWithConfig(in IApplicationThread caller, in String callingPackage, 118 in String callingFeatureId, in Intent intent, in String resolvedType, 119 in IBinder resultTo, in String resultWho, int requestCode, int startFlags, 120 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)121 int startVoiceActivity(in String callingPackage, in String callingFeatureId, int callingPid, 122 int callingUid, in Intent intent, in String resolvedType, 123 in IVoiceInteractionSession session, in IVoiceInteractor interactor, int flags, 124 in ProfilerInfo profilerInfo, in Bundle options, int userId); getVoiceInteractorPackageName(in IBinder callingVoiceInteractor)125 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)126 int startAssistantActivity(in String callingPackage, in String callingFeatureId, int callingPid, 127 int callingUid, in Intent intent, in String resolvedType, in Bundle options, int userId); 128 @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)129 int startActivityFromGameSession(IApplicationThread caller, in String callingPackage, 130 in String callingFeatureId, int callingPid, int callingUid, in Intent intent, 131 int taskId, int userId); startRecentsActivity(in Intent intent, in long eventTime, in IRecentsAnimationRunner recentsAnimationRunner)132 void startRecentsActivity(in Intent intent, in long eventTime, 133 in IRecentsAnimationRunner recentsAnimationRunner); startActivityFromRecents(int taskId, in Bundle options)134 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)135 int startActivityAsCaller(in IApplicationThread caller, in String callingPackage, 136 in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, 137 int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, 138 boolean ignoreTargetSecurity, int userId); 139 isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType, int userId)140 boolean isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType, 141 int userId); 142 unhandledBack()143 void unhandledBack(); 144 145 /** Returns an interface to control the activity related operations. */ getActivityClientController()146 IActivityClientController getActivityClientController(); 147 getFrontActivityScreenCompatMode()148 int getFrontActivityScreenCompatMode(); setFrontActivityScreenCompatMode(int mode)149 void setFrontActivityScreenCompatMode(int mode); setFocusedTask(int taskId)150 void setFocusedTask(int taskId); removeTask(int taskId)151 boolean removeTask(int taskId); removeAllVisibleRecentTasks()152 void removeAllVisibleRecentTasks(); getTasks(int maxNum, boolean filterOnlyVisibleRecents, boolean keepIntentExtra, int displayId)153 List<ActivityManager.RunningTaskInfo> getTasks(int maxNum, boolean filterOnlyVisibleRecents, 154 boolean keepIntentExtra, int displayId); moveTaskToFront(in IApplicationThread app, in String callingPackage, int task, int flags, in Bundle options)155 void moveTaskToFront(in IApplicationThread app, in String callingPackage, int task, 156 int flags, in Bundle options); getRecentTasks(int maxNum, int flags, int userId)157 ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags, 158 int userId); isTopActivityImmersive()159 boolean isTopActivityImmersive(); reportAssistContextExtras(in IBinder assistToken, in Bundle extras, in AssistStructure structure, in AssistContent content, in Uri referrer)160 void reportAssistContextExtras(in IBinder assistToken, in Bundle extras, 161 in AssistStructure structure, in AssistContent content, in Uri referrer); 162 setFocusedRootTask(int taskId)163 void setFocusedRootTask(int taskId); getFocusedRootTaskInfo()164 ActivityTaskManager.RootTaskInfo getFocusedRootTaskInfo(); getTaskBounds(int taskId)165 Rect getTaskBounds(int taskId); 166 167 /** Focuses the top task on a display if it isn't already focused. Used for Recents. */ focusTopTask(int displayId)168 void focusTopTask(int displayId); 169 cancelRecentsAnimation(boolean restoreHomeRootTaskPosition)170 void cancelRecentsAnimation(boolean restoreHomeRootTaskPosition); 171 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.UPDATE_LOCK_TASK_PACKAGES)") updateLockTaskPackages(int userId, in String[] packages)172 void updateLockTaskPackages(int userId, in String[] packages); isInLockTaskMode()173 boolean isInLockTaskMode(); getLockTaskModeState()174 int getLockTaskModeState(); getAppTasks(in String callingPackage)175 List<IBinder> getAppTasks(in String callingPackage); startSystemLockTaskMode(int taskId)176 void startSystemLockTaskMode(int taskId); stopSystemLockTaskMode()177 void stopSystemLockTaskMode(); finishVoiceTask(in IVoiceInteractionSession session)178 void finishVoiceTask(in IVoiceInteractionSession session); addAppTask(in IBinder activityToken, in Intent intent, in ActivityManager.TaskDescription description, in Bitmap thumbnail)179 int addAppTask(in IBinder activityToken, in Intent intent, 180 in ActivityManager.TaskDescription description, in Bitmap thumbnail); getAppTaskThumbnailSize()181 Point getAppTaskThumbnailSize(); 182 releaseSomeActivities(in IApplicationThread app)183 oneway void releaseSomeActivities(in IApplicationThread app); getTaskDescriptionIcon(in String filename, int userId)184 Bitmap getTaskDescriptionIcon(in String filename, int userId); registerTaskStackListener(in ITaskStackListener listener)185 void registerTaskStackListener(in ITaskStackListener listener); unregisterTaskStackListener(in ITaskStackListener listener)186 void unregisterTaskStackListener(in ITaskStackListener listener); setTaskResizeable(int taskId, int resizeableMode)187 void setTaskResizeable(int taskId, int resizeableMode); 188 189 /** 190 * Resize the task with given bounds 191 * 192 * @param taskId The id of the task to set the bounds for. 193 * @param bounds The new bounds. 194 * @param resizeMode Resize mode defined as {@code ActivityTaskManager#RESIZE_MODE_*} constants. 195 */ resizeTask(int taskId, in Rect bounds, int resizeMode)196 void resizeTask(int taskId, in Rect bounds, int resizeMode); moveRootTaskToDisplay(int taskId, int displayId)197 void moveRootTaskToDisplay(int taskId, int displayId); 198 moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop)199 void moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop); 200 201 /** 202 * Removes root tasks in the input windowing modes from the system if they are of activity type 203 * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED 204 */ removeRootTasksInWindowingModes(in int[] windowingModes)205 void removeRootTasksInWindowingModes(in int[] windowingModes); 206 /** Removes root tasks of the activity types from the system. */ removeRootTasksWithActivityTypes(in int[] activityTypes)207 void removeRootTasksWithActivityTypes(in int[] activityTypes); 208 getAllRootTaskInfos()209 List<ActivityTaskManager.RootTaskInfo> getAllRootTaskInfos(); getRootTaskInfo(int windowingMode, int activityType)210 ActivityTaskManager.RootTaskInfo getRootTaskInfo(int windowingMode, int activityType); getAllRootTaskInfosOnDisplay(int displayId)211 List<ActivityTaskManager.RootTaskInfo> getAllRootTaskInfosOnDisplay(int displayId); getRootTaskInfoOnDisplay(int windowingMode, int activityType, int displayId)212 ActivityTaskManager.RootTaskInfo getRootTaskInfoOnDisplay(int windowingMode, int activityType, int displayId); 213 214 /** 215 * Informs ActivityTaskManagerService that the keyguard is showing. 216 * 217 * @param showingKeyguard True if the keyguard is showing, false otherwise. 218 * @param showingAod True if AOD is showing, false otherwise. 219 */ setLockScreenShown(boolean showingKeyguard, boolean showingAod)220 void setLockScreenShown(boolean showingKeyguard, boolean showingAod); getAssistContextExtras(int requestType)221 Bundle getAssistContextExtras(int requestType); requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver, in Bundle receiverExtras, in IBinder activityToken, boolean focused, boolean newSessionId)222 boolean requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver, 223 in Bundle receiverExtras, in IBinder activityToken, 224 boolean focused, boolean newSessionId); requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras, in IBinder activityToken, int flags)225 boolean requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras, 226 in IBinder activityToken, int flags); isAssistDataAllowed()227 boolean isAssistDataAllowed(); requestAssistDataForTask(in IAssistDataReceiver receiver, int taskId, in String callingPackageName, String callingAttributionTag)228 boolean requestAssistDataForTask(in IAssistDataReceiver receiver, int taskId, 229 in String callingPackageName, String callingAttributionTag); 230 231 /** 232 * Notify the system that the keyguard is going away. 233 * 234 * @param flags See 235 * {@link android.view.WindowManagerPolicyConstants#KEYGUARD_GOING_AWAY_FLAG_TO_SHADE} 236 * etc. 237 */ 238 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.CONTROL_KEYGUARD)") keyguardGoingAway(int flags)239 void keyguardGoingAway(int flags); 240 suppressResizeConfigChanges(boolean suppress)241 void suppressResizeConfigChanges(boolean suppress); 242 243 /** Returns an interface enabling the management of window organizers. */ getWindowOrganizerController()244 IWindowOrganizerController getWindowOrganizerController(); 245 supportsLocalVoiceInteraction()246 boolean supportsLocalVoiceInteraction(); 247 248 // Get device configuration getDeviceConfigurationInfo()249 ConfigurationInfo getDeviceConfigurationInfo(); 250 251 /** Cancels the window transitions for the given task. */ cancelTaskWindowTransition(int taskId)252 void cancelTaskWindowTransition(int taskId); 253 254 /** 255 * Fetches the snapshot for the task with the given id, taking a new snapshot if it is not in 256 * the task snapshot cache and it is requested. 257 * 258 * @param taskId the id of the task to retrieve the sAutoapshots for 259 * @param isLowResolution if set, if the snapshot needs to be loaded from disk, this will load 260 * a reduced resolution of it, which is much faster 261 * @return a graphic buffer representing a screenshot of a task 262 */ getTaskSnapshot( int taskId, boolean isLowResolution)263 android.window.TaskSnapshot getTaskSnapshot( 264 int taskId, boolean isLowResolution); 265 266 /** 267 * Requests for a new snapshot to be taken for the task with the given id, storing it in the 268 * task snapshot cache only if requested. 269 * 270 * @param taskId the id of the task to take a snapshot of 271 * @param updateCache Whether to store the new snapshot in the system's task snapshot cache. 272 * If it is true, the snapshot can be either real content or app-theme mode 273 * depending on the attributes of app. Otherwise, the snapshot will be taken 274 * with real content. 275 * @return a graphic buffer representing a screenshot of a task 276 */ takeTaskSnapshot(int taskId, boolean updateCache)277 android.window.TaskSnapshot takeTaskSnapshot(int taskId, boolean updateCache); 278 279 /** 280 * Return the user id of last resumed activity. 281 */ getLastResumedActivityUserId()282 int getLastResumedActivityUserId(); 283 284 /** 285 * Updates global configuration and applies changes to the entire system. 286 * @param values Update values for global configuration. If null is passed it will request the 287 * Window Manager to compute new config for the default display. 288 * @throws RemoteException 289 * @return Returns true if the configuration was updated. 290 */ updateConfiguration(in Configuration values)291 boolean updateConfiguration(in Configuration values); updateLockTaskFeatures(int userId, int flags)292 void updateLockTaskFeatures(int userId, int flags); 293 294 /** 295 * Registers a remote animation to be run for all activity starts from a certain package during 296 * a short predefined amount of time. 297 */ registerRemoteAnimationForNextActivityStart(in String packageName, in RemoteAnimationAdapter adapter, in IBinder launchCookie)298 void registerRemoteAnimationForNextActivityStart(in String packageName, 299 in RemoteAnimationAdapter adapter, in IBinder launchCookie); 300 301 /** 302 * Registers remote animations for a display. 303 */ registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition)304 void registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition); 305 306 /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */ alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity)307 void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity); 308 setVrThread(int tid)309 void setVrThread(int tid); setPersistentVrThread(int tid)310 void setPersistentVrThread(int tid); stopAppSwitches()311 void stopAppSwitches(); resumeAppSwitches()312 void resumeAppSwitches(); setActivityController(in IActivityController watcher, boolean imAMonkey)313 void setActivityController(in IActivityController watcher, boolean imAMonkey); setVoiceKeepAwake(in IVoiceInteractionSession session, boolean keepAwake)314 void setVoiceKeepAwake(in IVoiceInteractionSession session, boolean keepAwake); 315 getPackageScreenCompatMode(in String packageName)316 int getPackageScreenCompatMode(in String packageName); setPackageScreenCompatMode(in String packageName, int mode)317 void setPackageScreenCompatMode(in String packageName, int mode); getPackageAskScreenCompat(in String packageName)318 boolean getPackageAskScreenCompat(in String packageName); setPackageAskScreenCompat(in String packageName, boolean ask)319 void setPackageAskScreenCompat(in String packageName, boolean ask); 320 321 /** 322 * Clears launch params for given packages. 323 */ clearLaunchParamsForPackages(in List<String> packageNames)324 void clearLaunchParamsForPackages(in List<String> packageNames); 325 326 /** 327 * A splash screen view has copied. 328 */ onSplashScreenViewCopyFinished(int taskId, in @nullable SplashScreenView.SplashScreenViewParcelable material)329 void onSplashScreenViewCopyFinished(int taskId, 330 in @nullable SplashScreenView.SplashScreenViewParcelable material); 331 332 /** 333 * When the Picture-in-picture state has changed. 334 * @param pipState the {@link PictureInPictureUiState} is sent to current pip task if there is 335 * any -or- the top most task (state like entering PiP does not require a pinned task). 336 */ onPictureInPictureUiStateChanged(in PictureInPictureUiState pipState)337 void onPictureInPictureUiStateChanged(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 navigationObserver a remote callback to nofify shell when the focused window is gone, 357 or an unexpected transition has happened on the navigation target. 358 * @param adaptor a remote animation to be run for the back navigation plays the animation. 359 * @return Returns the back navigation info. 360 */ startBackNavigation( in RemoteCallback navigationObserver, in BackAnimationAdapter adaptor)361 android.window.BackNavigationInfo startBackNavigation( 362 in RemoteCallback navigationObserver, in BackAnimationAdapter adaptor); 363 364 /** 365 * registers a callback to be invoked when the screen is captured. 366 * 367 * @param observer callback to be registered. 368 * @param activityToken The token for the activity to set the callback to. 369 * @hide 370 */ registerScreenCaptureObserver(IBinder activityToken, IScreenCaptureObserver observer)371 void registerScreenCaptureObserver(IBinder activityToken, IScreenCaptureObserver observer); 372 373 /** 374 * unregisters the screen capture callback which was registered with 375 * {@link #registerScreenCaptureObserver(ScreenCaptureObserver)}. 376 * 377 * @param observer callback to be unregistered. 378 * @param activityToken The token for the activity to unset the callback from. 379 * @hide 380 */ unregisterScreenCaptureObserver(IBinder activityToken, IScreenCaptureObserver observer)381 void unregisterScreenCaptureObserver(IBinder activityToken, IScreenCaptureObserver observer); 382 } 383