IActivityManager.java revision 55280a91884b9256e8db6af6a09f28b3feeaa9d8
1/*
2 * Copyright (C) 2006 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.content.ComponentName;
20import android.content.ContentProviderNative;
21import android.content.IContentProvider;
22import android.content.Intent;
23import android.content.IntentFilter;
24import android.content.pm.ConfigurationInfo;
25import android.content.pm.IPackageDataObserver;
26import android.content.pm.ProviderInfo;
27import android.content.res.Configuration;
28import android.graphics.Bitmap;
29import android.net.Uri;
30import android.os.RemoteException;
31import android.os.IBinder;
32import android.os.IInterface;
33import android.os.Parcel;
34import android.os.Parcelable;
35import android.os.ParcelFileDescriptor;
36import android.os.Bundle;
37
38import java.util.List;
39
40/**
41 * System private API for talking with the activity manager service.  This
42 * provides calls from the application back to the activity manager.
43 *
44 * {@hide}
45 */
46public interface IActivityManager extends IInterface {
47    public static final int START_DELIVERED_TO_TOP = 3;
48    public static final int START_TASK_TO_FRONT = 2;
49    public static final int START_RETURN_INTENT_TO_CALLER = 1;
50    public static final int START_SUCCESS = 0;
51    public static final int START_INTENT_NOT_RESOLVED = -1;
52    public static final int START_CLASS_NOT_FOUND = -2;
53    public static final int START_FORWARD_AND_REQUEST_CONFLICT = -3;
54    public static final int START_PERMISSION_DENIED = -4;
55    public int startActivity(IApplicationThread caller,
56            Intent intent, String resolvedType, Uri[] grantedUriPermissions,
57            int grantedMode, IBinder resultTo, String resultWho, int requestCode,
58            boolean onlyIfNeeded, boolean debug) throws RemoteException;
59    public boolean startNextMatchingActivity(IBinder callingActivity,
60            Intent intent) throws RemoteException;
61    public boolean finishActivity(IBinder token, int code, Intent data)
62            throws RemoteException;
63    public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException;
64    public Intent registerReceiver(IApplicationThread caller,
65            IIntentReceiver receiver, IntentFilter filter,
66            String requiredPermission) throws RemoteException;
67    public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException;
68    public static final int BROADCAST_SUCCESS = 0;
69    public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION = -1;
70    public int broadcastIntent(IApplicationThread caller, Intent intent,
71            String resolvedType, IIntentReceiver resultTo, int resultCode,
72            String resultData, Bundle map, String requiredPermission,
73            boolean serialized, boolean sticky) throws RemoteException;
74    public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException;
75    /* oneway */
76    public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException;
77    public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException;
78    public void attachApplication(IApplicationThread app) throws RemoteException;
79    /* oneway */
80    public void activityIdle(IBinder token) throws RemoteException;
81    public void activityPaused(IBinder token, Bundle state) throws RemoteException;
82    /* oneway */
83    public void activityStopped(IBinder token,
84                                Bitmap thumbnail, CharSequence description) throws RemoteException;
85    /* oneway */
86    public void activityDestroyed(IBinder token) throws RemoteException;
87    public String getCallingPackage(IBinder token) throws RemoteException;
88    public ComponentName getCallingActivity(IBinder token) throws RemoteException;
89    public List getTasks(int maxNum, int flags,
90                         IThumbnailReceiver receiver) throws RemoteException;
91    public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
92            int flags) throws RemoteException;
93    public List getServices(int maxNum, int flags) throws RemoteException;
94    public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
95            throws RemoteException;
96    public void moveTaskToFront(int task) throws RemoteException;
97    public void moveTaskToBack(int task) throws RemoteException;
98    public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) throws RemoteException;
99    public void moveTaskBackwards(int task) throws RemoteException;
100    public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
101    public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException;
102    /* oneway */
103    public void reportThumbnail(IBinder token,
104                                Bitmap thumbnail, CharSequence description) throws RemoteException;
105    public ContentProviderHolder getContentProvider(IApplicationThread caller,
106                                                    String name) throws RemoteException;
107    public void removeContentProvider(IApplicationThread caller,
108        String name) throws RemoteException;
109    public void publishContentProviders(IApplicationThread caller,
110                                        List<ContentProviderHolder> providers) throws RemoteException;
111    public ComponentName startService(IApplicationThread caller, Intent service,
112            String resolvedType) throws RemoteException;
113    public int stopService(IApplicationThread caller, Intent service,
114            String resolvedType) throws RemoteException;
115    public boolean stopServiceToken(ComponentName className, IBinder token,
116            int startId) throws RemoteException;
117    public void setServiceForeground(ComponentName className, IBinder token,
118            boolean isForeground) throws RemoteException;
119    public int bindService(IApplicationThread caller, IBinder token,
120            Intent service, String resolvedType,
121            IServiceConnection connection, int flags) throws RemoteException;
122    public boolean unbindService(IServiceConnection connection) throws RemoteException;
123    public void publishService(IBinder token,
124            Intent intent, IBinder service) throws RemoteException;
125    public void unbindFinished(IBinder token, Intent service,
126            boolean doRebind) throws RemoteException;
127    /* oneway */
128    public void serviceDoneExecuting(IBinder token) throws RemoteException;
129    public IBinder peekService(Intent service, String resolvedType) throws RemoteException;
130
131    public boolean startInstrumentation(ComponentName className, String profileFile,
132            int flags, Bundle arguments, IInstrumentationWatcher watcher)
133            throws RemoteException;
134    public void finishInstrumentation(IApplicationThread target,
135            int resultCode, Bundle results) throws RemoteException;
136
137    public Configuration getConfiguration() throws RemoteException;
138    public void updateConfiguration(Configuration values) throws RemoteException;
139    public void setRequestedOrientation(IBinder token,
140            int requestedOrientation) throws RemoteException;
141    public int getRequestedOrientation(IBinder token) throws RemoteException;
142
143    public ComponentName getActivityClassForToken(IBinder token) throws RemoteException;
144    public String getPackageForToken(IBinder token) throws RemoteException;
145
146    public static final int INTENT_SENDER_BROADCAST = 1;
147    public static final int INTENT_SENDER_ACTIVITY = 2;
148    public static final int INTENT_SENDER_ACTIVITY_RESULT = 3;
149    public static final int INTENT_SENDER_SERVICE = 4;
150    public IIntentSender getIntentSender(int type,
151            String packageName, IBinder token, String resultWho,
152            int requestCode, Intent intent, String resolvedType, int flags) throws RemoteException;
153    public void cancelIntentSender(IIntentSender sender) throws RemoteException;
154    public boolean clearApplicationUserData(final String packageName,
155            final IPackageDataObserver observer) throws RemoteException;
156    public String getPackageForIntentSender(IIntentSender sender) throws RemoteException;
157
158    public void setProcessLimit(int max) throws RemoteException;
159    public int getProcessLimit() throws RemoteException;
160
161    public void setProcessForeground(IBinder token, int pid, boolean isForeground) throws RemoteException;
162
163    public int checkPermission(String permission, int pid, int uid)
164            throws RemoteException;
165
166    public int checkUriPermission(Uri uri, int pid, int uid, int mode)
167            throws RemoteException;
168    public void grantUriPermission(IApplicationThread caller, String targetPkg,
169            Uri uri, int mode) throws RemoteException;
170    public void revokeUriPermission(IApplicationThread caller, Uri uri,
171            int mode) throws RemoteException;
172
173    public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
174            throws RemoteException;
175
176    public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException;
177
178    public void restartPackage(final String packageName) throws RemoteException;
179
180    // Note: probably don't want to allow applications access to these.
181    public void goingToSleep() throws RemoteException;
182    public void wakingUp() throws RemoteException;
183
184    public void unhandledBack() throws RemoteException;
185    public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException;
186    public void setDebugApp(
187        String packageName, boolean waitForDebugger, boolean persistent)
188        throws RemoteException;
189    public void setAlwaysFinish(boolean enabled) throws RemoteException;
190    public void setActivityWatcher(IActivityWatcher watcher)
191        throws RemoteException;
192
193    public void enterSafeMode() throws RemoteException;
194
195    public void noteWakeupAlarm(IIntentSender sender) throws RemoteException;
196
197    public boolean killPidsForMemory(int[] pids) throws RemoteException;
198
199    public void reportPss(IApplicationThread caller, int pss) throws RemoteException;
200
201    // Special low-level communication with activity manager.
202    public void startRunning(String pkg, String cls, String action,
203            String data) throws RemoteException;
204    public void systemReady() throws RemoteException;
205    // Returns 1 if the user wants to debug.
206    public int handleApplicationError(IBinder app,
207            int flags,    /* 1 == can debug */
208            String tag, String shortMsg, String longMsg,
209            byte[] crashData) throws RemoteException;
210
211    /*
212     * This will deliver the specified signal to all the persistent processes. Currently only
213     * SIGUSR1 is delivered. All others are ignored.
214     */
215    public void signalPersistentProcesses(int signal) throws RemoteException;
216    // Retrieve running application processes in the system
217    public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
218            throws RemoteException;
219    // Get device configuration
220    public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException;
221
222    // Turn on/off profiling in a particular process.
223    public boolean profileControl(String process, boolean start,
224            String path) throws RemoteException;
225
226    public boolean shutdown(int timeout) throws RemoteException;
227
228    /*
229     * Private non-Binder interfaces
230     */
231    /* package */ boolean testIsSystemReady();
232
233    /** Information you can retrieve about a particular application. */
234    public static class ContentProviderHolder implements Parcelable {
235        public final ProviderInfo info;
236        public final String permissionFailure;
237        public IContentProvider provider;
238        public boolean noReleaseNeeded;
239
240        public ContentProviderHolder(ProviderInfo _info) {
241            info = _info;
242            permissionFailure = null;
243        }
244
245        public ContentProviderHolder(ProviderInfo _info,
246                String _permissionFailure) {
247            info = _info;
248            permissionFailure = _permissionFailure;
249        }
250
251        public int describeContents() {
252            return 0;
253        }
254
255        public void writeToParcel(Parcel dest, int flags) {
256            info.writeToParcel(dest, 0);
257            dest.writeString(permissionFailure);
258            if (provider != null) {
259                dest.writeStrongBinder(provider.asBinder());
260            } else {
261                dest.writeStrongBinder(null);
262            }
263            dest.writeInt(noReleaseNeeded ? 1:0);
264        }
265
266        public static final Parcelable.Creator<ContentProviderHolder> CREATOR
267                = new Parcelable.Creator<ContentProviderHolder>() {
268            public ContentProviderHolder createFromParcel(Parcel source) {
269                return new ContentProviderHolder(source);
270            }
271
272            public ContentProviderHolder[] newArray(int size) {
273                return new ContentProviderHolder[size];
274            }
275        };
276
277        private ContentProviderHolder(Parcel source) {
278            info = ProviderInfo.CREATOR.createFromParcel(source);
279            permissionFailure = source.readString();
280            provider = ContentProviderNative.asInterface(
281                source.readStrongBinder());
282            noReleaseNeeded = source.readInt() != 0;
283        }
284    };
285
286    String descriptor = "android.app.IActivityManager";
287
288    // Please keep these transaction codes the same -- they are also
289    // sent by C++ code.
290    int START_RUNNING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
291    int HANDLE_APPLICATION_ERROR_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+1;
292    int START_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+2;
293    int UNHANDLED_BACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+3;
294    int OPEN_CONTENT_URI_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+4;
295
296    // Remaining non-native transaction codes.
297    int FINISH_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+10;
298    int REGISTER_RECEIVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+11;
299    int UNREGISTER_RECEIVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+12;
300    int BROADCAST_INTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+13;
301    int UNBROADCAST_INTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+14;
302    int FINISH_RECEIVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+15;
303    int ATTACH_APPLICATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+16;
304    int ACTIVITY_IDLE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+17;
305    int ACTIVITY_PAUSED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+18;
306    int ACTIVITY_STOPPED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+19;
307    int GET_CALLING_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+20;
308    int GET_CALLING_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+21;
309    int GET_TASKS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+22;
310    int MOVE_TASK_TO_FRONT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+23;
311    int MOVE_TASK_TO_BACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+24;
312    int MOVE_TASK_BACKWARDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+25;
313    int GET_TASK_FOR_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+26;
314    int REPORT_THUMBNAIL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+27;
315    int GET_CONTENT_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+28;
316    int PUBLISH_CONTENT_PROVIDERS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+29;
317    int SET_PERSISTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+30;
318    int FINISH_SUB_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+31;
319    int SYSTEM_READY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+32;
320    int START_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+33;
321    int STOP_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+34;
322    int BIND_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+35;
323    int UNBIND_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+36;
324    int PUBLISH_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+37;
325    int FINISH_OTHER_INSTANCES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+38;
326    int GOING_TO_SLEEP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+39;
327    int WAKING_UP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+40;
328    int SET_DEBUG_APP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+41;
329    int SET_ALWAYS_FINISH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+42;
330    int START_INSTRUMENTATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+43;
331    int FINISH_INSTRUMENTATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+44;
332    int GET_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+45;
333    int UPDATE_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+46;
334    int STOP_SERVICE_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+47;
335    int GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+48;
336    int GET_PACKAGE_FOR_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+49;
337    int SET_PROCESS_LIMIT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+50;
338    int GET_PROCESS_LIMIT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+51;
339    int CHECK_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+52;
340    int CHECK_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+53;
341    int GRANT_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+54;
342    int REVOKE_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+55;
343    int SET_ACTIVITY_WATCHER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+56;
344    int SHOW_WAITING_FOR_DEBUGGER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+57;
345    int SIGNAL_PERSISTENT_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+58;
346    int GET_RECENT_TASKS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+59;
347    int SERVICE_DONE_EXECUTING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+60;
348    int ACTIVITY_DESTROYED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+61;
349    int GET_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+62;
350    int CANCEL_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+63;
351    int GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+64;
352    int ENTER_SAFE_MODE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+65;
353    int START_NEXT_MATCHING_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+66;
354    int NOTE_WAKEUP_ALARM_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+67;
355    int REMOVE_CONTENT_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+68;
356    int SET_REQUESTED_ORIENTATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+69;
357    int GET_REQUESTED_ORIENTATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+70;
358    int UNBIND_FINISHED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+71;
359    int SET_PROCESS_FOREGROUND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+72;
360    int SET_SERVICE_FOREGROUND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+73;
361    int MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+74;
362    int GET_MEMORY_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+75;
363    int GET_PROCESSES_IN_ERROR_STATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+76;
364    int CLEAR_APP_DATA_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+77;
365    int RESTART_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+78;
366    int KILL_PIDS_FOR_MEMORY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+79;
367    int GET_SERVICES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+80;
368    int REPORT_PSS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+81;
369    int GET_RUNNING_APP_PROCESSES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+82;
370    int GET_DEVICE_CONFIGURATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+83;
371    int PEEK_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+84;
372    int PROFILE_CONTROL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+85;
373    int SHUTDOWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+86;
374}
375