1 /*
2  * Copyright (C) 2020 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.ICompatCameraControlCallback;
21 import android.app.IRequestFinishCallback;
22 import android.app.PictureInPictureParams;
23 import android.content.ComponentName;
24 import android.content.Intent;
25 import android.content.res.Configuration;
26 import android.net.Uri;
27 import android.os.Bundle;
28 import android.os.IRemoteCallback;
29 import android.os.PersistableBundle;
30 import android.view.RemoteAnimationDefinition;
31 import android.window.SizeConfigurationBuckets;
32 
33 import com.android.internal.policy.IKeyguardDismissCallback;
34 
35 /**
36  * Interface for the callback and request from an activity to system.
37  *
38  * {@hide}
39  */
40 interface IActivityClientController {
activityIdle(in IBinder token, in Configuration config, in boolean stopProfiling)41     oneway void activityIdle(in IBinder token, in Configuration config, in boolean stopProfiling);
activityResumed(in IBinder token, in boolean handleSplashScreenExit)42     oneway void activityResumed(in IBinder token, in boolean handleSplashScreenExit);
activityRefreshed(in IBinder token)43     oneway void activityRefreshed(in IBinder token);
44     /**
45      * This call is not one-way because {@link #activityPaused()) is not one-way, or
46      * the top-resumed-lost could be reported after activity paused.
47      */
activityTopResumedStateLost()48     void activityTopResumedStateLost();
49     /**
50      * Notifies that the activity has completed paused. This call is not one-way because it can make
51      * consecutive launch in the same process more coherent. About the order of binder call, it
52      * should be fine with other one-way calls because if pause hasn't completed on the server side,
53      * there won't be other lifecycle changes.
54      */
activityPaused(in IBinder token)55     void activityPaused(in IBinder token);
activityStopped(in IBinder token, in Bundle state, in PersistableBundle persistentState, in CharSequence description)56     oneway void activityStopped(in IBinder token, in Bundle state,
57             in PersistableBundle persistentState, in CharSequence description);
activityDestroyed(in IBinder token)58     oneway void activityDestroyed(in IBinder token);
activityLocalRelaunch(in IBinder token)59     oneway void activityLocalRelaunch(in IBinder token);
activityRelaunched(in IBinder token)60     oneway void activityRelaunched(in IBinder token);
61 
reportSizeConfigurations(in IBinder token, in SizeConfigurationBuckets sizeConfigurations)62     oneway void reportSizeConfigurations(in IBinder token,
63             in SizeConfigurationBuckets sizeConfigurations);
moveActivityTaskToBack(in IBinder token, boolean nonRoot)64     boolean moveActivityTaskToBack(in IBinder token, boolean nonRoot);
shouldUpRecreateTask(in IBinder token, in String destAffinity)65     boolean shouldUpRecreateTask(in IBinder token, in String destAffinity);
navigateUpTo(in IBinder token, in Intent target, in String resolvedType, int resultCode, in Intent resultData)66     boolean navigateUpTo(in IBinder token, in Intent target, in String resolvedType,
67             int resultCode, in Intent resultData);
releaseActivityInstance(in IBinder token)68     boolean releaseActivityInstance(in IBinder token);
finishActivity(in IBinder token, int code, in Intent data, int finishTask)69     boolean finishActivity(in IBinder token, int code, in Intent data, int finishTask);
finishActivityAffinity(in IBinder token)70     boolean finishActivityAffinity(in IBinder token);
71     /** Finish all activities that were started for result from the specified activity. */
finishSubActivity(in IBinder token, in String resultWho, int requestCode)72     void finishSubActivity(in IBinder token, in String resultWho, int requestCode);
73     /**
74      * Indicates that when the activity finsihes, the result should be immediately sent to the
75      * originating activity. Must only be invoked during MediaProjection setup.
76      */
77     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.MANAGE_MEDIA_PROJECTION)")
setForceSendResultForMediaProjection(in IBinder token)78     void setForceSendResultForMediaProjection(in IBinder token);
79 
isTopOfTask(in IBinder token)80     boolean isTopOfTask(in IBinder token);
willActivityBeVisible(in IBinder token)81     boolean willActivityBeVisible(in IBinder token);
getDisplayId(in IBinder activityToken)82     int getDisplayId(in IBinder activityToken);
getTaskForActivity(in IBinder token, in boolean onlyRoot)83     int getTaskForActivity(in IBinder token, in boolean onlyRoot);
84     /**
85      * Returns the {@link Configuration} of the task which hosts the Activity, or {@code null} if
86      * the task {@link Configuration} cannot be obtained.
87      */
getTaskConfiguration(in IBinder activityToken)88     Configuration getTaskConfiguration(in IBinder activityToken);
getActivityTokenBelow(IBinder token)89     IBinder getActivityTokenBelow(IBinder token);
getCallingActivity(in IBinder token)90     ComponentName getCallingActivity(in IBinder token);
getCallingPackage(in IBinder token)91     String getCallingPackage(in IBinder token);
getLaunchedFromUid(in IBinder token)92     int getLaunchedFromUid(in IBinder token);
getActivityCallerUid(in IBinder activityToken, in IBinder callerToken)93     int getActivityCallerUid(in IBinder activityToken, in IBinder callerToken);
getLaunchedFromPackage(in IBinder token)94     String getLaunchedFromPackage(in IBinder token);
getActivityCallerPackage(in IBinder activityToken, in IBinder callerToken)95     String getActivityCallerPackage(in IBinder activityToken, in IBinder callerToken);
96 
checkActivityCallerContentUriPermission(in IBinder activityToken, in IBinder callerToken, in Uri uri, int modeFlags, int userId)97     int checkActivityCallerContentUriPermission(in IBinder activityToken, in IBinder callerToken,
98             in Uri uri, int modeFlags, int userId);
99 
setRequestedOrientation(in IBinder token, int requestedOrientation)100     void setRequestedOrientation(in IBinder token, int requestedOrientation);
getRequestedOrientation(in IBinder token)101     int getRequestedOrientation(in IBinder token);
102 
convertFromTranslucent(in IBinder token)103     boolean convertFromTranslucent(in IBinder token);
convertToTranslucent(in IBinder token, in Bundle options)104     boolean convertToTranslucent(in IBinder token, in Bundle options);
105 
isImmersive(in IBinder token)106     boolean isImmersive(in IBinder token);
setImmersive(in IBinder token, boolean immersive)107     void setImmersive(in IBinder token, boolean immersive);
108 
enterPictureInPictureMode(in IBinder token, in PictureInPictureParams params)109     boolean enterPictureInPictureMode(in IBinder token, in PictureInPictureParams params);
setPictureInPictureParams(in IBinder token, in PictureInPictureParams params)110     void setPictureInPictureParams(in IBinder token, in PictureInPictureParams params);
setShouldDockBigOverlays(in IBinder token, in boolean shouldDockBigOverlays)111     oneway void setShouldDockBigOverlays(in IBinder token, in boolean shouldDockBigOverlays);
toggleFreeformWindowingMode(in IBinder token)112     void toggleFreeformWindowingMode(in IBinder token);
requestMultiwindowFullscreen(in IBinder token, in int request, in IRemoteCallback callback)113     oneway void requestMultiwindowFullscreen(in IBinder token, in int request,
114             in IRemoteCallback callback);
115 
startLockTaskModeByToken(in IBinder token)116     oneway void startLockTaskModeByToken(in IBinder token);
stopLockTaskModeByToken(in IBinder token)117     oneway void stopLockTaskModeByToken(in IBinder token);
showLockTaskEscapeMessage(in IBinder token)118     oneway void showLockTaskEscapeMessage(in IBinder token);
setTaskDescription(in IBinder token, in ActivityManager.TaskDescription values)119     void setTaskDescription(in IBinder token, in ActivityManager.TaskDescription values);
120 
showAssistFromActivity(in IBinder token, in Bundle args)121     boolean showAssistFromActivity(in IBinder token, in Bundle args);
isRootVoiceInteraction(in IBinder token)122     boolean isRootVoiceInteraction(in IBinder token);
startLocalVoiceInteraction(in IBinder token, in Bundle options)123     void startLocalVoiceInteraction(in IBinder token, in Bundle options);
stopLocalVoiceInteraction(in IBinder token)124     void stopLocalVoiceInteraction(in IBinder token);
125 
setShowWhenLocked(in IBinder token, boolean showWhenLocked)126     oneway void setShowWhenLocked(in IBinder token, boolean showWhenLocked);
setInheritShowWhenLocked(in IBinder token, boolean setInheritShownWhenLocked)127     oneway void setInheritShowWhenLocked(in IBinder token, boolean setInheritShownWhenLocked);
setTurnScreenOn(in IBinder token, boolean turnScreenOn)128     void setTurnScreenOn(in IBinder token, boolean turnScreenOn);
setAllowCrossUidActivitySwitchFromBelow(in IBinder token, boolean allowed)129     oneway void setAllowCrossUidActivitySwitchFromBelow(in IBinder token, boolean allowed);
reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle)130     oneway void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle);
overrideActivityTransition(IBinder token, boolean open, int enterAnim, int exitAnim, int backgroundColor)131     oneway void overrideActivityTransition(IBinder token, boolean open, int enterAnim, int exitAnim,
132             int backgroundColor);
clearOverrideActivityTransition(IBinder token, boolean open)133     oneway void clearOverrideActivityTransition(IBinder token, boolean open);
134     /**
135      * Overrides the animation of activity pending transition. This call is not one-way because
136      * the method is usually used after startActivity or Activity#finish. If this is non-blocking,
137      * the calling activity may proceed to complete pause and become stopping state, which will
138      * cause the request to be ignored. Besides, startActivity and Activity#finish are blocking
139      * calls, so this method should be the same as them to keep the invocation order.
140      */
overridePendingTransition(in IBinder token, in String packageName, int enterAnim, int exitAnim, int backgroundColor)141     void overridePendingTransition(in IBinder token, in String packageName,
142             int enterAnim, int exitAnim, int backgroundColor);
setVrMode(in IBinder token, boolean enabled, in ComponentName packageName)143     int setVrMode(in IBinder token, boolean enabled, in ComponentName packageName);
144 
145     /** See {@link android.app.Activity#setRecentsScreenshotEnabled}. */
setRecentsScreenshotEnabled(in IBinder token, boolean enabled)146     oneway void setRecentsScreenshotEnabled(in IBinder token, boolean enabled);
147 
148     /**
149      * It should only be called from home activity to remove its outdated snapshot. The home
150      * snapshot is used to speed up entering home from screen off. If the content of home activity
151      * is significantly different from before taking the snapshot, then the home activity can use
152      * this method to avoid inconsistent transition.
153      */
invalidateHomeTaskSnapshot(IBinder homeToken)154     void invalidateHomeTaskSnapshot(IBinder homeToken);
155 
dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback, in CharSequence message)156     void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback,
157             in CharSequence message);
158 
159     /** Registers remote animations for a specific activity. */
registerRemoteAnimations(in IBinder token, in RemoteAnimationDefinition definition)160     void registerRemoteAnimations(in IBinder token, in RemoteAnimationDefinition definition);
161 
162     /** Unregisters all remote animations for a specific activity. */
unregisterRemoteAnimations(in IBinder token)163     void unregisterRemoteAnimations(in IBinder token);
164 
165     /**
166      * Reports that an Activity received a back key press.
167      */
onBackPressed(in IBinder activityToken, in IRequestFinishCallback callback)168     oneway void onBackPressed(in IBinder activityToken,
169             in IRequestFinishCallback callback);
170 
171     /** Reports that the splash screen view has attached to activity.  */
splashScreenAttached(in IBinder token)172     oneway void splashScreenAttached(in IBinder token);
173 
174     /**
175      * Shows or hides a Camera app compat toggle for stretched issues with the requested state.
176      *
177      * @param token The token for the window that needs a control.
178      * @param showControl Whether the control should be shown or hidden.
179      * @param transformationApplied Whether the treatment is already applied.
180      * @param callback The callback executed when the user clicks on a control.
181      */
requestCompatCameraControl(in IBinder token, boolean showControl, boolean transformationApplied, in ICompatCameraControlCallback callback)182     oneway void requestCompatCameraControl(in IBinder token, boolean showControl,
183             boolean transformationApplied, in ICompatCameraControlCallback callback);
184 
185     /**
186      * If set, any activity launch in the same task will be overridden to the locale of activity
187      * that started the task.
188      */
enableTaskLocaleOverride(in IBinder token)189     void enableTaskLocaleOverride(in IBinder token);
190 
191     /**
192      * Return {@code true} if the activity was explicitly requested to be launched in the
193      * TaskFragment.
194      *
195      * @param activityToken The token of the Activity.
196      * @param taskFragmentToken The token of the TaskFragment.
197      */
isRequestedToLaunchInTaskFragment(in IBinder activityToken, in IBinder taskFragmentToken)198     boolean isRequestedToLaunchInTaskFragment(in IBinder activityToken,
199             in IBinder taskFragmentToken);
200 
201     /**
202      * Enable or disable ActivityRecordInputSink to block input events.
203      *
204      * @param token The token for the activity that requests to toggle.
205      * @param enabled Whether the input evens are blocked by ActivityRecordInputSink.
206      */
207     @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest"
208             + ".permission.INTERNAL_SYSTEM_WINDOW)")
setActivityRecordInputSinkEnabled(in IBinder activityToken, boolean enabled)209     oneway void setActivityRecordInputSinkEnabled(in IBinder activityToken, boolean enabled);
210 }
211