blob: c8d983933fc6d216fc0bd7b3309b3849d4a8aed9 [file] [log] [blame]
Jeff Brown13014b52014-04-07 19:45:27 -07001/*
2 * Copyright (C) 2014 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
17package android.app;
18
Jeff Brown061ea992015-04-17 19:55:47 -070019import android.annotation.NonNull;
Jorim Jaggife762342016-10-13 14:33:27 +020020import android.annotation.Nullable;
Fyodor Kupolovb5013302015-04-17 17:59:14 -070021import android.content.ComponentName;
Felipe Lemea1b79bf2016-05-24 13:06:54 -070022import android.content.IIntentSender;
Makoto Onukiea11db12016-06-24 15:17:44 -070023import android.content.Intent;
Suprabh Shukla64725012016-06-15 13:19:28 -070024import android.content.res.Configuration;
Makoto Onukiea11db12016-06-24 15:17:44 -070025import android.os.Bundle;
Amith Yamasani0af6fa72016-01-17 15:36:19 -080026import android.os.IBinder;
Sudheer Shankac766db02017-06-12 10:37:29 -070027import android.os.SystemClock;
Amith Yamasani0af6fa72016-01-17 15:36:19 -080028import android.service.voice.IVoiceInteractionSession;
Jorim Jaggi3878ca32017-02-02 17:13:05 -080029import android.util.SparseIntArray;
Amith Yamasani0af6fa72016-01-17 15:36:19 -080030
31import com.android.internal.app.IVoiceInteractor;
Jeff Brown061ea992015-04-17 19:55:47 -070032
Amith Yamasanie8222e52016-04-08 15:28:47 -070033import java.util.List;
34
Jeff Brown13014b52014-04-07 19:45:27 -070035/**
36 * Activity manager local system service interface.
37 *
38 * @hide Only for use within the system server.
39 */
40public abstract class ActivityManagerInternal {
Jorim Jaggi275561a2016-02-23 10:11:02 -050041
42 /**
43 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we had
44 * the surface saved.
45 */
46 public static final int APP_TRANSITION_SAVED_SURFACE = 0;
47
48 /**
49 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we drew
Jorim Jaggi3878ca32017-02-02 17:13:05 -080050 * the splash screen.
Jorim Jaggi275561a2016-02-23 10:11:02 -050051 */
Jorim Jaggi3878ca32017-02-02 17:13:05 -080052 public static final int APP_TRANSITION_SPLASH_SCREEN = 1;
Jorim Jaggi275561a2016-02-23 10:11:02 -050053
54 /**
55 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we all
56 * app windows were drawn
57 */
58 public static final int APP_TRANSITION_WINDOWS_DRAWN = 2;
59
60 /**
61 * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
62 * timeout.
63 */
64 public static final int APP_TRANSITION_TIMEOUT = 3;
65
Jeff Sharkey923e0b82016-11-16 17:22:48 -070066 /**
Jorim Jaggi3878ca32017-02-02 17:13:05 -080067 * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
68 * we drew a task snapshot.
69 */
70 public static final int APP_TRANSITION_SNAPSHOT = 4;
71
72 /**
Jeff Sharkey7ff418d2016-11-30 14:29:59 -070073 * Grant Uri permissions from one app to another. This method only extends
74 * permission grants if {@code callingUid} has permission to them.
75 */
76 public abstract void grantUriPermissionFromIntent(int callingUid, String targetPkg,
77 Intent intent, int targetUserId);
78
79 /**
Jeff Sharkey923e0b82016-11-16 17:22:48 -070080 * Verify that calling app has access to the given provider.
81 */
82 public abstract String checkContentProviderAccess(String authority, int userId);
83
Jeff Brown13014b52014-04-07 19:45:27 -070084 // Called by the power manager.
Jeff Brownfbe96702014-11-19 18:30:58 -080085 public abstract void onWakefulnessChanged(int wakefulness);
86
Primiano Tucci810c0522014-07-25 18:03:16 +010087 public abstract int startIsolatedProcess(String entryPoint, String[] mainArgs,
88 String processName, String abiOverride, int uid, Runnable crashHandler);
Jeff Brown061ea992015-04-17 19:55:47 -070089
90 /**
David Stevensf62360c2017-03-16 19:00:20 -070091 * Acquires a sleep token for the specified display with the specified tag.
Jeff Brown061ea992015-04-17 19:55:47 -070092 *
93 * @param tag A string identifying the purpose of the token (eg. "Dream").
David Stevensf62360c2017-03-16 19:00:20 -070094 * @param displayId The display to apply the sleep token to.
Jeff Brown061ea992015-04-17 19:55:47 -070095 */
David Stevensf62360c2017-03-16 19:00:20 -070096 public abstract SleepToken acquireSleepToken(@NonNull String tag, int displayId);
Jeff Brown061ea992015-04-17 19:55:47 -070097
98 /**
99 * Sleep tokens cause the activity manager to put the top activity to sleep.
100 * They are used by components such as dreams that may hide and block interaction
101 * with underlying activities.
102 */
103 public static abstract class SleepToken {
Jorim Jaggi275561a2016-02-23 10:11:02 -0500104
Jeff Brown061ea992015-04-17 19:55:47 -0700105 /**
106 * Releases the sleep token.
107 */
108 public abstract void release();
109 }
Fyodor Kupolovb5013302015-04-17 17:59:14 -0700110
111 /**
112 * Returns home activity for the specified user.
Jorim Jaggi275561a2016-02-23 10:11:02 -0500113 *
Fyodor Kupolovb5013302015-04-17 17:59:14 -0700114 * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
115 */
116 public abstract ComponentName getHomeActivityForUser(int userId);
Amith Yamasani515d4062015-09-28 11:30:06 -0700117
118 /**
119 * Called when a user has been deleted. This can happen during normal device usage
120 * or just at startup, when partially removed users are purged. Any state persisted by the
121 * ActivityManager should be purged now.
122 *
123 * @param userId The user being cleaned up.
124 */
125 public abstract void onUserRemoved(int userId);
Amith Yamasani0af6fa72016-01-17 15:36:19 -0800126
127 public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
128 IVoiceInteractionSession mSession,
129 IVoiceInteractor mInteractor);
Jorim Jaggi275561a2016-02-23 10:11:02 -0500130
131 /**
Jorim Jaggi275561a2016-02-23 10:11:02 -0500132 * Callback for window manager to let activity manager know that we are finally starting the
133 * app transition;
134 *
Jorim Jaggi3878ca32017-02-02 17:13:05 -0800135 * @param reasons A map from stack id to a reason integer why the transition was started,, which
136 * must be one of the APP_TRANSITION_* values.
Sudheer Shankac766db02017-06-12 10:37:29 -0700137 * @param timestamp The time at which the app transition started in
138 * {@link SystemClock#uptimeMillis()} timebase.
Jorim Jaggi275561a2016-02-23 10:11:02 -0500139 */
Sudheer Shankac766db02017-06-12 10:37:29 -0700140 public abstract void notifyAppTransitionStarting(SparseIntArray reasons, long timestamp);
Jorim Jaggi192086e2016-03-11 17:17:03 +0100141
142 /**
143 * Callback for window manager to let activity manager know that the app transition was
144 * cancelled.
145 */
146 public abstract void notifyAppTransitionCancelled();
147
148 /**
149 * Callback for window manager to let activity manager know that the app transition is finished.
150 */
151 public abstract void notifyAppTransitionFinished();
Amith Yamasanie8222e52016-04-08 15:28:47 -0700152
153 /**
154 * Returns the top activity from each of the currently visible stacks. The first entry will be
155 * the focused activity.
156 */
157 public abstract List<IBinder> getTopVisibleActivities();
Tony Mak853304c2016-04-18 15:17:41 +0100158
159 /**
160 * Callback for window manager to let activity manager know that docked stack changes its
161 * minimized state.
162 */
163 public abstract void notifyDockedStackMinimizedChanged(boolean minimized);
Rubin Xuf8451b92016-04-01 15:50:58 +0100164
165 /**
166 * Kill foreground apps from the specified user.
167 */
168 public abstract void killForegroundAppsForUser(int userHandle);
Felipe Lemea1b79bf2016-05-24 13:06:54 -0700169
170 /**
171 * Sets how long a {@link PendingIntent} can be temporarily whitelist to by bypass restrictions
172 * such as Power Save mode.
173 */
Dianne Hackborn98305522017-05-05 17:53:53 -0700174 public abstract void setPendingIntentWhitelistDuration(IIntentSender target,
175 IBinder whitelistToken, long duration);
Suprabh Shukla64725012016-06-15 13:19:28 -0700176
177 /**
Dianne Hackborn85e35642017-01-12 15:10:57 -0800178 * Allow DeviceIdleController to tell us about what apps are whitelisted.
179 */
180 public abstract void setDeviceIdleWhitelist(int[] appids);
181
182 /**
183 * Update information about which app IDs are on the temp whitelist.
184 */
185 public abstract void updateDeviceIdleTempWhitelist(int[] appids, int changingAppId,
186 boolean adding);
187
188 /**
Suprabh Shukla64725012016-06-15 13:19:28 -0700189 * Updates and persists the {@link Configuration} for a given user.
190 *
191 * @param values the configuration to update
192 * @param userId the user to update the configuration for
193 */
194 public abstract void updatePersistentConfigurationForUser(@NonNull Configuration values,
195 int userId);
Makoto Onukiea11db12016-06-24 15:17:44 -0700196
197 /**
Makoto Onuki440a1ea2016-07-20 14:21:18 -0700198 * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it.
Makoto Onuki83f6d2d2016-07-11 14:30:19 -0700199 *
200 * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
Makoto Onukiea11db12016-06-24 15:17:44 -0700201 */
Makoto Onuki440a1ea2016-07-20 14:21:18 -0700202 public abstract int startActivitiesAsPackage(String packageName,
203 int userId, Intent[] intents, Bundle bOptions);
Makoto Onuki33525d22016-08-03 15:45:24 -0700204
205 /**
206 * Get the procstate for the UID. The return value will be between
207 * {@link ActivityManager#MIN_PROCESS_STATE} and {@link ActivityManager#MAX_PROCESS_STATE}.
208 * Note if the UID doesn't exist, it'll return {@link ActivityManager#PROCESS_STATE_NONEXISTENT}
209 * (-1).
210 */
211 public abstract int getUidProcessState(int uid);
Jorim Jaggife762342016-10-13 14:33:27 +0200212
213 /**
214 * Called when Keyguard flags might have changed.
215 *
216 * @param callback Callback to run after activity visibilities have been reevaluated. This can
217 * be used from window manager so that when the callback is called, it's
218 * guaranteed that all apps have their visibility updated accordingly.
219 */
220 public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback);
Sudheer Shankafc46e9b2016-10-21 17:55:27 -0700221
222 /**
223 * @return {@code true} if system is ready, {@code false} otherwise.
224 */
225 public abstract boolean isSystemReady();
Jorim Jaggie69c9312016-10-31 18:24:38 -0700226
227 /**
228 * Called when the trusted state of Keyguard has changed.
229 */
230 public abstract void notifyKeyguardTrustedChanged();
Wale Ogunwaled993a572017-02-05 13:52:09 -0800231
232 /**
233 * Sets if the given pid has an overlay UI or not.
234 *
235 * @param pid The pid we are setting overlay UI for.
236 * @param hasOverlayUi True if the process has overlay UI.
237 * @see android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY
238 */
239 public abstract void setHasOverlayUi(int pid, boolean hasOverlayUi);
Sudheer Shankae7361852017-03-07 11:51:46 -0800240
241 /**
242 * Called after the network policy rules are updated by
243 * {@link com.android.server.net.NetworkPolicyManagerService} for a specific {@param uid} and
244 * {@param procStateSeq}.
245 */
246 public abstract void notifyNetworkPolicyRulesUpdated(int uid, long procStateSeq);
Karthik Ravi Shankar99493db2017-03-08 18:30:19 -0800247
248 /**
249 * Called after virtual display Id is updated by
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -0700250 * {@link com.android.server.vr.Vr2dDisplay} with a specific
251 * {@param vr2dDisplayId}.
Karthik Ravi Shankar99493db2017-03-08 18:30:19 -0800252 */
Karthik Ravi Shankar2b9aaed2017-05-01 01:34:19 -0700253 public abstract void setVr2dDisplayId(int vr2dDisplayId);
Wale Ogunwalef1285912017-06-09 15:20:29 -0700254
255 /**
256 * Saves the current activity manager state and includes the saved state in the next dump of
257 * activity manager.
258 */
259 public abstract void saveANRState(String reason);
260
261 /**
262 * Clears the previously saved activity manager ANR state.
263 */
264 public abstract void clearSavedANRState();
Phil Weaver5dc3ebc2017-08-16 13:04:20 -0700265
266 /**
267 * Set focus on an activity.
268 * @param token The IApplicationToken for the activity
269 */
270 public abstract void setFocusedActivity(IBinder token);
Jeff Brown13014b52014-04-07 19:45:27 -0700271}