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