ActivityManagerInternal.java revision c9d9407e8ec10a56a4caa3c84122d1c6a1fedaab
1/*
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
19import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.content.ComponentName;
22import android.content.IIntentSender;
23import android.content.Intent;
24import android.content.res.Configuration;
25import android.os.Bundle;
26import android.os.IBinder;
27import android.service.voice.IVoiceInteractionSession;
28
29import com.android.internal.app.IVoiceInteractor;
30
31import java.io.PrintWriter;
32import java.util.ArrayList;
33import java.util.List;
34
35/**
36 * Activity manager local system service interface.
37 *
38 * @hide Only for use within the system server.
39 */
40public abstract class ActivityManagerInternal {
41
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
50     * the starting window.
51     */
52    public static final int APP_TRANSITION_STARTING_WINDOW = 1;
53
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
66    /**
67     * Grant Uri permissions from one app to another. This method only extends
68     * permission grants if {@code callingUid} has permission to them.
69     */
70    public abstract void grantUriPermissionFromIntent(int callingUid, String targetPkg,
71            Intent intent, int targetUserId);
72
73    /**
74     * Verify that calling app has access to the given provider.
75     */
76    public abstract String checkContentProviderAccess(String authority, int userId);
77
78    // Called by the power manager.
79    public abstract void onWakefulnessChanged(int wakefulness);
80
81    public abstract int startIsolatedProcess(String entryPoint, String[] mainArgs,
82            String processName, String abiOverride, int uid, Runnable crashHandler);
83
84    /**
85     * Acquires a sleep token with the specified tag.
86     *
87     * @param tag A string identifying the purpose of the token (eg. "Dream").
88     */
89    public abstract SleepToken acquireSleepToken(@NonNull String tag);
90
91    /**
92     * Sleep tokens cause the activity manager to put the top activity to sleep.
93     * They are used by components such as dreams that may hide and block interaction
94     * with underlying activities.
95     */
96    public static abstract class SleepToken {
97
98        /**
99         * Releases the sleep token.
100         */
101        public abstract void release();
102    }
103
104    /**
105     * Returns home activity for the specified user.
106     *
107     * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
108     */
109    public abstract ComponentName getHomeActivityForUser(int userId);
110
111    /**
112     * Called when a user has been deleted. This can happen during normal device usage
113     * or just at startup, when partially removed users are purged. Any state persisted by the
114     * ActivityManager should be purged now.
115     *
116     * @param userId The user being cleaned up.
117     */
118    public abstract void onUserRemoved(int userId);
119
120    public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
121            IVoiceInteractionSession mSession,
122            IVoiceInteractor mInteractor);
123
124    /**
125     * Callback for window manager to let activity manager know that the starting window has been
126     * drawn
127     */
128    public abstract void notifyStartingWindowDrawn();
129
130    /**
131     * Callback for window manager to let activity manager know that we are finally starting the
132     * app transition;
133     *
134     * @param reason The reason why the app transition started. Must be one of the APP_TRANSITION_*
135     *               values.
136     */
137    public abstract void notifyAppTransitionStarting(int reason);
138
139    /**
140     * Callback for window manager to let activity manager know that the app transition was
141     * cancelled.
142     */
143    public abstract void notifyAppTransitionCancelled();
144
145    /**
146     * Callback for window manager to let activity manager know that the app transition is finished.
147     */
148    public abstract void notifyAppTransitionFinished();
149
150    /**
151     * Returns the top activity from each of the currently visible stacks. The first entry will be
152     * the focused activity.
153     */
154    public abstract List<IBinder> getTopVisibleActivities();
155
156    /**
157     * Callback for window manager to let activity manager know that docked stack changes its
158     * minimized state.
159     */
160    public abstract void notifyDockedStackMinimizedChanged(boolean minimized);
161
162    /**
163     * Kill foreground apps from the specified user.
164     */
165    public abstract void killForegroundAppsForUser(int userHandle);
166
167    /**
168     *  Sets how long a {@link PendingIntent} can be temporarily whitelist to by bypass restrictions
169     *  such as Power Save mode.
170     */
171    public abstract void setPendingIntentWhitelistDuration(IIntentSender target, long duration);
172
173    /**
174     * Allow DeviceIdleController to tell us about what apps are whitelisted.
175     */
176    public abstract void setDeviceIdleWhitelist(int[] appids);
177
178    /**
179     * Update information about which app IDs are on the temp whitelist.
180     */
181    public abstract void updateDeviceIdleTempWhitelist(int[] appids, int changingAppId,
182            boolean adding);
183
184    /**
185     * Updates and persists the {@link Configuration} for a given user.
186     *
187     * @param values the configuration to update
188     * @param userId the user to update the configuration for
189     */
190    public abstract void updatePersistentConfigurationForUser(@NonNull Configuration values,
191            int userId);
192
193    /**
194     * Start activity {@code intents} as if {@code packageName} on user {@code userId} did it.
195     *
196     * @return error codes used by {@link IActivityManager#startActivity} and its siblings.
197     */
198    public abstract int startActivitiesAsPackage(String packageName,
199            int userId, Intent[] intents, Bundle bOptions);
200
201    /**
202     * Get the procstate for the UID.  The return value will be between
203     * {@link ActivityManager#MIN_PROCESS_STATE} and {@link ActivityManager#MAX_PROCESS_STATE}.
204     * Note if the UID doesn't exist, it'll return {@link ActivityManager#PROCESS_STATE_NONEXISTENT}
205     * (-1).
206     */
207    public abstract int getUidProcessState(int uid);
208
209    /**
210     * Called when Keyguard flags might have changed.
211     *
212     * @param callback Callback to run after activity visibilities have been reevaluated. This can
213     *                 be used from window manager so that when the callback is called, it's
214     *                 guaranteed that all apps have their visibility updated accordingly.
215     */
216    public abstract void notifyKeyguardFlagsChanged(@Nullable Runnable callback);
217
218    /**
219     * @return {@code true} if system is ready, {@code false} otherwise.
220     */
221    public abstract boolean isSystemReady();
222
223    /**
224     * Called when the trusted state of Keyguard has changed.
225     */
226    public abstract void notifyKeyguardTrustedChanged();
227
228    /**
229     * Sets if the given pid has an overlay UI or not.
230     *
231     * @param pid The pid we are setting overlay UI for.
232     * @param hasOverlayUi True if the process has overlay UI.
233     * @see android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY
234     */
235    public abstract void setHasOverlayUi(int pid, boolean hasOverlayUi);
236}
237