2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.ComponentName;
22 import android.content.IIntentSender;
23 import android.content.Intent;
24 import android.content.res.Configuration;
25 import android.os.Bundle;
26 import android.os.IBinder;
27 import android.os.SystemClock;
28 import android.service.voice.IVoiceInteractionSession;
29 import android.util.SparseIntArray;
31 import com.android.internal.app.IVoiceInteractor;
33 import java.util.List;
36 * Activity manager local system service interface.
38 * @hide Only for use within the system server.
40 public abstract class ActivityManagerInternal {
43 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we had
46 public static final int APP_TRANSITION_SAVED_SURFACE = 0;
49 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we drew
52 public static final int APP_TRANSITION_SPLASH_SCREEN = 1;
55 * Type for {@link #notifyAppTransitionStarting}: The transition was started because we all
56 * app windows were drawn
58 public static final int APP_TRANSITION_WINDOWS_DRAWN = 2;
61 * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
64 public static final int APP_TRANSITION_TIMEOUT = 3;
67 * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
68 * we drew a task snapshot.
70 public static final int APP_TRANSITION_SNAPSHOT = 4;
73 * Grant Uri permissions from one app to another. This method only extends
74 * permission grants if {@code callingUid} has permission to them.
76 public abstract void grantUriPermissionFromIntent(int callingUid, String targetPkg,
77 Intent intent, int targetUserId);
80 * Verify that calling app has access to the given provider.
82 public abstract String checkContentProviderAccess(String authority, int userId);
84 // Called by the power manager.
85 public abstract void onWakefulnessChanged(int wakefulness);
87 public abstract int startIsolatedProcess(String entryPoint, String[] mainArgs,
88 String processName, String abiOverride, int uid, Runnable crashHandler);
91 * Acquires a sleep token for the specified display with the specified tag.
93 * @param tag A string identifying the purpose of the token (eg. "Dream").
94 * @param displayId The display to apply the sleep token to.
96 public abstract SleepToken acquireSleepToken(@NonNull String tag, int displayId);
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.
103 public static abstract class SleepToken {
106 * Releases the sleep token.
108 public abstract void release();
112 * Returns home activity for the specified user.
114 * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
116 public abstract ComponentName getHomeActivityForUser(int userId);
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.
123 * @param userId The user being cleaned up.
125 public abstract void onUserRemoved(int userId);
127 public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
128 IVoiceInteractionSession mSession,
129 IVoiceInteractor mInteractor);
132 * Callback for window manager to let activity manager know that we are finally starting the
135 * @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.
137 * @param timestamp The time at which the app transition started in
138 * {@link SystemClock#uptimeMillis()} timebase.
140 public abstract void notifyAppTransitionStarting(SparseIntArray reasons, long timestamp);
143 * Callback for window manager to let activity manager know that the app transition was
146 public abstract void notifyAppTransitionCancelled();
149 * Callback for window manager to let activity manager know that the app transition is finished.
151 public abstract void notifyAppTransitionFinished();
154 * Returns the top activity from each of the currently visible stacks. The first entry will be
155 * the focused activity.
157 public abstract List<IBinder> getTopVisibleActivities();
160 * Callback for window manager to let activity manager know that docked stack changes its
163 public abstract void notifyDockedStackMinimizedChanged(boolean minimized);
166 * Kill foreground apps from the specified user.
168 public abstract void killForegroundAppsForUser(int userHandle);
171 * Sets how long a {@link PendingIntent} can be temporarily whitelist to by bypass restrictions
172 * such as Power Save mode.
174 public abstract void setPendingIntentWhitelistDuration(IIntentSender target,
175 IBinder whitelistToken, long duration);
178 * Allow DeviceIdleController to tell us about what apps are whitelisted.
180 public abstract void setDeviceIdleWhitelist(int[] appids);
183 * Update information about which app IDs are on the temp whitelist.
185 public abstract void updateDeviceIdleTempWhitelist(int[] appids, int changingAppId,
189 * Updates and persists the {@link Configuration} for a given user.
191 * @param values the configuration to update
192 * @param userId the user to update the configuration for
194 public abstract void updatePersistentConfigurationForUser(@NonNull Configuration values,
198 * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it.
200 * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
202 public abstract int startActivitiesAsPackage(String packageName,
203 int userId, Intent[] intents, Bundle bOptions);
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}
211 public abstract int getUidProcessState(int uid);
214 * Called when Keyguard flags might have changed.
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.
220 public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback);
223 * @return {@code true} if system is ready, {@code false} otherwise.
225 public abstract boolean isSystemReady();
228 * Called when the trusted state of Keyguard has changed.
230 public abstract void notifyKeyguardTrustedChanged();
233 * Sets if the given pid has an overlay UI or not.
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
239 public abstract void setHasOverlayUi(int pid, boolean hasOverlayUi);
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}.
246 public abstract void notifyNetworkPolicyRulesUpdated(int uid, long procStateSeq);
249 * Called after virtual display Id is updated by
250 * {@link com.android.server.vr.Vr2dDisplay} with a specific
251 * {@param vr2dDisplayId}.
253 public abstract void setVr2dDisplayId(int vr2dDisplayId);
256 * Saves the current activity manager state and includes the saved state in the next dump of
259 public abstract void saveANRState(String reason);
262 * Clears the previously saved activity manager ANR state.
264 public abstract void clearSavedANRState();
267 * Set focus on an activity.
268 * @param token The IApplicationToken for the activity
270 public abstract void setFocusedActivity(IBinder token);
273 * Returns {@code true} if {@code uid} is running an activity from {@code packageName}.
275 public abstract boolean hasRunningActivity(int uid, @Nullable String packageName);