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.RemoteAnimationDefinition; 72 import android.view.RemoteAnimationAdapter; 73 import android.window.IWindowOrganizerController; 74 import android.window.SplashScreenView; 75 import com.android.internal.app.IVoiceInteractor; 76 import com.android.internal.os.IResultReceiver; 77 78 import java.util.List; 79 80 /** 81 * System private API for talking with the activity task manager that handles how activities are 82 * managed on screen. 83 * 84 * {@hide} 85 */ 86 // TODO(b/174040395): Make this interface private to ActivityTaskManager.java and have external 87 // caller go through that call instead. This would help us better separate and control the API 88 // surface exposed. 89 // TODO(b/174041603): Create a builder interface for things like startActivityXXX(...) to reduce 90 // interface duplication. 91 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)92 int startActivity(in IApplicationThread caller, in String callingPackage, 93 in String callingFeatureId, in Intent intent, in String resolvedType, 94 in IBinder resultTo, in String resultWho, int requestCode, 95 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)96 int startActivities(in IApplicationThread caller, in String callingPackage, 97 in String callingFeatureId, in Intent[] intents, in String[] resolvedTypes, 98 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)99 int startActivityAsUser(in IApplicationThread caller, in String callingPackage, 100 in String callingFeatureId, in Intent intent, in String resolvedType, 101 in IBinder resultTo, in String resultWho, int requestCode, int flags, 102 in ProfilerInfo profilerInfo, in Bundle options, int userId); startNextMatchingActivity(in IBinder callingActivity, in Intent intent, in Bundle options)103 boolean startNextMatchingActivity(in IBinder callingActivity, 104 in Intent intent, in Bundle options); 105 106 /** 107 * The DreamActivity has to be started in a special way that does not involve the PackageParser. 108 * The DreamActivity is a framework component inserted in the dream application process. Hence, 109 * it is not declared in the application's manifest and cannot be parsed. startDreamActivity 110 * creates the activity and starts it without reaching out to the PackageParser. 111 */ startDreamActivity(in Intent intent)112 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)113 int startActivityIntentSender(in IApplicationThread caller, 114 in IIntentSender target, in IBinder whitelistToken, in Intent fillInIntent, 115 in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode, 116 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)117 WaitResult startActivityAndWait(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 flags, 120 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)121 int startActivityWithConfig(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 startFlags, 124 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)125 int startVoiceActivity(in String callingPackage, in String callingFeatureId, int callingPid, 126 int callingUid, in Intent intent, in String resolvedType, 127 in IVoiceInteractionSession session, in IVoiceInteractor interactor, int flags, 128 in ProfilerInfo profilerInfo, in Bundle options, int userId); startAssistantActivity(in String callingPackage, in String callingFeatureId, int callingPid, int callingUid, in Intent intent, in String resolvedType, in Bundle options, int userId)129 int startAssistantActivity(in String callingPackage, in String callingFeatureId, int callingPid, 130 int callingUid, in Intent intent, in String resolvedType, in Bundle options, int userId); startRecentsActivity(in Intent intent, in long eventTime, in IRecentsAnimationRunner recentsAnimationRunner)131 void startRecentsActivity(in Intent intent, in long eventTime, 132 in IRecentsAnimationRunner recentsAnimationRunner); startActivityFromRecents(int taskId, in Bundle options)133 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, IBinder permissionToken, boolean ignoreTargetSecurity, int userId)134 int startActivityAsCaller(in IApplicationThread caller, in String callingPackage, 135 in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho, 136 int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options, 137 IBinder permissionToken, boolean ignoreTargetSecurity, int userId); 138 isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType, int userId)139 boolean isActivityStartAllowedOnDisplay(int displayId, in Intent intent, in String resolvedType, 140 int userId); 141 unhandledBack()142 void unhandledBack(); 143 144 /** Returns an interface to control the activity related operations. */ getActivityClientController()145 IActivityClientController getActivityClientController(); 146 getFrontActivityScreenCompatMode()147 int getFrontActivityScreenCompatMode(); setFrontActivityScreenCompatMode(int mode)148 void setFrontActivityScreenCompatMode(int mode); setFocusedTask(int taskId)149 void setFocusedTask(int taskId); removeTask(int taskId)150 boolean removeTask(int taskId); removeAllVisibleRecentTasks()151 void removeAllVisibleRecentTasks(); getTasks(int maxNum, boolean filterOnlyVisibleRecents, boolean keepIntentExtra)152 List<ActivityManager.RunningTaskInfo> getTasks(int maxNum, boolean filterOnlyVisibleRecents, 153 boolean keepIntentExtra); moveTaskToFront(in IApplicationThread app, in String callingPackage, int task, int flags, in Bundle options)154 void moveTaskToFront(in IApplicationThread app, in String callingPackage, int task, 155 int flags, in Bundle options); getRecentTasks(int maxNum, int flags, int userId)156 ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags, 157 int userId); isTopActivityImmersive()158 boolean isTopActivityImmersive(); getTaskDescription(int taskId)159 ActivityManager.TaskDescription getTaskDescription(int taskId); 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 cancelRecentsAnimation(boolean restoreHomeRootTaskPosition)167 void cancelRecentsAnimation(boolean restoreHomeRootTaskPosition); updateLockTaskPackages(int userId, in String[] packages)168 void updateLockTaskPackages(int userId, in String[] packages); isInLockTaskMode()169 boolean isInLockTaskMode(); getLockTaskModeState()170 int getLockTaskModeState(); getAppTasks(in String callingPackage)171 List<IBinder> getAppTasks(in String callingPackage); startSystemLockTaskMode(int taskId)172 void startSystemLockTaskMode(int taskId); stopSystemLockTaskMode()173 void stopSystemLockTaskMode(); finishVoiceTask(in IVoiceInteractionSession session)174 void finishVoiceTask(in IVoiceInteractionSession session); addAppTask(in IBinder activityToken, in Intent intent, in ActivityManager.TaskDescription description, in Bitmap thumbnail)175 int addAppTask(in IBinder activityToken, in Intent intent, 176 in ActivityManager.TaskDescription description, in Bitmap thumbnail); getAppTaskThumbnailSize()177 Point getAppTaskThumbnailSize(); 178 /** 179 * Only callable from the system. This token grants a temporary permission to call 180 * #startActivityAsCallerWithToken. The token will time out after 181 * START_AS_CALLER_TOKEN_TIMEOUT if it is not used. 182 * 183 * @param delegatorToken The Binder token referencing the system Activity that wants to delegate 184 * the #startActivityAsCaller to another app. The "caller" will be the caller of this 185 * activity's token, not the delegate's caller (which is probably the delegator itself). 186 * 187 * @return Returns a token that can be given to a "delegate" app that may call 188 * #startActivityAsCaller 189 */ requestStartActivityPermissionToken(in IBinder delegatorToken)190 IBinder requestStartActivityPermissionToken(in IBinder delegatorToken); 191 releaseSomeActivities(in IApplicationThread app)192 oneway void releaseSomeActivities(in IApplicationThread app); getTaskDescriptionIcon(in String filename, int userId)193 Bitmap getTaskDescriptionIcon(in String filename, int userId); registerTaskStackListener(in ITaskStackListener listener)194 void registerTaskStackListener(in ITaskStackListener listener); unregisterTaskStackListener(in ITaskStackListener listener)195 void unregisterTaskStackListener(in ITaskStackListener listener); setTaskResizeable(int taskId, int resizeableMode)196 void setTaskResizeable(int taskId, int resizeableMode); 197 198 /** 199 * Resize the task with given bounds 200 * 201 * @param taskId The id of the task to set the bounds for. 202 * @param bounds The new bounds. 203 * @param resizeMode Resize mode defined as {@code ActivityTaskManager#RESIZE_MODE_*} constants. 204 * @return Return true on success. Otherwise false. 205 */ resizeTask(int taskId, in Rect bounds, int resizeMode)206 boolean resizeTask(int taskId, in Rect bounds, int resizeMode); moveRootTaskToDisplay(int taskId, int displayId)207 void moveRootTaskToDisplay(int taskId, int displayId); 208 moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop)209 void moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop); 210 211 /** 212 * Removes root tasks in the input windowing modes from the system if they are of activity type 213 * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED 214 */ removeRootTasksInWindowingModes(in int[] windowingModes)215 void removeRootTasksInWindowingModes(in int[] windowingModes); 216 /** Removes root tasks of the activity types from the system. */ removeRootTasksWithActivityTypes(in int[] activityTypes)217 void removeRootTasksWithActivityTypes(in int[] activityTypes); 218 getAllRootTaskInfos()219 List<ActivityTaskManager.RootTaskInfo> getAllRootTaskInfos(); getRootTaskInfo(int windowingMode, int activityType)220 ActivityTaskManager.RootTaskInfo getRootTaskInfo(int windowingMode, int activityType); getAllRootTaskInfosOnDisplay(int displayId)221 List<ActivityTaskManager.RootTaskInfo> getAllRootTaskInfosOnDisplay(int displayId); getRootTaskInfoOnDisplay(int windowingMode, int activityType, int displayId)222 ActivityTaskManager.RootTaskInfo getRootTaskInfoOnDisplay(int windowingMode, int activityType, int displayId); 223 224 /** 225 * Informs ActivityTaskManagerService that the keyguard is showing. 226 * 227 * @param showingKeyguard True if the keyguard is showing, false otherwise. 228 * @param showingAod True if AOD is showing, false otherwise. 229 */ setLockScreenShown(boolean showingKeyguard, boolean showingAod)230 void setLockScreenShown(boolean showingKeyguard, boolean showingAod); getAssistContextExtras(int requestType)231 Bundle getAssistContextExtras(int requestType); requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver, in Bundle receiverExtras, in IBinder activityToken, boolean focused, boolean newSessionId)232 boolean requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver, 233 in Bundle receiverExtras, in IBinder activityToken, 234 boolean focused, boolean newSessionId); requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras, in IBinder activityToken, int flags)235 boolean requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras, 236 in IBinder activityToken, int flags); isAssistDataAllowedOnCurrentActivity()237 boolean isAssistDataAllowedOnCurrentActivity(); requestAssistDataForTask(in IAssistDataReceiver receiver, int taskId, in String callingPackageName)238 boolean requestAssistDataForTask(in IAssistDataReceiver receiver, int taskId, 239 in String callingPackageName); 240 241 /** 242 * Notify the system that the keyguard is going away. 243 * 244 * @param flags See 245 * {@link android.view.WindowManagerPolicyConstants#KEYGUARD_GOING_AWAY_FLAG_TO_SHADE} 246 * etc. 247 */ keyguardGoingAway(int flags)248 void keyguardGoingAway(int flags); 249 suppressResizeConfigChanges(boolean suppress)250 void suppressResizeConfigChanges(boolean suppress); 251 252 /** Returns an interface enabling the management of window organizers. */ getWindowOrganizerController()253 IWindowOrganizerController getWindowOrganizerController(); 254 255 /** 256 * Sets whether we are currently in an interactive split screen resize operation where we 257 * are changing the docked stack size. 258 */ setSplitScreenResizing(boolean resizing)259 void setSplitScreenResizing(boolean resizing); supportsLocalVoiceInteraction()260 boolean supportsLocalVoiceInteraction(); 261 262 // Get device configuration getDeviceConfigurationInfo()263 ConfigurationInfo getDeviceConfigurationInfo(); 264 265 /** Cancels the window transitions for the given task. */ cancelTaskWindowTransition(int taskId)266 void cancelTaskWindowTransition(int taskId); 267 268 /** 269 * @param taskId the id of the task to retrieve the sAutoapshots for 270 * @param isLowResolution if set, if the snapshot needs to be loaded from disk, this will load 271 * a reduced resolution of it, which is much faster 272 * @return a graphic buffer representing a screenshot of a task 273 */ getTaskSnapshot(int taskId, boolean isLowResolution)274 android.window.TaskSnapshot getTaskSnapshot(int taskId, boolean isLowResolution); 275 276 /** 277 * Return the user id of last resumed activity. 278 */ getLastResumedActivityUserId()279 int getLastResumedActivityUserId(); 280 281 /** 282 * Updates global configuration and applies changes to the entire system. 283 * @param values Update values for global configuration. If null is passed it will request the 284 * Window Manager to compute new config for the default display. 285 * @throws RemoteException 286 * @return Returns true if the configuration was updated. 287 */ updateConfiguration(in Configuration values)288 boolean updateConfiguration(in Configuration values); updateLockTaskFeatures(int userId, int flags)289 void updateLockTaskFeatures(int userId, int flags); 290 291 /** 292 * Registers a remote animation to be run for all activity starts from a certain package during 293 * a short predefined amount of time. 294 */ registerRemoteAnimationForNextActivityStart(in String packageName, in RemoteAnimationAdapter adapter)295 void registerRemoteAnimationForNextActivityStart(in String packageName, 296 in RemoteAnimationAdapter adapter); 297 298 /** 299 * Registers remote animations for a display. 300 */ registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition)301 void registerRemoteAnimationsForDisplay(int displayId, in RemoteAnimationDefinition definition); 302 303 /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */ alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity)304 void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity); 305 setVrThread(int tid)306 void setVrThread(int tid); setPersistentVrThread(int tid)307 void setPersistentVrThread(int tid); stopAppSwitches()308 void stopAppSwitches(); resumeAppSwitches()309 void resumeAppSwitches(); setActivityController(in IActivityController watcher, boolean imAMonkey)310 void setActivityController(in IActivityController watcher, boolean imAMonkey); setVoiceKeepAwake(in IVoiceInteractionSession session, boolean keepAwake)311 void setVoiceKeepAwake(in IVoiceInteractionSession session, boolean keepAwake); 312 getPackageScreenCompatMode(in String packageName)313 int getPackageScreenCompatMode(in String packageName); setPackageScreenCompatMode(in String packageName, int mode)314 void setPackageScreenCompatMode(in String packageName, int mode); getPackageAskScreenCompat(in String packageName)315 boolean getPackageAskScreenCompat(in String packageName); setPackageAskScreenCompat(in String packageName, boolean ask)316 void setPackageAskScreenCompat(in String packageName, boolean ask); 317 318 /** 319 * Clears launch params for given packages. 320 */ clearLaunchParamsForPackages(in List<String> packageNames)321 void clearLaunchParamsForPackages(in List<String> packageNames); 322 323 /** 324 * A splash screen view has copied. 325 */ onSplashScreenViewCopyFinished(int taskId, in SplashScreenView.SplashScreenViewParcelable material)326 void onSplashScreenViewCopyFinished(int taskId, 327 in SplashScreenView.SplashScreenViewParcelable material); 328 329 /** 330 * When the Picture-in-picture state has changed. 331 */ onPictureInPictureStateChanged(in PictureInPictureUiState pipState)332 void onPictureInPictureStateChanged(in PictureInPictureUiState pipState); 333 } 334