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.content.ComponentName;
21import android.content.IIntentSender;
22import android.os.IBinder;
23import android.service.voice.IVoiceInteractionSession;
24
25import com.android.internal.app.IVoiceInteractor;
26
27import java.util.List;
28
29/**
30 * Activity manager local system service interface.
31 *
32 * @hide Only for use within the system server.
33 */
34public abstract class ActivityManagerInternal {
35
36    /**
37     * Type for {@link #notifyAppTransitionStarting}: The transition was started because we had
38     * the surface saved.
39     */
40    public static final int APP_TRANSITION_SAVED_SURFACE = 0;
41
42    /**
43     * Type for {@link #notifyAppTransitionStarting}: The transition was started because we drew
44     * the starting window.
45     */
46    public static final int APP_TRANSITION_STARTING_WINDOW = 1;
47
48    /**
49     * Type for {@link #notifyAppTransitionStarting}: The transition was started because we all
50     * app windows were drawn
51     */
52    public static final int APP_TRANSITION_WINDOWS_DRAWN = 2;
53
54    /**
55     * Type for {@link #notifyAppTransitionStarting}: The transition was started because of a
56     * timeout.
57     */
58    public static final int APP_TRANSITION_TIMEOUT = 3;
59
60    // Called by the power manager.
61    public abstract void onWakefulnessChanged(int wakefulness);
62
63    public abstract int startIsolatedProcess(String entryPoint, String[] mainArgs,
64            String processName, String abiOverride, int uid, Runnable crashHandler);
65
66    /**
67     * Acquires a sleep token with the specified tag.
68     *
69     * @param tag A string identifying the purpose of the token (eg. "Dream").
70     */
71    public abstract SleepToken acquireSleepToken(@NonNull String tag);
72
73    /**
74     * Sleep tokens cause the activity manager to put the top activity to sleep.
75     * They are used by components such as dreams that may hide and block interaction
76     * with underlying activities.
77     */
78    public static abstract class SleepToken {
79
80        /**
81         * Releases the sleep token.
82         */
83        public abstract void release();
84    }
85
86    /**
87     * Returns home activity for the specified user.
88     *
89     * @param userId ID of the user or {@link android.os.UserHandle#USER_ALL}
90     */
91    public abstract ComponentName getHomeActivityForUser(int userId);
92
93    /**
94     * Called when a user has been deleted. This can happen during normal device usage
95     * or just at startup, when partially removed users are purged. Any state persisted by the
96     * ActivityManager should be purged now.
97     *
98     * @param userId The user being cleaned up.
99     */
100    public abstract void onUserRemoved(int userId);
101
102    public abstract void onLocalVoiceInteractionStarted(IBinder callingActivity,
103            IVoiceInteractionSession mSession,
104            IVoiceInteractor mInteractor);
105
106    /**
107     * Callback for window manager to let activity manager know that the starting window has been
108     * drawn
109     */
110    public abstract void notifyStartingWindowDrawn();
111
112    /**
113     * Callback for window manager to let activity manager know that we are finally starting the
114     * app transition;
115     *
116     * @param reason The reason why the app transition started. Must be one of the APP_TRANSITION_*
117     *               values.
118     */
119    public abstract void notifyAppTransitionStarting(int reason);
120
121    /**
122     * Callback for window manager to let activity manager know that the app transition was
123     * cancelled.
124     */
125    public abstract void notifyAppTransitionCancelled();
126
127    /**
128     * Callback for window manager to let activity manager know that the app transition is finished.
129     */
130    public abstract void notifyAppTransitionFinished();
131
132    /**
133     * Returns the top activity from each of the currently visible stacks. The first entry will be
134     * the focused activity.
135     */
136    public abstract List<IBinder> getTopVisibleActivities();
137
138    /**
139     * Callback for window manager to let activity manager know that docked stack changes its
140     * minimized state.
141     */
142    public abstract void notifyDockedStackMinimizedChanged(boolean minimized);
143
144    /**
145     * Kill foreground apps from the specified user.
146     */
147    public abstract void killForegroundAppsForUser(int userHandle);
148
149    /**
150     *  Sets how long a {@link PendingIntent} can be temporarily whitelist to by bypass restrictions
151     *  such as Power Save mode.
152     */
153    public abstract void setPendingIntentWhitelistDuration(IIntentSender target, long duration);
154}
155