blob: f3cc4ee88d71f14c1212e2b1fcb4648a0ab1e7ff [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.content.ComponentName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020import android.content.Intent;
21import android.content.IntentFilter;
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -070022import android.content.IIntentSender;
23import android.content.IIntentReceiver;
Dianne Hackbornfa82f222009-09-17 15:14:12 -070024import android.content.IntentSender;
Christopher Tate181fafa2009-05-14 11:12:14 -070025import android.content.pm.ApplicationInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.content.pm.ConfigurationInfo;
27import android.content.pm.IPackageDataObserver;
28import android.content.res.Configuration;
29import android.graphics.Bitmap;
30import android.net.Uri;
31import android.os.Binder;
32import android.os.Bundle;
Dianne Hackborn3025ef32009-08-31 21:31:47 -070033import android.os.Debug;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.os.Parcelable;
35import android.os.ParcelFileDescriptor;
36import android.os.RemoteException;
37import android.os.IBinder;
38import android.os.Parcel;
39import android.os.ServiceManager;
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -070040import android.os.StrictMode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import android.text.TextUtils;
42import android.util.Config;
43import android.util.Log;
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -080044import android.util.Singleton;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046import java.util.ArrayList;
47import java.util.List;
48
49/** {@hide} */
50public abstract class ActivityManagerNative extends Binder implements IActivityManager
51{
52 /**
53 * Cast a Binder object into an activity manager interface, generating
54 * a proxy if needed.
55 */
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -080056 static public IActivityManager asInterface(IBinder obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 if (obj == null) {
58 return null;
59 }
60 IActivityManager in =
61 (IActivityManager)obj.queryLocalInterface(descriptor);
62 if (in != null) {
63 return in;
64 }
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -080065
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080066 return new ActivityManagerProxy(obj);
67 }
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -080068
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 /**
70 * Retrieve the system's default/global activity manager.
71 */
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -080072 static public IActivityManager getDefault() {
73 return gDefault.get();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 }
75
76 /**
77 * Convenience for checking whether the system is ready. For internal use only.
78 */
79 static public boolean isSystemReady() {
80 if (!sSystemReady) {
81 sSystemReady = getDefault().testIsSystemReady();
82 }
83 return sSystemReady;
84 }
85 static boolean sSystemReady = false;
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -080086
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080087 /**
88 * Convenience for sending a sticky broadcast. For internal use only.
89 * If you don't care about permission, use null.
90 */
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -080091 static public void broadcastStickyIntent(Intent intent, String permission) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 try {
93 getDefault().broadcastIntent(
94 null, intent, null, null, Activity.RESULT_OK, null, null,
95 null /*permission*/, false, true);
96 } catch (RemoteException ex) {
97 }
98 }
99
100 static public void noteWakeupAlarm(PendingIntent ps) {
101 try {
102 getDefault().noteWakeupAlarm(ps.getTarget());
103 } catch (RemoteException ex) {
104 }
105 }
106
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -0800107 public ActivityManagerNative() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800108 attachInterface(this, descriptor);
109 }
110
111 public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
112 throws RemoteException {
113 switch (code) {
114 case START_ACTIVITY_TRANSACTION:
115 {
116 data.enforceInterface(IActivityManager.descriptor);
117 IBinder b = data.readStrongBinder();
118 IApplicationThread app = ApplicationThreadNative.asInterface(b);
119 Intent intent = Intent.CREATOR.createFromParcel(data);
120 String resolvedType = data.readString();
121 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
122 int grantedMode = data.readInt();
123 IBinder resultTo = data.readStrongBinder();
124 String resultWho = data.readString();
125 int requestCode = data.readInt();
126 boolean onlyIfNeeded = data.readInt() != 0;
127 boolean debug = data.readInt() != 0;
128 int result = startActivity(app, intent, resolvedType,
129 grantedUriPermissions, grantedMode, resultTo, resultWho,
130 requestCode, onlyIfNeeded, debug);
131 reply.writeNoException();
132 reply.writeInt(result);
133 return true;
134 }
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700135
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -0800136 case START_ACTIVITY_AND_WAIT_TRANSACTION:
137 {
138 data.enforceInterface(IActivityManager.descriptor);
139 IBinder b = data.readStrongBinder();
140 IApplicationThread app = ApplicationThreadNative.asInterface(b);
141 Intent intent = Intent.CREATOR.createFromParcel(data);
142 String resolvedType = data.readString();
143 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
144 int grantedMode = data.readInt();
145 IBinder resultTo = data.readStrongBinder();
146 String resultWho = data.readString();
147 int requestCode = data.readInt();
148 boolean onlyIfNeeded = data.readInt() != 0;
149 boolean debug = data.readInt() != 0;
150 WaitResult result = startActivityAndWait(app, intent, resolvedType,
151 grantedUriPermissions, grantedMode, resultTo, resultWho,
152 requestCode, onlyIfNeeded, debug);
153 reply.writeNoException();
154 result.writeToParcel(reply, 0);
155 return true;
156 }
157
Dianne Hackborn2ccda4d2010-03-22 21:49:15 -0700158 case START_ACTIVITY_WITH_CONFIG_TRANSACTION:
159 {
160 data.enforceInterface(IActivityManager.descriptor);
161 IBinder b = data.readStrongBinder();
162 IApplicationThread app = ApplicationThreadNative.asInterface(b);
163 Intent intent = Intent.CREATOR.createFromParcel(data);
164 String resolvedType = data.readString();
165 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
166 int grantedMode = data.readInt();
167 IBinder resultTo = data.readStrongBinder();
168 String resultWho = data.readString();
169 int requestCode = data.readInt();
170 boolean onlyIfNeeded = data.readInt() != 0;
171 boolean debug = data.readInt() != 0;
172 Configuration config = Configuration.CREATOR.createFromParcel(data);
173 int result = startActivityWithConfig(app, intent, resolvedType,
174 grantedUriPermissions, grantedMode, resultTo, resultWho,
175 requestCode, onlyIfNeeded, debug, config);
176 reply.writeNoException();
177 reply.writeInt(result);
178 return true;
179 }
180
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700181 case START_ACTIVITY_INTENT_SENDER_TRANSACTION:
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700182 {
183 data.enforceInterface(IActivityManager.descriptor);
184 IBinder b = data.readStrongBinder();
185 IApplicationThread app = ApplicationThreadNative.asInterface(b);
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700186 IntentSender intent = IntentSender.CREATOR.createFromParcel(data);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700187 Intent fillInIntent = null;
188 if (data.readInt() != 0) {
189 fillInIntent = Intent.CREATOR.createFromParcel(data);
190 }
191 String resolvedType = data.readString();
192 IBinder resultTo = data.readStrongBinder();
193 String resultWho = data.readString();
194 int requestCode = data.readInt();
195 int flagsMask = data.readInt();
196 int flagsValues = data.readInt();
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700197 int result = startActivityIntentSender(app, intent,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700198 fillInIntent, resolvedType, resultTo, resultWho,
199 requestCode, flagsMask, flagsValues);
200 reply.writeNoException();
201 reply.writeInt(result);
202 return true;
203 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800204
205 case START_NEXT_MATCHING_ACTIVITY_TRANSACTION:
206 {
207 data.enforceInterface(IActivityManager.descriptor);
208 IBinder callingActivity = data.readStrongBinder();
209 Intent intent = Intent.CREATOR.createFromParcel(data);
210 boolean result = startNextMatchingActivity(callingActivity, intent);
211 reply.writeNoException();
212 reply.writeInt(result ? 1 : 0);
213 return true;
214 }
215
216 case FINISH_ACTIVITY_TRANSACTION: {
217 data.enforceInterface(IActivityManager.descriptor);
218 IBinder token = data.readStrongBinder();
219 Intent resultData = null;
220 int resultCode = data.readInt();
221 if (data.readInt() != 0) {
222 resultData = Intent.CREATOR.createFromParcel(data);
223 }
224 boolean res = finishActivity(token, resultCode, resultData);
225 reply.writeNoException();
226 reply.writeInt(res ? 1 : 0);
227 return true;
228 }
229
230 case FINISH_SUB_ACTIVITY_TRANSACTION: {
231 data.enforceInterface(IActivityManager.descriptor);
232 IBinder token = data.readStrongBinder();
233 String resultWho = data.readString();
234 int requestCode = data.readInt();
235 finishSubActivity(token, resultWho, requestCode);
236 reply.writeNoException();
237 return true;
238 }
239
Dianne Hackborn061d58a2010-03-12 15:07:06 -0800240 case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: {
241 data.enforceInterface(IActivityManager.descriptor);
242 IBinder token = data.readStrongBinder();
243 boolean res = willActivityBeVisible(token);
244 reply.writeNoException();
245 reply.writeInt(res ? 1 : 0);
246 return true;
247 }
248
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 case REGISTER_RECEIVER_TRANSACTION:
250 {
251 data.enforceInterface(IActivityManager.descriptor);
252 IBinder b = data.readStrongBinder();
253 IApplicationThread app =
254 b != null ? ApplicationThreadNative.asInterface(b) : null;
255 b = data.readStrongBinder();
256 IIntentReceiver rec
257 = b != null ? IIntentReceiver.Stub.asInterface(b) : null;
258 IntentFilter filter = IntentFilter.CREATOR.createFromParcel(data);
259 String perm = data.readString();
260 Intent intent = registerReceiver(app, rec, filter, perm);
261 reply.writeNoException();
262 if (intent != null) {
263 reply.writeInt(1);
264 intent.writeToParcel(reply, 0);
265 } else {
266 reply.writeInt(0);
267 }
268 return true;
269 }
270
271 case UNREGISTER_RECEIVER_TRANSACTION:
272 {
273 data.enforceInterface(IActivityManager.descriptor);
274 IBinder b = data.readStrongBinder();
275 if (b == null) {
276 return true;
277 }
278 IIntentReceiver rec = IIntentReceiver.Stub.asInterface(b);
279 unregisterReceiver(rec);
280 reply.writeNoException();
281 return true;
282 }
283
284 case BROADCAST_INTENT_TRANSACTION:
285 {
286 data.enforceInterface(IActivityManager.descriptor);
287 IBinder b = data.readStrongBinder();
288 IApplicationThread app =
289 b != null ? ApplicationThreadNative.asInterface(b) : null;
290 Intent intent = Intent.CREATOR.createFromParcel(data);
291 String resolvedType = data.readString();
292 b = data.readStrongBinder();
293 IIntentReceiver resultTo =
294 b != null ? IIntentReceiver.Stub.asInterface(b) : null;
295 int resultCode = data.readInt();
296 String resultData = data.readString();
297 Bundle resultExtras = data.readBundle();
298 String perm = data.readString();
299 boolean serialized = data.readInt() != 0;
300 boolean sticky = data.readInt() != 0;
301 int res = broadcastIntent(app, intent, resolvedType, resultTo,
302 resultCode, resultData, resultExtras, perm,
303 serialized, sticky);
304 reply.writeNoException();
305 reply.writeInt(res);
306 return true;
307 }
308
309 case UNBROADCAST_INTENT_TRANSACTION:
310 {
311 data.enforceInterface(IActivityManager.descriptor);
312 IBinder b = data.readStrongBinder();
313 IApplicationThread app = b != null ? ApplicationThreadNative.asInterface(b) : null;
314 Intent intent = Intent.CREATOR.createFromParcel(data);
315 unbroadcastIntent(app, intent);
316 reply.writeNoException();
317 return true;
318 }
319
320 case FINISH_RECEIVER_TRANSACTION: {
321 data.enforceInterface(IActivityManager.descriptor);
322 IBinder who = data.readStrongBinder();
323 int resultCode = data.readInt();
324 String resultData = data.readString();
325 Bundle resultExtras = data.readBundle();
326 boolean resultAbort = data.readInt() != 0;
327 if (who != null) {
328 finishReceiver(who, resultCode, resultData, resultExtras, resultAbort);
329 }
330 reply.writeNoException();
331 return true;
332 }
333
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800334 case ATTACH_APPLICATION_TRANSACTION: {
335 data.enforceInterface(IActivityManager.descriptor);
336 IApplicationThread app = ApplicationThreadNative.asInterface(
337 data.readStrongBinder());
338 if (app != null) {
339 attachApplication(app);
340 }
341 reply.writeNoException();
342 return true;
343 }
344
345 case ACTIVITY_IDLE_TRANSACTION: {
346 data.enforceInterface(IActivityManager.descriptor);
347 IBinder token = data.readStrongBinder();
Dianne Hackborne88846e2009-09-30 21:34:25 -0700348 Configuration config = null;
349 if (data.readInt() != 0) {
350 config = Configuration.CREATOR.createFromParcel(data);
351 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800352 if (token != null) {
Dianne Hackborne88846e2009-09-30 21:34:25 -0700353 activityIdle(token, config);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800354 }
355 reply.writeNoException();
356 return true;
357 }
358
359 case ACTIVITY_PAUSED_TRANSACTION: {
360 data.enforceInterface(IActivityManager.descriptor);
361 IBinder token = data.readStrongBinder();
362 Bundle map = data.readBundle();
363 activityPaused(token, map);
364 reply.writeNoException();
365 return true;
366 }
367
368 case ACTIVITY_STOPPED_TRANSACTION: {
369 data.enforceInterface(IActivityManager.descriptor);
370 IBinder token = data.readStrongBinder();
371 Bitmap thumbnail = data.readInt() != 0
372 ? Bitmap.CREATOR.createFromParcel(data) : null;
373 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
374 activityStopped(token, thumbnail, description);
375 reply.writeNoException();
376 return true;
377 }
378
379 case ACTIVITY_DESTROYED_TRANSACTION: {
380 data.enforceInterface(IActivityManager.descriptor);
381 IBinder token = data.readStrongBinder();
382 activityDestroyed(token);
383 reply.writeNoException();
384 return true;
385 }
386
387 case GET_CALLING_PACKAGE_TRANSACTION: {
388 data.enforceInterface(IActivityManager.descriptor);
389 IBinder token = data.readStrongBinder();
390 String res = token != null ? getCallingPackage(token) : null;
391 reply.writeNoException();
392 reply.writeString(res);
393 return true;
394 }
395
396 case GET_CALLING_ACTIVITY_TRANSACTION: {
397 data.enforceInterface(IActivityManager.descriptor);
398 IBinder token = data.readStrongBinder();
399 ComponentName cn = getCallingActivity(token);
400 reply.writeNoException();
401 ComponentName.writeToParcel(cn, reply);
402 return true;
403 }
404
405 case GET_TASKS_TRANSACTION: {
406 data.enforceInterface(IActivityManager.descriptor);
407 int maxNum = data.readInt();
408 int fl = data.readInt();
409 IBinder receiverBinder = data.readStrongBinder();
410 IThumbnailReceiver receiver = receiverBinder != null
411 ? IThumbnailReceiver.Stub.asInterface(receiverBinder)
412 : null;
413 List list = getTasks(maxNum, fl, receiver);
414 reply.writeNoException();
415 int N = list != null ? list.size() : -1;
416 reply.writeInt(N);
417 int i;
418 for (i=0; i<N; i++) {
419 ActivityManager.RunningTaskInfo info =
420 (ActivityManager.RunningTaskInfo)list.get(i);
421 info.writeToParcel(reply, 0);
422 }
423 return true;
424 }
425
426 case GET_RECENT_TASKS_TRANSACTION: {
427 data.enforceInterface(IActivityManager.descriptor);
428 int maxNum = data.readInt();
429 int fl = data.readInt();
430 List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
431 fl);
432 reply.writeNoException();
433 reply.writeTypedList(list);
434 return true;
435 }
436
437 case GET_SERVICES_TRANSACTION: {
438 data.enforceInterface(IActivityManager.descriptor);
439 int maxNum = data.readInt();
440 int fl = data.readInt();
441 List list = getServices(maxNum, fl);
442 reply.writeNoException();
443 int N = list != null ? list.size() : -1;
444 reply.writeInt(N);
445 int i;
446 for (i=0; i<N; i++) {
447 ActivityManager.RunningServiceInfo info =
448 (ActivityManager.RunningServiceInfo)list.get(i);
449 info.writeToParcel(reply, 0);
450 }
451 return true;
452 }
453
454 case GET_PROCESSES_IN_ERROR_STATE_TRANSACTION: {
455 data.enforceInterface(IActivityManager.descriptor);
456 List<ActivityManager.ProcessErrorStateInfo> list = getProcessesInErrorState();
457 reply.writeNoException();
458 reply.writeTypedList(list);
459 return true;
460 }
461
462 case GET_RUNNING_APP_PROCESSES_TRANSACTION: {
463 data.enforceInterface(IActivityManager.descriptor);
464 List<ActivityManager.RunningAppProcessInfo> list = getRunningAppProcesses();
465 reply.writeNoException();
466 reply.writeTypedList(list);
467 return true;
468 }
469
Suchi Amalapurapuf7f5dda2010-03-23 10:34:28 -0700470 case GET_RUNNING_EXTERNAL_APPLICATIONS_TRANSACTION: {
471 data.enforceInterface(IActivityManager.descriptor);
472 List<ApplicationInfo> list = getRunningExternalApplications();
473 reply.writeNoException();
474 reply.writeTypedList(list);
475 return true;
476 }
477
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800478 case MOVE_TASK_TO_FRONT_TRANSACTION: {
479 data.enforceInterface(IActivityManager.descriptor);
480 int task = data.readInt();
Dianne Hackborn621e17d2010-11-22 15:59:56 -0800481 int fl = data.readInt();
482 moveTaskToFront(task, fl);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800483 reply.writeNoException();
484 return true;
485 }
486
487 case MOVE_TASK_TO_BACK_TRANSACTION: {
488 data.enforceInterface(IActivityManager.descriptor);
489 int task = data.readInt();
490 moveTaskToBack(task);
491 reply.writeNoException();
492 return true;
493 }
494
495 case MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION: {
496 data.enforceInterface(IActivityManager.descriptor);
497 IBinder token = data.readStrongBinder();
498 boolean nonRoot = data.readInt() != 0;
499 boolean res = moveActivityTaskToBack(token, nonRoot);
500 reply.writeNoException();
501 reply.writeInt(res ? 1 : 0);
502 return true;
503 }
504
505 case MOVE_TASK_BACKWARDS_TRANSACTION: {
506 data.enforceInterface(IActivityManager.descriptor);
507 int task = data.readInt();
508 moveTaskBackwards(task);
509 reply.writeNoException();
510 return true;
511 }
512
513 case GET_TASK_FOR_ACTIVITY_TRANSACTION: {
514 data.enforceInterface(IActivityManager.descriptor);
515 IBinder token = data.readStrongBinder();
516 boolean onlyRoot = data.readInt() != 0;
517 int res = token != null
518 ? getTaskForActivity(token, onlyRoot) : -1;
519 reply.writeNoException();
520 reply.writeInt(res);
521 return true;
522 }
523
524 case FINISH_OTHER_INSTANCES_TRANSACTION: {
525 data.enforceInterface(IActivityManager.descriptor);
526 IBinder token = data.readStrongBinder();
527 ComponentName className = ComponentName.readFromParcel(data);
528 finishOtherInstances(token, className);
529 reply.writeNoException();
530 return true;
531 }
532
533 case REPORT_THUMBNAIL_TRANSACTION: {
534 data.enforceInterface(IActivityManager.descriptor);
535 IBinder token = data.readStrongBinder();
536 Bitmap thumbnail = data.readInt() != 0
537 ? Bitmap.CREATOR.createFromParcel(data) : null;
538 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
539 reportThumbnail(token, thumbnail, description);
540 reply.writeNoException();
541 return true;
542 }
543
544 case GET_CONTENT_PROVIDER_TRANSACTION: {
545 data.enforceInterface(IActivityManager.descriptor);
546 IBinder b = data.readStrongBinder();
547 IApplicationThread app = ApplicationThreadNative.asInterface(b);
548 String name = data.readString();
549 ContentProviderHolder cph = getContentProvider(app, name);
550 reply.writeNoException();
551 if (cph != null) {
552 reply.writeInt(1);
553 cph.writeToParcel(reply, 0);
554 } else {
555 reply.writeInt(0);
556 }
557 return true;
558 }
559
560 case PUBLISH_CONTENT_PROVIDERS_TRANSACTION: {
561 data.enforceInterface(IActivityManager.descriptor);
562 IBinder b = data.readStrongBinder();
563 IApplicationThread app = ApplicationThreadNative.asInterface(b);
564 ArrayList<ContentProviderHolder> providers =
565 data.createTypedArrayList(ContentProviderHolder.CREATOR);
566 publishContentProviders(app, providers);
567 reply.writeNoException();
568 return true;
569 }
570
571 case REMOVE_CONTENT_PROVIDER_TRANSACTION: {
572 data.enforceInterface(IActivityManager.descriptor);
573 IBinder b = data.readStrongBinder();
574 IApplicationThread app = ApplicationThreadNative.asInterface(b);
575 String name = data.readString();
576 removeContentProvider(app, name);
577 reply.writeNoException();
578 return true;
579 }
580
Dianne Hackborndd9b82c2009-09-03 00:18:47 -0700581 case GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION: {
582 data.enforceInterface(IActivityManager.descriptor);
583 ComponentName comp = ComponentName.CREATOR.createFromParcel(data);
584 PendingIntent pi = getRunningServiceControlPanel(comp);
585 reply.writeNoException();
586 PendingIntent.writePendingIntentOrNullToParcel(pi, reply);
587 return true;
588 }
589
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800590 case START_SERVICE_TRANSACTION: {
591 data.enforceInterface(IActivityManager.descriptor);
592 IBinder b = data.readStrongBinder();
593 IApplicationThread app = ApplicationThreadNative.asInterface(b);
594 Intent service = Intent.CREATOR.createFromParcel(data);
595 String resolvedType = data.readString();
596 ComponentName cn = startService(app, service, resolvedType);
597 reply.writeNoException();
598 ComponentName.writeToParcel(cn, reply);
599 return true;
600 }
601
602 case STOP_SERVICE_TRANSACTION: {
603 data.enforceInterface(IActivityManager.descriptor);
604 IBinder b = data.readStrongBinder();
605 IApplicationThread app = ApplicationThreadNative.asInterface(b);
606 Intent service = Intent.CREATOR.createFromParcel(data);
607 String resolvedType = data.readString();
608 int res = stopService(app, service, resolvedType);
609 reply.writeNoException();
610 reply.writeInt(res);
611 return true;
612 }
613
614 case STOP_SERVICE_TOKEN_TRANSACTION: {
615 data.enforceInterface(IActivityManager.descriptor);
616 ComponentName className = ComponentName.readFromParcel(data);
617 IBinder token = data.readStrongBinder();
618 int startId = data.readInt();
619 boolean res = stopServiceToken(className, token, startId);
620 reply.writeNoException();
621 reply.writeInt(res ? 1 : 0);
622 return true;
623 }
624
625 case SET_SERVICE_FOREGROUND_TRANSACTION: {
626 data.enforceInterface(IActivityManager.descriptor);
627 ComponentName className = ComponentName.readFromParcel(data);
628 IBinder token = data.readStrongBinder();
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700629 int id = data.readInt();
630 Notification notification = null;
631 if (data.readInt() != 0) {
632 notification = Notification.CREATOR.createFromParcel(data);
633 }
634 boolean removeNotification = data.readInt() != 0;
635 setServiceForeground(className, token, id, notification, removeNotification);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800636 reply.writeNoException();
637 return true;
638 }
639
640 case BIND_SERVICE_TRANSACTION: {
641 data.enforceInterface(IActivityManager.descriptor);
642 IBinder b = data.readStrongBinder();
643 IApplicationThread app = ApplicationThreadNative.asInterface(b);
644 IBinder token = data.readStrongBinder();
645 Intent service = Intent.CREATOR.createFromParcel(data);
646 String resolvedType = data.readString();
647 b = data.readStrongBinder();
648 int fl = data.readInt();
649 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
650 int res = bindService(app, token, service, resolvedType, conn, fl);
651 reply.writeNoException();
652 reply.writeInt(res);
653 return true;
654 }
655
656 case UNBIND_SERVICE_TRANSACTION: {
657 data.enforceInterface(IActivityManager.descriptor);
658 IBinder b = data.readStrongBinder();
659 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
660 boolean res = unbindService(conn);
661 reply.writeNoException();
662 reply.writeInt(res ? 1 : 0);
663 return true;
664 }
665
666 case PUBLISH_SERVICE_TRANSACTION: {
667 data.enforceInterface(IActivityManager.descriptor);
668 IBinder token = data.readStrongBinder();
669 Intent intent = Intent.CREATOR.createFromParcel(data);
670 IBinder service = data.readStrongBinder();
671 publishService(token, intent, service);
672 reply.writeNoException();
673 return true;
674 }
675
676 case UNBIND_FINISHED_TRANSACTION: {
677 data.enforceInterface(IActivityManager.descriptor);
678 IBinder token = data.readStrongBinder();
679 Intent intent = Intent.CREATOR.createFromParcel(data);
680 boolean doRebind = data.readInt() != 0;
681 unbindFinished(token, intent, doRebind);
682 reply.writeNoException();
683 return true;
684 }
685
686 case SERVICE_DONE_EXECUTING_TRANSACTION: {
687 data.enforceInterface(IActivityManager.descriptor);
688 IBinder token = data.readStrongBinder();
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700689 int type = data.readInt();
690 int startId = data.readInt();
691 int res = data.readInt();
692 serviceDoneExecuting(token, type, startId, res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800693 reply.writeNoException();
694 return true;
695 }
696
697 case START_INSTRUMENTATION_TRANSACTION: {
698 data.enforceInterface(IActivityManager.descriptor);
699 ComponentName className = ComponentName.readFromParcel(data);
700 String profileFile = data.readString();
701 int fl = data.readInt();
702 Bundle arguments = data.readBundle();
703 IBinder b = data.readStrongBinder();
704 IInstrumentationWatcher w = IInstrumentationWatcher.Stub.asInterface(b);
705 boolean res = startInstrumentation(className, profileFile, fl, arguments, w);
706 reply.writeNoException();
707 reply.writeInt(res ? 1 : 0);
708 return true;
709 }
710
711
712 case FINISH_INSTRUMENTATION_TRANSACTION: {
713 data.enforceInterface(IActivityManager.descriptor);
714 IBinder b = data.readStrongBinder();
715 IApplicationThread app = ApplicationThreadNative.asInterface(b);
716 int resultCode = data.readInt();
717 Bundle results = data.readBundle();
718 finishInstrumentation(app, resultCode, results);
719 reply.writeNoException();
720 return true;
721 }
722
723 case GET_CONFIGURATION_TRANSACTION: {
724 data.enforceInterface(IActivityManager.descriptor);
725 Configuration config = getConfiguration();
726 reply.writeNoException();
727 config.writeToParcel(reply, 0);
728 return true;
729 }
730
731 case UPDATE_CONFIGURATION_TRANSACTION: {
732 data.enforceInterface(IActivityManager.descriptor);
733 Configuration config = Configuration.CREATOR.createFromParcel(data);
734 updateConfiguration(config);
735 reply.writeNoException();
736 return true;
737 }
738
739 case SET_REQUESTED_ORIENTATION_TRANSACTION: {
740 data.enforceInterface(IActivityManager.descriptor);
741 IBinder token = data.readStrongBinder();
742 int requestedOrientation = data.readInt();
743 setRequestedOrientation(token, requestedOrientation);
744 reply.writeNoException();
745 return true;
746 }
747
748 case GET_REQUESTED_ORIENTATION_TRANSACTION: {
749 data.enforceInterface(IActivityManager.descriptor);
750 IBinder token = data.readStrongBinder();
751 int req = getRequestedOrientation(token);
752 reply.writeNoException();
753 reply.writeInt(req);
754 return true;
755 }
756
757 case GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION: {
758 data.enforceInterface(IActivityManager.descriptor);
759 IBinder token = data.readStrongBinder();
760 ComponentName cn = getActivityClassForToken(token);
761 reply.writeNoException();
762 ComponentName.writeToParcel(cn, reply);
763 return true;
764 }
765
766 case GET_PACKAGE_FOR_TOKEN_TRANSACTION: {
767 data.enforceInterface(IActivityManager.descriptor);
768 IBinder token = data.readStrongBinder();
769 reply.writeNoException();
770 reply.writeString(getPackageForToken(token));
771 return true;
772 }
773
774 case GET_INTENT_SENDER_TRANSACTION: {
775 data.enforceInterface(IActivityManager.descriptor);
776 int type = data.readInt();
777 String packageName = data.readString();
778 IBinder token = data.readStrongBinder();
779 String resultWho = data.readString();
780 int requestCode = data.readInt();
Dianne Hackborn621e17d2010-11-22 15:59:56 -0800781 Intent[] requestIntents;
782 String[] requestResolvedTypes;
783 if (data.readInt() != 0) {
784 requestIntents = data.createTypedArray(Intent.CREATOR);
785 requestResolvedTypes = data.createStringArray();
786 } else {
787 requestIntents = null;
788 requestResolvedTypes = null;
789 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800790 int fl = data.readInt();
791 IIntentSender res = getIntentSender(type, packageName, token,
Dianne Hackborn621e17d2010-11-22 15:59:56 -0800792 resultWho, requestCode, requestIntents,
793 requestResolvedTypes, fl);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800794 reply.writeNoException();
795 reply.writeStrongBinder(res != null ? res.asBinder() : null);
796 return true;
797 }
798
799 case CANCEL_INTENT_SENDER_TRANSACTION: {
800 data.enforceInterface(IActivityManager.descriptor);
801 IIntentSender r = IIntentSender.Stub.asInterface(
802 data.readStrongBinder());
803 cancelIntentSender(r);
804 reply.writeNoException();
805 return true;
806 }
807
808 case GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION: {
809 data.enforceInterface(IActivityManager.descriptor);
810 IIntentSender r = IIntentSender.Stub.asInterface(
811 data.readStrongBinder());
812 String res = getPackageForIntentSender(r);
813 reply.writeNoException();
814 reply.writeString(res);
815 return true;
816 }
817
818 case SET_PROCESS_LIMIT_TRANSACTION: {
819 data.enforceInterface(IActivityManager.descriptor);
820 int max = data.readInt();
821 setProcessLimit(max);
822 reply.writeNoException();
823 return true;
824 }
825
826 case GET_PROCESS_LIMIT_TRANSACTION: {
827 data.enforceInterface(IActivityManager.descriptor);
828 int limit = getProcessLimit();
829 reply.writeNoException();
830 reply.writeInt(limit);
831 return true;
832 }
833
834 case SET_PROCESS_FOREGROUND_TRANSACTION: {
835 data.enforceInterface(IActivityManager.descriptor);
836 IBinder token = data.readStrongBinder();
837 int pid = data.readInt();
838 boolean isForeground = data.readInt() != 0;
839 setProcessForeground(token, pid, isForeground);
840 reply.writeNoException();
841 return true;
842 }
843
844 case CHECK_PERMISSION_TRANSACTION: {
845 data.enforceInterface(IActivityManager.descriptor);
846 String perm = data.readString();
847 int pid = data.readInt();
848 int uid = data.readInt();
849 int res = checkPermission(perm, pid, uid);
850 reply.writeNoException();
851 reply.writeInt(res);
852 return true;
853 }
854
855 case CHECK_URI_PERMISSION_TRANSACTION: {
856 data.enforceInterface(IActivityManager.descriptor);
857 Uri uri = Uri.CREATOR.createFromParcel(data);
858 int pid = data.readInt();
859 int uid = data.readInt();
860 int mode = data.readInt();
861 int res = checkUriPermission(uri, pid, uid, mode);
862 reply.writeNoException();
863 reply.writeInt(res);
864 return true;
865 }
866
867 case CLEAR_APP_DATA_TRANSACTION: {
868 data.enforceInterface(IActivityManager.descriptor);
869 String packageName = data.readString();
870 IPackageDataObserver observer = IPackageDataObserver.Stub.asInterface(
871 data.readStrongBinder());
872 boolean res = clearApplicationUserData(packageName, observer);
873 reply.writeNoException();
874 reply.writeInt(res ? 1 : 0);
875 return true;
876 }
877
878 case GRANT_URI_PERMISSION_TRANSACTION: {
879 data.enforceInterface(IActivityManager.descriptor);
880 IBinder b = data.readStrongBinder();
881 IApplicationThread app = ApplicationThreadNative.asInterface(b);
882 String targetPkg = data.readString();
883 Uri uri = Uri.CREATOR.createFromParcel(data);
884 int mode = data.readInt();
885 grantUriPermission(app, targetPkg, uri, mode);
886 reply.writeNoException();
887 return true;
888 }
889
890 case REVOKE_URI_PERMISSION_TRANSACTION: {
891 data.enforceInterface(IActivityManager.descriptor);
892 IBinder b = data.readStrongBinder();
893 IApplicationThread app = ApplicationThreadNative.asInterface(b);
894 Uri uri = Uri.CREATOR.createFromParcel(data);
895 int mode = data.readInt();
896 revokeUriPermission(app, uri, mode);
897 reply.writeNoException();
898 return true;
899 }
900
901 case SHOW_WAITING_FOR_DEBUGGER_TRANSACTION: {
902 data.enforceInterface(IActivityManager.descriptor);
903 IBinder b = data.readStrongBinder();
904 IApplicationThread app = ApplicationThreadNative.asInterface(b);
905 boolean waiting = data.readInt() != 0;
906 showWaitingForDebugger(app, waiting);
907 reply.writeNoException();
908 return true;
909 }
910
911 case GET_MEMORY_INFO_TRANSACTION: {
912 data.enforceInterface(IActivityManager.descriptor);
913 ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
914 getMemoryInfo(mi);
915 reply.writeNoException();
916 mi.writeToParcel(reply, 0);
917 return true;
918 }
919
920 case UNHANDLED_BACK_TRANSACTION: {
921 data.enforceInterface(IActivityManager.descriptor);
922 unhandledBack();
923 reply.writeNoException();
924 return true;
925 }
926
927 case OPEN_CONTENT_URI_TRANSACTION: {
928 data.enforceInterface(IActivityManager.descriptor);
929 Uri uri = Uri.parse(data.readString());
930 ParcelFileDescriptor pfd = openContentUri(uri);
931 reply.writeNoException();
932 if (pfd != null) {
933 reply.writeInt(1);
934 pfd.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
935 } else {
936 reply.writeInt(0);
937 }
938 return true;
939 }
940
941 case GOING_TO_SLEEP_TRANSACTION: {
942 data.enforceInterface(IActivityManager.descriptor);
943 goingToSleep();
944 reply.writeNoException();
945 return true;
946 }
947
948 case WAKING_UP_TRANSACTION: {
949 data.enforceInterface(IActivityManager.descriptor);
950 wakingUp();
951 reply.writeNoException();
952 return true;
953 }
954
955 case SET_DEBUG_APP_TRANSACTION: {
956 data.enforceInterface(IActivityManager.descriptor);
957 String pn = data.readString();
958 boolean wfd = data.readInt() != 0;
959 boolean per = data.readInt() != 0;
960 setDebugApp(pn, wfd, per);
961 reply.writeNoException();
962 return true;
963 }
964
965 case SET_ALWAYS_FINISH_TRANSACTION: {
966 data.enforceInterface(IActivityManager.descriptor);
967 boolean enabled = data.readInt() != 0;
968 setAlwaysFinish(enabled);
969 reply.writeNoException();
970 return true;
971 }
972
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700973 case SET_ACTIVITY_CONTROLLER_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800974 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700975 IActivityController watcher = IActivityController.Stub.asInterface(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800976 data.readStrongBinder());
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700977 setActivityController(watcher);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800978 return true;
979 }
980
981 case ENTER_SAFE_MODE_TRANSACTION: {
982 data.enforceInterface(IActivityManager.descriptor);
983 enterSafeMode();
984 reply.writeNoException();
985 return true;
986 }
987
988 case NOTE_WAKEUP_ALARM_TRANSACTION: {
989 data.enforceInterface(IActivityManager.descriptor);
990 IIntentSender is = IIntentSender.Stub.asInterface(
991 data.readStrongBinder());
992 noteWakeupAlarm(is);
993 reply.writeNoException();
994 return true;
995 }
996
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -0700997 case KILL_PIDS_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800998 data.enforceInterface(IActivityManager.descriptor);
999 int[] pids = data.createIntArray();
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07001000 String reason = data.readString();
1001 boolean res = killPids(pids, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001002 reply.writeNoException();
1003 reply.writeInt(res ? 1 : 0);
1004 return true;
1005 }
1006
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001007 case START_RUNNING_TRANSACTION: {
1008 data.enforceInterface(IActivityManager.descriptor);
1009 String pkg = data.readString();
1010 String cls = data.readString();
1011 String action = data.readString();
1012 String indata = data.readString();
1013 startRunning(pkg, cls, action, indata);
1014 reply.writeNoException();
1015 return true;
1016 }
1017
Dan Egnor60d87622009-12-16 16:32:58 -08001018 case HANDLE_APPLICATION_CRASH_TRANSACTION: {
1019 data.enforceInterface(IActivityManager.descriptor);
1020 IBinder app = data.readStrongBinder();
1021 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
1022 handleApplicationCrash(app, ci);
1023 reply.writeNoException();
1024 return true;
1025 }
1026
1027 case HANDLE_APPLICATION_WTF_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001028 data.enforceInterface(IActivityManager.descriptor);
1029 IBinder app = data.readStrongBinder();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001030 String tag = data.readString();
Dan Egnorb7f03672009-12-09 16:22:32 -08001031 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
Dan Egnor60d87622009-12-16 16:32:58 -08001032 boolean res = handleApplicationWtf(app, tag, ci);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001033 reply.writeNoException();
Dan Egnor60d87622009-12-16 16:32:58 -08001034 reply.writeInt(res ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001035 return true;
1036 }
Dan Egnorb7f03672009-12-09 16:22:32 -08001037
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07001038 case HANDLE_APPLICATION_STRICT_MODE_VIOLATION_TRANSACTION: {
1039 data.enforceInterface(IActivityManager.descriptor);
1040 IBinder app = data.readStrongBinder();
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07001041 int violationMask = data.readInt();
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07001042 StrictMode.ViolationInfo info = new StrictMode.ViolationInfo(data);
1043 handleApplicationStrictModeViolation(app, violationMask, info);
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07001044 reply.writeNoException();
1045 return true;
1046 }
1047
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001048 case SIGNAL_PERSISTENT_PROCESSES_TRANSACTION: {
1049 data.enforceInterface(IActivityManager.descriptor);
1050 int sig = data.readInt();
1051 signalPersistentProcesses(sig);
1052 reply.writeNoException();
1053 return true;
1054 }
1055
Dianne Hackborn03abb812010-01-04 18:43:19 -08001056 case KILL_BACKGROUND_PROCESSES_TRANSACTION: {
1057 data.enforceInterface(IActivityManager.descriptor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001058 String packageName = data.readString();
Dianne Hackborn03abb812010-01-04 18:43:19 -08001059 killBackgroundProcesses(packageName);
1060 reply.writeNoException();
1061 return true;
1062 }
1063
1064 case FORCE_STOP_PACKAGE_TRANSACTION: {
1065 data.enforceInterface(IActivityManager.descriptor);
1066 String packageName = data.readString();
1067 forceStopPackage(packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001068 reply.writeNoException();
1069 return true;
1070 }
1071
1072 case GET_DEVICE_CONFIGURATION_TRANSACTION: {
1073 data.enforceInterface(IActivityManager.descriptor);
1074 ConfigurationInfo config = getDeviceConfigurationInfo();
1075 reply.writeNoException();
1076 config.writeToParcel(reply, 0);
1077 return true;
1078 }
1079
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001080 case PROFILE_CONTROL_TRANSACTION: {
1081 data.enforceInterface(IActivityManager.descriptor);
1082 String process = data.readString();
1083 boolean start = data.readInt() != 0;
1084 String path = data.readString();
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07001085 ParcelFileDescriptor fd = data.readInt() != 0
1086 ? data.readFileDescriptor() : null;
1087 boolean res = profileControl(process, start, path, fd);
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001088 reply.writeNoException();
1089 reply.writeInt(res ? 1 : 0);
1090 return true;
1091 }
1092
Dianne Hackborn55280a92009-05-07 15:53:46 -07001093 case SHUTDOWN_TRANSACTION: {
1094 data.enforceInterface(IActivityManager.descriptor);
1095 boolean res = shutdown(data.readInt());
1096 reply.writeNoException();
1097 reply.writeInt(res ? 1 : 0);
1098 return true;
1099 }
1100
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07001101 case STOP_APP_SWITCHES_TRANSACTION: {
1102 data.enforceInterface(IActivityManager.descriptor);
1103 stopAppSwitches();
1104 reply.writeNoException();
1105 return true;
1106 }
1107
1108 case RESUME_APP_SWITCHES_TRANSACTION: {
1109 data.enforceInterface(IActivityManager.descriptor);
1110 resumeAppSwitches();
1111 reply.writeNoException();
1112 return true;
1113 }
1114
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001115 case PEEK_SERVICE_TRANSACTION: {
1116 data.enforceInterface(IActivityManager.descriptor);
1117 Intent service = Intent.CREATOR.createFromParcel(data);
1118 String resolvedType = data.readString();
1119 IBinder binder = peekService(service, resolvedType);
1120 reply.writeNoException();
1121 reply.writeStrongBinder(binder);
1122 return true;
1123 }
Christopher Tate181fafa2009-05-14 11:12:14 -07001124
1125 case START_BACKUP_AGENT_TRANSACTION: {
1126 data.enforceInterface(IActivityManager.descriptor);
1127 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1128 int backupRestoreMode = data.readInt();
1129 boolean success = bindBackupAgent(info, backupRestoreMode);
1130 reply.writeNoException();
1131 reply.writeInt(success ? 1 : 0);
1132 return true;
1133 }
1134
1135 case BACKUP_AGENT_CREATED_TRANSACTION: {
1136 data.enforceInterface(IActivityManager.descriptor);
1137 String packageName = data.readString();
1138 IBinder agent = data.readStrongBinder();
1139 backupAgentCreated(packageName, agent);
1140 reply.writeNoException();
1141 return true;
1142 }
1143
1144 case UNBIND_BACKUP_AGENT_TRANSACTION: {
1145 data.enforceInterface(IActivityManager.descriptor);
1146 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1147 unbindBackupAgent(info);
1148 reply.writeNoException();
1149 return true;
1150 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07001151
1152 case REGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1153 data.enforceInterface(IActivityManager.descriptor);
1154 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1155 data.readStrongBinder());
1156 registerActivityWatcher(watcher);
1157 return true;
1158 }
1159
1160 case UNREGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1161 data.enforceInterface(IActivityManager.descriptor);
1162 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1163 data.readStrongBinder());
1164 unregisterActivityWatcher(watcher);
1165 return true;
1166 }
Dianne Hackborn2d91af02009-07-16 13:34:33 -07001167
1168 case START_ACTIVITY_IN_PACKAGE_TRANSACTION:
1169 {
1170 data.enforceInterface(IActivityManager.descriptor);
1171 int uid = data.readInt();
1172 Intent intent = Intent.CREATOR.createFromParcel(data);
1173 String resolvedType = data.readString();
1174 IBinder resultTo = data.readStrongBinder();
1175 String resultWho = data.readString();
1176 int requestCode = data.readInt();
1177 boolean onlyIfNeeded = data.readInt() != 0;
1178 int result = startActivityInPackage(uid, intent, resolvedType,
1179 resultTo, resultWho, requestCode, onlyIfNeeded);
1180 reply.writeNoException();
1181 reply.writeInt(result);
1182 return true;
1183 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001184
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07001185 case KILL_APPLICATION_WITH_UID_TRANSACTION: {
1186 data.enforceInterface(IActivityManager.descriptor);
1187 String pkg = data.readString();
1188 int uid = data.readInt();
1189 killApplicationWithUid(pkg, uid);
1190 reply.writeNoException();
1191 return true;
1192 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001193
1194 case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
1195 data.enforceInterface(IActivityManager.descriptor);
1196 String reason = data.readString();
1197 closeSystemDialogs(reason);
1198 reply.writeNoException();
1199 return true;
1200 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001201
1202 case GET_PROCESS_MEMORY_INFO_TRANSACTION: {
1203 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001204 int[] pids = data.createIntArray();
1205 Debug.MemoryInfo[] res = getProcessMemoryInfo(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001206 reply.writeNoException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001207 reply.writeTypedArray(res, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001208 return true;
1209 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07001210
1211 case KILL_APPLICATION_PROCESS_TRANSACTION: {
1212 data.enforceInterface(IActivityManager.descriptor);
1213 String processName = data.readString();
1214 int uid = data.readInt();
1215 killApplicationProcess(processName, uid);
1216 reply.writeNoException();
1217 return true;
1218 }
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001219
1220 case OVERRIDE_PENDING_TRANSITION_TRANSACTION: {
1221 data.enforceInterface(IActivityManager.descriptor);
1222 IBinder token = data.readStrongBinder();
1223 String packageName = data.readString();
1224 int enterAnim = data.readInt();
1225 int exitAnim = data.readInt();
1226 overridePendingTransition(token, packageName, enterAnim, exitAnim);
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08001227 reply.writeNoException();
1228 return true;
1229 }
1230
1231 case IS_USER_A_MONKEY_TRANSACTION: {
1232 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn7e269642010-08-25 19:50:20 -07001233 boolean areThey = isUserAMonkey();
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08001234 reply.writeNoException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001235 reply.writeInt(areThey ? 1 : 0);
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001236 return true;
1237 }
Dianne Hackborn860755f2010-06-03 18:47:52 -07001238
1239 case FINISH_HEAVY_WEIGHT_APP_TRANSACTION: {
1240 data.enforceInterface(IActivityManager.descriptor);
1241 finishHeavyWeightApp();
1242 reply.writeNoException();
1243 return true;
1244 }
Daniel Sandler69a48172010-06-23 16:29:36 -04001245
1246 case IS_IMMERSIVE_TRANSACTION: {
1247 data.enforceInterface(IActivityManager.descriptor);
1248 IBinder token = data.readStrongBinder();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001249 boolean isit = isImmersive(token);
Daniel Sandler69a48172010-06-23 16:29:36 -04001250 reply.writeNoException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001251 reply.writeInt(isit ? 1 : 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04001252 return true;
1253 }
1254
1255 case SET_IMMERSIVE_TRANSACTION: {
1256 data.enforceInterface(IActivityManager.descriptor);
1257 IBinder token = data.readStrongBinder();
1258 boolean imm = data.readInt() == 1;
1259 setImmersive(token, imm);
1260 reply.writeNoException();
1261 return true;
1262 }
1263
1264 case IS_TOP_ACTIVITY_IMMERSIVE_TRANSACTION: {
1265 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn7e269642010-08-25 19:50:20 -07001266 boolean isit = isTopActivityImmersive();
Daniel Sandler69a48172010-06-23 16:29:36 -04001267 reply.writeNoException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001268 reply.writeInt(isit ? 1 : 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04001269 return true;
1270 }
1271
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07001272 case CRASH_APPLICATION_TRANSACTION: {
1273 data.enforceInterface(IActivityManager.descriptor);
1274 int uid = data.readInt();
1275 int initialPid = data.readInt();
1276 String packageName = data.readString();
1277 String message = data.readString();
1278 crashApplication(uid, initialPid, packageName, message);
1279 reply.writeNoException();
1280 return true;
1281 }
Dianne Hackborncca1f0e2010-09-26 18:34:53 -07001282
1283 case GET_PROVIDER_MIME_TYPE_TRANSACTION: {
1284 data.enforceInterface(IActivityManager.descriptor);
1285 Uri uri = Uri.CREATOR.createFromParcel(data);
1286 String type = getProviderMimeType(uri);
1287 reply.writeNoException();
1288 reply.writeString(type);
1289 return true;
1290 }
1291
Dianne Hackborn7e269642010-08-25 19:50:20 -07001292 case NEW_URI_PERMISSION_OWNER_TRANSACTION: {
1293 data.enforceInterface(IActivityManager.descriptor);
1294 String name = data.readString();
1295 IBinder perm = newUriPermissionOwner(name);
1296 reply.writeNoException();
1297 reply.writeStrongBinder(perm);
1298 return true;
1299 }
1300
1301 case GRANT_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1302 data.enforceInterface(IActivityManager.descriptor);
1303 IBinder owner = data.readStrongBinder();
1304 int fromUid = data.readInt();
1305 String targetPkg = data.readString();
1306 Uri uri = Uri.CREATOR.createFromParcel(data);
1307 int mode = data.readInt();
1308 grantUriPermissionFromOwner(owner, fromUid, targetPkg, uri, mode);
1309 reply.writeNoException();
1310 return true;
1311 }
1312
1313 case REVOKE_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1314 data.enforceInterface(IActivityManager.descriptor);
1315 IBinder owner = data.readStrongBinder();
1316 Uri uri = null;
1317 if (data.readInt() != 0) {
1318 Uri.CREATOR.createFromParcel(data);
1319 }
1320 int mode = data.readInt();
1321 revokeUriPermissionFromOwner(owner, uri, mode);
1322 reply.writeNoException();
1323 return true;
1324 }
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07001325
Dianne Hackborn90f4aaf2010-09-27 14:58:44 -07001326 case CHECK_GRANT_URI_PERMISSION_TRANSACTION: {
1327 data.enforceInterface(IActivityManager.descriptor);
1328 int callingUid = data.readInt();
1329 String targetPkg = data.readString();
1330 Uri uri = Uri.CREATOR.createFromParcel(data);
1331 int modeFlags = data.readInt();
1332 int res = checkGrantUriPermission(callingUid, targetPkg, uri, modeFlags);
1333 reply.writeNoException();
1334 reply.writeInt(res);
1335 return true;
1336 }
1337
Andy McFadden824c5102010-07-09 16:26:57 -07001338 case DUMP_HEAP_TRANSACTION: {
1339 data.enforceInterface(IActivityManager.descriptor);
1340 String process = data.readString();
1341 boolean managed = data.readInt() != 0;
1342 String path = data.readString();
1343 ParcelFileDescriptor fd = data.readInt() != 0
1344 ? data.readFileDescriptor() : null;
1345 boolean res = dumpHeap(process, managed, path, fd);
1346 reply.writeNoException();
1347 reply.writeInt(res ? 1 : 0);
1348 return true;
1349 }
1350
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001351 case START_ACTIVITIES_IN_PACKAGE_TRANSACTION:
1352 {
1353 data.enforceInterface(IActivityManager.descriptor);
1354 int uid = data.readInt();
1355 Intent[] intents = data.createTypedArray(Intent.CREATOR);
1356 String[] resolvedTypes = data.createStringArray();
1357 IBinder resultTo = data.readStrongBinder();
1358 int result = startActivitiesInPackage(uid, intents, resolvedTypes, resultTo);
1359 reply.writeNoException();
1360 reply.writeInt(result);
1361 return true;
1362 }
1363
1364 case START_ACTIVITIES_TRANSACTION:
1365 {
1366 data.enforceInterface(IActivityManager.descriptor);
1367 IBinder b = data.readStrongBinder();
1368 IApplicationThread app = ApplicationThreadNative.asInterface(b);
1369 Intent[] intents = data.createTypedArray(Intent.CREATOR);
1370 String[] resolvedTypes = data.createStringArray();
1371 IBinder resultTo = data.readStrongBinder();
1372 int result = startActivities(app, intents, resolvedTypes, resultTo);
1373 reply.writeNoException();
1374 reply.writeInt(result);
1375 return true;
1376 }
1377
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001378 }
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -08001379
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001380 return super.onTransact(code, data, reply, flags);
1381 }
1382
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -08001383 public IBinder asBinder() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001384 return this;
1385 }
1386
Brad Fitzpatrick663f4f32010-11-23 19:15:24 -08001387 private static final Singleton<IActivityManager> gDefault = new Singleton<IActivityManager>() {
1388 protected IActivityManager create() {
1389 IBinder b = ServiceManager.getService("activity");
1390 if (Config.LOGV) {
1391 Log.v("ActivityManager", "default service binder = " + b);
1392 }
1393 IActivityManager am = asInterface(b);
1394 if (Config.LOGV) {
1395 Log.v("ActivityManager", "default service = " + am);
1396 }
1397 return am;
1398 }
1399 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001400}
1401
1402class ActivityManagerProxy implements IActivityManager
1403{
1404 public ActivityManagerProxy(IBinder remote)
1405 {
1406 mRemote = remote;
1407 }
1408
1409 public IBinder asBinder()
1410 {
1411 return mRemote;
1412 }
1413
1414 public int startActivity(IApplicationThread caller, Intent intent,
1415 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1416 IBinder resultTo, String resultWho,
1417 int requestCode, boolean onlyIfNeeded,
1418 boolean debug) throws RemoteException {
1419 Parcel data = Parcel.obtain();
1420 Parcel reply = Parcel.obtain();
1421 data.writeInterfaceToken(IActivityManager.descriptor);
1422 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1423 intent.writeToParcel(data, 0);
1424 data.writeString(resolvedType);
1425 data.writeTypedArray(grantedUriPermissions, 0);
1426 data.writeInt(grantedMode);
1427 data.writeStrongBinder(resultTo);
1428 data.writeString(resultWho);
1429 data.writeInt(requestCode);
1430 data.writeInt(onlyIfNeeded ? 1 : 0);
1431 data.writeInt(debug ? 1 : 0);
1432 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1433 reply.readException();
1434 int result = reply.readInt();
1435 reply.recycle();
1436 data.recycle();
1437 return result;
1438 }
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -08001439 public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
1440 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1441 IBinder resultTo, String resultWho,
1442 int requestCode, boolean onlyIfNeeded,
1443 boolean debug) throws RemoteException {
1444 Parcel data = Parcel.obtain();
1445 Parcel reply = Parcel.obtain();
1446 data.writeInterfaceToken(IActivityManager.descriptor);
1447 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1448 intent.writeToParcel(data, 0);
1449 data.writeString(resolvedType);
1450 data.writeTypedArray(grantedUriPermissions, 0);
1451 data.writeInt(grantedMode);
1452 data.writeStrongBinder(resultTo);
1453 data.writeString(resultWho);
1454 data.writeInt(requestCode);
1455 data.writeInt(onlyIfNeeded ? 1 : 0);
1456 data.writeInt(debug ? 1 : 0);
1457 mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
1458 reply.readException();
1459 WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
1460 reply.recycle();
1461 data.recycle();
1462 return result;
1463 }
Dianne Hackborn2ccda4d2010-03-22 21:49:15 -07001464 public int startActivityWithConfig(IApplicationThread caller, Intent intent,
1465 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1466 IBinder resultTo, String resultWho,
1467 int requestCode, boolean onlyIfNeeded,
1468 boolean debug, Configuration config) throws RemoteException {
1469 Parcel data = Parcel.obtain();
1470 Parcel reply = Parcel.obtain();
1471 data.writeInterfaceToken(IActivityManager.descriptor);
1472 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1473 intent.writeToParcel(data, 0);
1474 data.writeString(resolvedType);
1475 data.writeTypedArray(grantedUriPermissions, 0);
1476 data.writeInt(grantedMode);
1477 data.writeStrongBinder(resultTo);
1478 data.writeString(resultWho);
1479 data.writeInt(requestCode);
1480 data.writeInt(onlyIfNeeded ? 1 : 0);
1481 data.writeInt(debug ? 1 : 0);
1482 config.writeToParcel(data, 0);
1483 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1484 reply.readException();
1485 int result = reply.readInt();
1486 reply.recycle();
1487 data.recycle();
1488 return result;
1489 }
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001490 public int startActivityIntentSender(IApplicationThread caller,
1491 IntentSender intent, Intent fillInIntent, String resolvedType,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001492 IBinder resultTo, String resultWho, int requestCode,
1493 int flagsMask, int flagsValues) throws RemoteException {
1494 Parcel data = Parcel.obtain();
1495 Parcel reply = Parcel.obtain();
1496 data.writeInterfaceToken(IActivityManager.descriptor);
1497 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1498 intent.writeToParcel(data, 0);
1499 if (fillInIntent != null) {
1500 data.writeInt(1);
1501 fillInIntent.writeToParcel(data, 0);
1502 } else {
1503 data.writeInt(0);
1504 }
1505 data.writeString(resolvedType);
1506 data.writeStrongBinder(resultTo);
1507 data.writeString(resultWho);
1508 data.writeInt(requestCode);
1509 data.writeInt(flagsMask);
1510 data.writeInt(flagsValues);
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001511 mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001512 reply.readException();
1513 int result = reply.readInt();
1514 reply.recycle();
1515 data.recycle();
1516 return result;
1517 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001518 public boolean startNextMatchingActivity(IBinder callingActivity,
1519 Intent intent) throws RemoteException {
1520 Parcel data = Parcel.obtain();
1521 Parcel reply = Parcel.obtain();
1522 data.writeInterfaceToken(IActivityManager.descriptor);
1523 data.writeStrongBinder(callingActivity);
1524 intent.writeToParcel(data, 0);
1525 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1526 reply.readException();
1527 int result = reply.readInt();
1528 reply.recycle();
1529 data.recycle();
1530 return result != 0;
1531 }
1532 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1533 throws RemoteException {
1534 Parcel data = Parcel.obtain();
1535 Parcel reply = Parcel.obtain();
1536 data.writeInterfaceToken(IActivityManager.descriptor);
1537 data.writeStrongBinder(token);
1538 data.writeInt(resultCode);
1539 if (resultData != null) {
1540 data.writeInt(1);
1541 resultData.writeToParcel(data, 0);
1542 } else {
1543 data.writeInt(0);
1544 }
1545 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1546 reply.readException();
1547 boolean res = reply.readInt() != 0;
1548 data.recycle();
1549 reply.recycle();
1550 return res;
1551 }
1552 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1553 {
1554 Parcel data = Parcel.obtain();
1555 Parcel reply = Parcel.obtain();
1556 data.writeInterfaceToken(IActivityManager.descriptor);
1557 data.writeStrongBinder(token);
1558 data.writeString(resultWho);
1559 data.writeInt(requestCode);
1560 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1561 reply.readException();
1562 data.recycle();
1563 reply.recycle();
1564 }
Dianne Hackborn061d58a2010-03-12 15:07:06 -08001565 public boolean willActivityBeVisible(IBinder token) throws RemoteException {
1566 Parcel data = Parcel.obtain();
1567 Parcel reply = Parcel.obtain();
1568 data.writeInterfaceToken(IActivityManager.descriptor);
1569 data.writeStrongBinder(token);
1570 mRemote.transact(WILL_ACTIVITY_BE_VISIBLE_TRANSACTION, data, reply, 0);
1571 reply.readException();
1572 boolean res = reply.readInt() != 0;
1573 data.recycle();
1574 reply.recycle();
1575 return res;
1576 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001577 public Intent registerReceiver(IApplicationThread caller,
1578 IIntentReceiver receiver,
1579 IntentFilter filter, String perm) throws RemoteException
1580 {
1581 Parcel data = Parcel.obtain();
1582 Parcel reply = Parcel.obtain();
1583 data.writeInterfaceToken(IActivityManager.descriptor);
1584 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1585 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1586 filter.writeToParcel(data, 0);
1587 data.writeString(perm);
1588 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1589 reply.readException();
1590 Intent intent = null;
1591 int haveIntent = reply.readInt();
1592 if (haveIntent != 0) {
1593 intent = Intent.CREATOR.createFromParcel(reply);
1594 }
1595 reply.recycle();
1596 data.recycle();
1597 return intent;
1598 }
1599 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1600 {
1601 Parcel data = Parcel.obtain();
1602 Parcel reply = Parcel.obtain();
1603 data.writeInterfaceToken(IActivityManager.descriptor);
1604 data.writeStrongBinder(receiver.asBinder());
1605 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1606 reply.readException();
1607 data.recycle();
1608 reply.recycle();
1609 }
1610 public int broadcastIntent(IApplicationThread caller,
1611 Intent intent, String resolvedType, IIntentReceiver resultTo,
1612 int resultCode, String resultData, Bundle map,
1613 String requiredPermission, boolean serialized,
1614 boolean sticky) throws RemoteException
1615 {
1616 Parcel data = Parcel.obtain();
1617 Parcel reply = Parcel.obtain();
1618 data.writeInterfaceToken(IActivityManager.descriptor);
1619 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1620 intent.writeToParcel(data, 0);
1621 data.writeString(resolvedType);
1622 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1623 data.writeInt(resultCode);
1624 data.writeString(resultData);
1625 data.writeBundle(map);
1626 data.writeString(requiredPermission);
1627 data.writeInt(serialized ? 1 : 0);
1628 data.writeInt(sticky ? 1 : 0);
1629 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1630 reply.readException();
1631 int res = reply.readInt();
1632 reply.recycle();
1633 data.recycle();
1634 return res;
1635 }
1636 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1637 {
1638 Parcel data = Parcel.obtain();
1639 Parcel reply = Parcel.obtain();
1640 data.writeInterfaceToken(IActivityManager.descriptor);
1641 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1642 intent.writeToParcel(data, 0);
1643 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1644 reply.readException();
1645 data.recycle();
1646 reply.recycle();
1647 }
1648 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1649 {
1650 Parcel data = Parcel.obtain();
1651 Parcel reply = Parcel.obtain();
1652 data.writeInterfaceToken(IActivityManager.descriptor);
1653 data.writeStrongBinder(who);
1654 data.writeInt(resultCode);
1655 data.writeString(resultData);
1656 data.writeBundle(map);
1657 data.writeInt(abortBroadcast ? 1 : 0);
1658 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1659 reply.readException();
1660 data.recycle();
1661 reply.recycle();
1662 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001663 public void attachApplication(IApplicationThread app) throws RemoteException
1664 {
1665 Parcel data = Parcel.obtain();
1666 Parcel reply = Parcel.obtain();
1667 data.writeInterfaceToken(IActivityManager.descriptor);
1668 data.writeStrongBinder(app.asBinder());
1669 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1670 reply.readException();
1671 data.recycle();
1672 reply.recycle();
1673 }
Dianne Hackborne88846e2009-09-30 21:34:25 -07001674 public void activityIdle(IBinder token, Configuration config) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001675 {
1676 Parcel data = Parcel.obtain();
1677 Parcel reply = Parcel.obtain();
1678 data.writeInterfaceToken(IActivityManager.descriptor);
1679 data.writeStrongBinder(token);
Dianne Hackborne88846e2009-09-30 21:34:25 -07001680 if (config != null) {
1681 data.writeInt(1);
1682 config.writeToParcel(data, 0);
1683 } else {
1684 data.writeInt(0);
1685 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001686 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1687 reply.readException();
1688 data.recycle();
1689 reply.recycle();
1690 }
1691 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1692 {
1693 Parcel data = Parcel.obtain();
1694 Parcel reply = Parcel.obtain();
1695 data.writeInterfaceToken(IActivityManager.descriptor);
1696 data.writeStrongBinder(token);
1697 data.writeBundle(state);
1698 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1699 reply.readException();
1700 data.recycle();
1701 reply.recycle();
1702 }
1703 public void activityStopped(IBinder token,
1704 Bitmap thumbnail, CharSequence description) throws RemoteException
1705 {
1706 Parcel data = Parcel.obtain();
1707 Parcel reply = Parcel.obtain();
1708 data.writeInterfaceToken(IActivityManager.descriptor);
1709 data.writeStrongBinder(token);
1710 if (thumbnail != null) {
1711 data.writeInt(1);
1712 thumbnail.writeToParcel(data, 0);
1713 } else {
1714 data.writeInt(0);
1715 }
1716 TextUtils.writeToParcel(description, data, 0);
1717 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1718 reply.readException();
1719 data.recycle();
1720 reply.recycle();
1721 }
1722 public void activityDestroyed(IBinder token) throws RemoteException
1723 {
1724 Parcel data = Parcel.obtain();
1725 Parcel reply = Parcel.obtain();
1726 data.writeInterfaceToken(IActivityManager.descriptor);
1727 data.writeStrongBinder(token);
1728 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1729 reply.readException();
1730 data.recycle();
1731 reply.recycle();
1732 }
1733 public String getCallingPackage(IBinder token) throws RemoteException
1734 {
1735 Parcel data = Parcel.obtain();
1736 Parcel reply = Parcel.obtain();
1737 data.writeInterfaceToken(IActivityManager.descriptor);
1738 data.writeStrongBinder(token);
1739 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1740 reply.readException();
1741 String res = reply.readString();
1742 data.recycle();
1743 reply.recycle();
1744 return res;
1745 }
1746 public ComponentName getCallingActivity(IBinder token)
1747 throws RemoteException {
1748 Parcel data = Parcel.obtain();
1749 Parcel reply = Parcel.obtain();
1750 data.writeInterfaceToken(IActivityManager.descriptor);
1751 data.writeStrongBinder(token);
1752 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1753 reply.readException();
1754 ComponentName res = ComponentName.readFromParcel(reply);
1755 data.recycle();
1756 reply.recycle();
1757 return res;
1758 }
1759 public List getTasks(int maxNum, int flags,
1760 IThumbnailReceiver receiver) throws RemoteException {
1761 Parcel data = Parcel.obtain();
1762 Parcel reply = Parcel.obtain();
1763 data.writeInterfaceToken(IActivityManager.descriptor);
1764 data.writeInt(maxNum);
1765 data.writeInt(flags);
1766 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1767 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1768 reply.readException();
1769 ArrayList list = null;
1770 int N = reply.readInt();
1771 if (N >= 0) {
1772 list = new ArrayList();
1773 while (N > 0) {
1774 ActivityManager.RunningTaskInfo info =
1775 ActivityManager.RunningTaskInfo.CREATOR
1776 .createFromParcel(reply);
1777 list.add(info);
1778 N--;
1779 }
1780 }
1781 data.recycle();
1782 reply.recycle();
1783 return list;
1784 }
1785 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1786 int flags) throws RemoteException {
1787 Parcel data = Parcel.obtain();
1788 Parcel reply = Parcel.obtain();
1789 data.writeInterfaceToken(IActivityManager.descriptor);
1790 data.writeInt(maxNum);
1791 data.writeInt(flags);
1792 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1793 reply.readException();
1794 ArrayList<ActivityManager.RecentTaskInfo> list
1795 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1796 data.recycle();
1797 reply.recycle();
1798 return list;
1799 }
1800 public List getServices(int maxNum, int flags) throws RemoteException {
1801 Parcel data = Parcel.obtain();
1802 Parcel reply = Parcel.obtain();
1803 data.writeInterfaceToken(IActivityManager.descriptor);
1804 data.writeInt(maxNum);
1805 data.writeInt(flags);
1806 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1807 reply.readException();
1808 ArrayList list = null;
1809 int N = reply.readInt();
1810 if (N >= 0) {
1811 list = new ArrayList();
1812 while (N > 0) {
1813 ActivityManager.RunningServiceInfo info =
1814 ActivityManager.RunningServiceInfo.CREATOR
1815 .createFromParcel(reply);
1816 list.add(info);
1817 N--;
1818 }
1819 }
1820 data.recycle();
1821 reply.recycle();
1822 return list;
1823 }
1824 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1825 throws RemoteException {
1826 Parcel data = Parcel.obtain();
1827 Parcel reply = Parcel.obtain();
1828 data.writeInterfaceToken(IActivityManager.descriptor);
1829 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1830 reply.readException();
1831 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1832 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1833 data.recycle();
1834 reply.recycle();
1835 return list;
1836 }
1837 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1838 throws RemoteException {
1839 Parcel data = Parcel.obtain();
1840 Parcel reply = Parcel.obtain();
1841 data.writeInterfaceToken(IActivityManager.descriptor);
1842 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1843 reply.readException();
1844 ArrayList<ActivityManager.RunningAppProcessInfo> list
1845 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1846 data.recycle();
1847 reply.recycle();
1848 return list;
1849 }
Suchi Amalapurapuf7f5dda2010-03-23 10:34:28 -07001850 public List<ApplicationInfo> getRunningExternalApplications()
1851 throws RemoteException {
1852 Parcel data = Parcel.obtain();
1853 Parcel reply = Parcel.obtain();
1854 data.writeInterfaceToken(IActivityManager.descriptor);
1855 mRemote.transact(GET_RUNNING_EXTERNAL_APPLICATIONS_TRANSACTION, data, reply, 0);
1856 reply.readException();
1857 ArrayList<ApplicationInfo> list
1858 = reply.createTypedArrayList(ApplicationInfo.CREATOR);
1859 data.recycle();
1860 reply.recycle();
1861 return list;
1862 }
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001863 public void moveTaskToFront(int task, int flags) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001864 {
1865 Parcel data = Parcel.obtain();
1866 Parcel reply = Parcel.obtain();
1867 data.writeInterfaceToken(IActivityManager.descriptor);
1868 data.writeInt(task);
Dianne Hackborn621e17d2010-11-22 15:59:56 -08001869 data.writeInt(flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001870 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1871 reply.readException();
1872 data.recycle();
1873 reply.recycle();
1874 }
1875 public void moveTaskToBack(int task) throws RemoteException
1876 {
1877 Parcel data = Parcel.obtain();
1878 Parcel reply = Parcel.obtain();
1879 data.writeInterfaceToken(IActivityManager.descriptor);
1880 data.writeInt(task);
1881 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1882 reply.readException();
1883 data.recycle();
1884 reply.recycle();
1885 }
1886 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1887 throws RemoteException {
1888 Parcel data = Parcel.obtain();
1889 Parcel reply = Parcel.obtain();
1890 data.writeInterfaceToken(IActivityManager.descriptor);
1891 data.writeStrongBinder(token);
1892 data.writeInt(nonRoot ? 1 : 0);
1893 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1894 reply.readException();
1895 boolean res = reply.readInt() != 0;
1896 data.recycle();
1897 reply.recycle();
1898 return res;
1899 }
1900 public void moveTaskBackwards(int task) throws RemoteException
1901 {
1902 Parcel data = Parcel.obtain();
1903 Parcel reply = Parcel.obtain();
1904 data.writeInterfaceToken(IActivityManager.descriptor);
1905 data.writeInt(task);
1906 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1907 reply.readException();
1908 data.recycle();
1909 reply.recycle();
1910 }
1911 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1912 {
1913 Parcel data = Parcel.obtain();
1914 Parcel reply = Parcel.obtain();
1915 data.writeInterfaceToken(IActivityManager.descriptor);
1916 data.writeStrongBinder(token);
1917 data.writeInt(onlyRoot ? 1 : 0);
1918 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1919 reply.readException();
1920 int res = reply.readInt();
1921 data.recycle();
1922 reply.recycle();
1923 return res;
1924 }
1925 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1926 {
1927 Parcel data = Parcel.obtain();
1928 Parcel reply = Parcel.obtain();
1929 data.writeInterfaceToken(IActivityManager.descriptor);
1930 data.writeStrongBinder(token);
1931 ComponentName.writeToParcel(className, data);
1932 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1933 reply.readException();
1934 data.recycle();
1935 reply.recycle();
1936 }
1937 public void reportThumbnail(IBinder token,
1938 Bitmap thumbnail, CharSequence description) throws RemoteException
1939 {
1940 Parcel data = Parcel.obtain();
1941 Parcel reply = Parcel.obtain();
1942 data.writeInterfaceToken(IActivityManager.descriptor);
1943 data.writeStrongBinder(token);
1944 if (thumbnail != null) {
1945 data.writeInt(1);
1946 thumbnail.writeToParcel(data, 0);
1947 } else {
1948 data.writeInt(0);
1949 }
1950 TextUtils.writeToParcel(description, data, 0);
1951 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1952 reply.readException();
1953 data.recycle();
1954 reply.recycle();
1955 }
1956 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1957 String name) throws RemoteException
1958 {
1959 Parcel data = Parcel.obtain();
1960 Parcel reply = Parcel.obtain();
1961 data.writeInterfaceToken(IActivityManager.descriptor);
1962 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1963 data.writeString(name);
1964 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1965 reply.readException();
1966 int res = reply.readInt();
1967 ContentProviderHolder cph = null;
1968 if (res != 0) {
1969 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1970 }
1971 data.recycle();
1972 reply.recycle();
1973 return cph;
1974 }
1975 public void publishContentProviders(IApplicationThread caller,
1976 List<ContentProviderHolder> providers) throws RemoteException
1977 {
1978 Parcel data = Parcel.obtain();
1979 Parcel reply = Parcel.obtain();
1980 data.writeInterfaceToken(IActivityManager.descriptor);
1981 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1982 data.writeTypedList(providers);
1983 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1984 reply.readException();
1985 data.recycle();
1986 reply.recycle();
1987 }
1988
1989 public void removeContentProvider(IApplicationThread caller,
1990 String name) throws RemoteException {
1991 Parcel data = Parcel.obtain();
1992 Parcel reply = Parcel.obtain();
1993 data.writeInterfaceToken(IActivityManager.descriptor);
1994 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1995 data.writeString(name);
1996 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1997 reply.readException();
1998 data.recycle();
1999 reply.recycle();
2000 }
2001
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002002 public PendingIntent getRunningServiceControlPanel(ComponentName service)
2003 throws RemoteException
2004 {
2005 Parcel data = Parcel.obtain();
2006 Parcel reply = Parcel.obtain();
2007 data.writeInterfaceToken(IActivityManager.descriptor);
2008 service.writeToParcel(data, 0);
2009 mRemote.transact(GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION, data, reply, 0);
2010 reply.readException();
2011 PendingIntent res = PendingIntent.readPendingIntentOrNullFromParcel(reply);
2012 data.recycle();
2013 reply.recycle();
2014 return res;
2015 }
2016
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002017 public ComponentName startService(IApplicationThread caller, Intent service,
2018 String resolvedType) throws RemoteException
2019 {
2020 Parcel data = Parcel.obtain();
2021 Parcel reply = Parcel.obtain();
2022 data.writeInterfaceToken(IActivityManager.descriptor);
2023 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2024 service.writeToParcel(data, 0);
2025 data.writeString(resolvedType);
2026 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
2027 reply.readException();
2028 ComponentName res = ComponentName.readFromParcel(reply);
2029 data.recycle();
2030 reply.recycle();
2031 return res;
2032 }
2033 public int stopService(IApplicationThread caller, Intent service,
2034 String resolvedType) throws RemoteException
2035 {
2036 Parcel data = Parcel.obtain();
2037 Parcel reply = Parcel.obtain();
2038 data.writeInterfaceToken(IActivityManager.descriptor);
2039 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2040 service.writeToParcel(data, 0);
2041 data.writeString(resolvedType);
2042 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
2043 reply.readException();
2044 int res = reply.readInt();
2045 reply.recycle();
2046 data.recycle();
2047 return res;
2048 }
2049 public boolean stopServiceToken(ComponentName className, IBinder token,
2050 int startId) throws RemoteException {
2051 Parcel data = Parcel.obtain();
2052 Parcel reply = Parcel.obtain();
2053 data.writeInterfaceToken(IActivityManager.descriptor);
2054 ComponentName.writeToParcel(className, data);
2055 data.writeStrongBinder(token);
2056 data.writeInt(startId);
2057 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
2058 reply.readException();
2059 boolean res = reply.readInt() != 0;
2060 data.recycle();
2061 reply.recycle();
2062 return res;
2063 }
2064 public void setServiceForeground(ComponentName className, IBinder token,
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07002065 int id, Notification notification, boolean removeNotification) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002066 Parcel data = Parcel.obtain();
2067 Parcel reply = Parcel.obtain();
2068 data.writeInterfaceToken(IActivityManager.descriptor);
2069 ComponentName.writeToParcel(className, data);
2070 data.writeStrongBinder(token);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07002071 data.writeInt(id);
2072 if (notification != null) {
2073 data.writeInt(1);
2074 notification.writeToParcel(data, 0);
2075 } else {
2076 data.writeInt(0);
2077 }
2078 data.writeInt(removeNotification ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002079 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
2080 reply.readException();
2081 data.recycle();
2082 reply.recycle();
2083 }
2084 public int bindService(IApplicationThread caller, IBinder token,
2085 Intent service, String resolvedType, IServiceConnection connection,
2086 int flags) throws RemoteException {
2087 Parcel data = Parcel.obtain();
2088 Parcel reply = Parcel.obtain();
2089 data.writeInterfaceToken(IActivityManager.descriptor);
2090 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2091 data.writeStrongBinder(token);
2092 service.writeToParcel(data, 0);
2093 data.writeString(resolvedType);
2094 data.writeStrongBinder(connection.asBinder());
2095 data.writeInt(flags);
2096 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
2097 reply.readException();
2098 int res = reply.readInt();
2099 data.recycle();
2100 reply.recycle();
2101 return res;
2102 }
2103 public boolean unbindService(IServiceConnection connection) throws RemoteException
2104 {
2105 Parcel data = Parcel.obtain();
2106 Parcel reply = Parcel.obtain();
2107 data.writeInterfaceToken(IActivityManager.descriptor);
2108 data.writeStrongBinder(connection.asBinder());
2109 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
2110 reply.readException();
2111 boolean res = reply.readInt() != 0;
2112 data.recycle();
2113 reply.recycle();
2114 return res;
2115 }
2116
2117 public void publishService(IBinder token,
2118 Intent intent, IBinder service) throws RemoteException {
2119 Parcel data = Parcel.obtain();
2120 Parcel reply = Parcel.obtain();
2121 data.writeInterfaceToken(IActivityManager.descriptor);
2122 data.writeStrongBinder(token);
2123 intent.writeToParcel(data, 0);
2124 data.writeStrongBinder(service);
2125 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
2126 reply.readException();
2127 data.recycle();
2128 reply.recycle();
2129 }
2130
2131 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
2132 throws RemoteException {
2133 Parcel data = Parcel.obtain();
2134 Parcel reply = Parcel.obtain();
2135 data.writeInterfaceToken(IActivityManager.descriptor);
2136 data.writeStrongBinder(token);
2137 intent.writeToParcel(data, 0);
2138 data.writeInt(doRebind ? 1 : 0);
2139 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
2140 reply.readException();
2141 data.recycle();
2142 reply.recycle();
2143 }
2144
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07002145 public void serviceDoneExecuting(IBinder token, int type, int startId,
2146 int res) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002147 Parcel data = Parcel.obtain();
2148 Parcel reply = Parcel.obtain();
2149 data.writeInterfaceToken(IActivityManager.descriptor);
2150 data.writeStrongBinder(token);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07002151 data.writeInt(type);
2152 data.writeInt(startId);
2153 data.writeInt(res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002154 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2155 reply.readException();
2156 data.recycle();
2157 reply.recycle();
2158 }
2159
2160 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
2161 Parcel data = Parcel.obtain();
2162 Parcel reply = Parcel.obtain();
2163 data.writeInterfaceToken(IActivityManager.descriptor);
2164 service.writeToParcel(data, 0);
2165 data.writeString(resolvedType);
2166 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
2167 reply.readException();
2168 IBinder binder = reply.readStrongBinder();
2169 reply.recycle();
2170 data.recycle();
2171 return binder;
2172 }
2173
Christopher Tate181fafa2009-05-14 11:12:14 -07002174 public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
2175 throws RemoteException {
2176 Parcel data = Parcel.obtain();
2177 Parcel reply = Parcel.obtain();
2178 data.writeInterfaceToken(IActivityManager.descriptor);
2179 app.writeToParcel(data, 0);
2180 data.writeInt(backupRestoreMode);
2181 mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2182 reply.readException();
2183 boolean success = reply.readInt() != 0;
2184 reply.recycle();
2185 data.recycle();
2186 return success;
2187 }
2188
2189 public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException {
2190 Parcel data = Parcel.obtain();
2191 Parcel reply = Parcel.obtain();
2192 data.writeInterfaceToken(IActivityManager.descriptor);
2193 data.writeString(packageName);
2194 data.writeStrongBinder(agent);
2195 mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0);
2196 reply.recycle();
2197 data.recycle();
2198 }
2199
2200 public void unbindBackupAgent(ApplicationInfo app) throws RemoteException {
2201 Parcel data = Parcel.obtain();
2202 Parcel reply = Parcel.obtain();
2203 data.writeInterfaceToken(IActivityManager.descriptor);
2204 app.writeToParcel(data, 0);
2205 mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2206 reply.readException();
2207 reply.recycle();
2208 data.recycle();
2209 }
2210
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002211 public boolean startInstrumentation(ComponentName className, String profileFile,
2212 int flags, Bundle arguments, IInstrumentationWatcher watcher)
2213 throws RemoteException {
2214 Parcel data = Parcel.obtain();
2215 Parcel reply = Parcel.obtain();
2216 data.writeInterfaceToken(IActivityManager.descriptor);
2217 ComponentName.writeToParcel(className, data);
2218 data.writeString(profileFile);
2219 data.writeInt(flags);
2220 data.writeBundle(arguments);
2221 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2222 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2223 reply.readException();
2224 boolean res = reply.readInt() != 0;
2225 reply.recycle();
2226 data.recycle();
2227 return res;
2228 }
2229
2230 public void finishInstrumentation(IApplicationThread target,
2231 int resultCode, Bundle results) throws RemoteException {
2232 Parcel data = Parcel.obtain();
2233 Parcel reply = Parcel.obtain();
2234 data.writeInterfaceToken(IActivityManager.descriptor);
2235 data.writeStrongBinder(target != null ? target.asBinder() : null);
2236 data.writeInt(resultCode);
2237 data.writeBundle(results);
2238 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2239 reply.readException();
2240 data.recycle();
2241 reply.recycle();
2242 }
2243 public Configuration getConfiguration() throws RemoteException
2244 {
2245 Parcel data = Parcel.obtain();
2246 Parcel reply = Parcel.obtain();
2247 data.writeInterfaceToken(IActivityManager.descriptor);
2248 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
2249 reply.readException();
2250 Configuration res = Configuration.CREATOR.createFromParcel(reply);
2251 reply.recycle();
2252 data.recycle();
2253 return res;
2254 }
2255 public void updateConfiguration(Configuration values) throws RemoteException
2256 {
2257 Parcel data = Parcel.obtain();
2258 Parcel reply = Parcel.obtain();
2259 data.writeInterfaceToken(IActivityManager.descriptor);
2260 values.writeToParcel(data, 0);
2261 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
2262 reply.readException();
2263 data.recycle();
2264 reply.recycle();
2265 }
2266 public void setRequestedOrientation(IBinder token, int requestedOrientation)
2267 throws RemoteException {
2268 Parcel data = Parcel.obtain();
2269 Parcel reply = Parcel.obtain();
2270 data.writeInterfaceToken(IActivityManager.descriptor);
2271 data.writeStrongBinder(token);
2272 data.writeInt(requestedOrientation);
2273 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2274 reply.readException();
2275 data.recycle();
2276 reply.recycle();
2277 }
2278 public int getRequestedOrientation(IBinder token) throws RemoteException {
2279 Parcel data = Parcel.obtain();
2280 Parcel reply = Parcel.obtain();
2281 data.writeInterfaceToken(IActivityManager.descriptor);
2282 data.writeStrongBinder(token);
2283 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2284 reply.readException();
2285 int res = reply.readInt();
2286 data.recycle();
2287 reply.recycle();
2288 return res;
2289 }
2290 public ComponentName getActivityClassForToken(IBinder token)
2291 throws RemoteException {
2292 Parcel data = Parcel.obtain();
2293 Parcel reply = Parcel.obtain();
2294 data.writeInterfaceToken(IActivityManager.descriptor);
2295 data.writeStrongBinder(token);
2296 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
2297 reply.readException();
2298 ComponentName res = ComponentName.readFromParcel(reply);
2299 data.recycle();
2300 reply.recycle();
2301 return res;
2302 }
2303 public String getPackageForToken(IBinder token) throws RemoteException
2304 {
2305 Parcel data = Parcel.obtain();
2306 Parcel reply = Parcel.obtain();
2307 data.writeInterfaceToken(IActivityManager.descriptor);
2308 data.writeStrongBinder(token);
2309 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
2310 reply.readException();
2311 String res = reply.readString();
2312 data.recycle();
2313 reply.recycle();
2314 return res;
2315 }
2316 public IIntentSender getIntentSender(int type,
2317 String packageName, IBinder token, String resultWho,
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002318 int requestCode, Intent[] intents, String[] resolvedTypes, int flags)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002319 throws RemoteException {
2320 Parcel data = Parcel.obtain();
2321 Parcel reply = Parcel.obtain();
2322 data.writeInterfaceToken(IActivityManager.descriptor);
2323 data.writeInt(type);
2324 data.writeString(packageName);
2325 data.writeStrongBinder(token);
2326 data.writeString(resultWho);
2327 data.writeInt(requestCode);
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002328 if (intents != null) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002329 data.writeInt(1);
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002330 data.writeTypedArray(intents, 0);
2331 data.writeStringArray(resolvedTypes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002332 } else {
2333 data.writeInt(0);
2334 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002335 data.writeInt(flags);
2336 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
2337 reply.readException();
2338 IIntentSender res = IIntentSender.Stub.asInterface(
2339 reply.readStrongBinder());
2340 data.recycle();
2341 reply.recycle();
2342 return res;
2343 }
2344 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
2345 Parcel data = Parcel.obtain();
2346 Parcel reply = Parcel.obtain();
2347 data.writeInterfaceToken(IActivityManager.descriptor);
2348 data.writeStrongBinder(sender.asBinder());
2349 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
2350 reply.readException();
2351 data.recycle();
2352 reply.recycle();
2353 }
2354 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
2355 Parcel data = Parcel.obtain();
2356 Parcel reply = Parcel.obtain();
2357 data.writeInterfaceToken(IActivityManager.descriptor);
2358 data.writeStrongBinder(sender.asBinder());
2359 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
2360 reply.readException();
2361 String res = reply.readString();
2362 data.recycle();
2363 reply.recycle();
2364 return res;
2365 }
2366 public void setProcessLimit(int max) throws RemoteException
2367 {
2368 Parcel data = Parcel.obtain();
2369 Parcel reply = Parcel.obtain();
2370 data.writeInterfaceToken(IActivityManager.descriptor);
2371 data.writeInt(max);
2372 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2373 reply.readException();
2374 data.recycle();
2375 reply.recycle();
2376 }
2377 public int getProcessLimit() throws RemoteException
2378 {
2379 Parcel data = Parcel.obtain();
2380 Parcel reply = Parcel.obtain();
2381 data.writeInterfaceToken(IActivityManager.descriptor);
2382 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2383 reply.readException();
2384 int res = reply.readInt();
2385 data.recycle();
2386 reply.recycle();
2387 return res;
2388 }
2389 public void setProcessForeground(IBinder token, int pid,
2390 boolean isForeground) throws RemoteException {
2391 Parcel data = Parcel.obtain();
2392 Parcel reply = Parcel.obtain();
2393 data.writeInterfaceToken(IActivityManager.descriptor);
2394 data.writeStrongBinder(token);
2395 data.writeInt(pid);
2396 data.writeInt(isForeground ? 1 : 0);
2397 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
2398 reply.readException();
2399 data.recycle();
2400 reply.recycle();
2401 }
2402 public int checkPermission(String permission, int pid, int uid)
2403 throws RemoteException {
2404 Parcel data = Parcel.obtain();
2405 Parcel reply = Parcel.obtain();
2406 data.writeInterfaceToken(IActivityManager.descriptor);
2407 data.writeString(permission);
2408 data.writeInt(pid);
2409 data.writeInt(uid);
2410 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
2411 reply.readException();
2412 int res = reply.readInt();
2413 data.recycle();
2414 reply.recycle();
2415 return res;
2416 }
2417 public boolean clearApplicationUserData(final String packageName,
2418 final IPackageDataObserver observer) throws RemoteException {
2419 Parcel data = Parcel.obtain();
2420 Parcel reply = Parcel.obtain();
2421 data.writeInterfaceToken(IActivityManager.descriptor);
2422 data.writeString(packageName);
2423 data.writeStrongBinder(observer.asBinder());
2424 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
2425 reply.readException();
2426 boolean res = reply.readInt() != 0;
2427 data.recycle();
2428 reply.recycle();
2429 return res;
2430 }
2431 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
2432 throws RemoteException {
2433 Parcel data = Parcel.obtain();
2434 Parcel reply = Parcel.obtain();
2435 data.writeInterfaceToken(IActivityManager.descriptor);
2436 uri.writeToParcel(data, 0);
2437 data.writeInt(pid);
2438 data.writeInt(uid);
2439 data.writeInt(mode);
2440 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
2441 reply.readException();
2442 int res = reply.readInt();
2443 data.recycle();
2444 reply.recycle();
2445 return res;
2446 }
2447 public void grantUriPermission(IApplicationThread caller, String targetPkg,
2448 Uri uri, int mode) throws RemoteException {
2449 Parcel data = Parcel.obtain();
2450 Parcel reply = Parcel.obtain();
2451 data.writeInterfaceToken(IActivityManager.descriptor);
2452 data.writeStrongBinder(caller.asBinder());
2453 data.writeString(targetPkg);
2454 uri.writeToParcel(data, 0);
2455 data.writeInt(mode);
2456 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2457 reply.readException();
2458 data.recycle();
2459 reply.recycle();
2460 }
2461 public void revokeUriPermission(IApplicationThread caller, Uri uri,
2462 int mode) throws RemoteException {
2463 Parcel data = Parcel.obtain();
2464 Parcel reply = Parcel.obtain();
2465 data.writeInterfaceToken(IActivityManager.descriptor);
2466 data.writeStrongBinder(caller.asBinder());
2467 uri.writeToParcel(data, 0);
2468 data.writeInt(mode);
2469 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2470 reply.readException();
2471 data.recycle();
2472 reply.recycle();
2473 }
2474 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
2475 throws RemoteException {
2476 Parcel data = Parcel.obtain();
2477 Parcel reply = Parcel.obtain();
2478 data.writeInterfaceToken(IActivityManager.descriptor);
2479 data.writeStrongBinder(who.asBinder());
2480 data.writeInt(waiting ? 1 : 0);
2481 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
2482 reply.readException();
2483 data.recycle();
2484 reply.recycle();
2485 }
2486 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
2487 Parcel data = Parcel.obtain();
2488 Parcel reply = Parcel.obtain();
2489 data.writeInterfaceToken(IActivityManager.descriptor);
2490 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
2491 reply.readException();
2492 outInfo.readFromParcel(reply);
2493 data.recycle();
2494 reply.recycle();
2495 }
2496 public void unhandledBack() throws RemoteException
2497 {
2498 Parcel data = Parcel.obtain();
2499 Parcel reply = Parcel.obtain();
2500 data.writeInterfaceToken(IActivityManager.descriptor);
2501 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
2502 reply.readException();
2503 data.recycle();
2504 reply.recycle();
2505 }
2506 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
2507 {
2508 Parcel data = Parcel.obtain();
2509 Parcel reply = Parcel.obtain();
2510 data.writeInterfaceToken(IActivityManager.descriptor);
2511 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
2512 reply.readException();
2513 ParcelFileDescriptor pfd = null;
2514 if (reply.readInt() != 0) {
2515 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
2516 }
2517 data.recycle();
2518 reply.recycle();
2519 return pfd;
2520 }
2521 public void goingToSleep() throws RemoteException
2522 {
2523 Parcel data = Parcel.obtain();
2524 Parcel reply = Parcel.obtain();
2525 data.writeInterfaceToken(IActivityManager.descriptor);
2526 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
2527 reply.readException();
2528 data.recycle();
2529 reply.recycle();
2530 }
2531 public void wakingUp() throws RemoteException
2532 {
2533 Parcel data = Parcel.obtain();
2534 Parcel reply = Parcel.obtain();
2535 data.writeInterfaceToken(IActivityManager.descriptor);
2536 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
2537 reply.readException();
2538 data.recycle();
2539 reply.recycle();
2540 }
2541 public void setDebugApp(
2542 String packageName, boolean waitForDebugger, boolean persistent)
2543 throws RemoteException
2544 {
2545 Parcel data = Parcel.obtain();
2546 Parcel reply = Parcel.obtain();
2547 data.writeInterfaceToken(IActivityManager.descriptor);
2548 data.writeString(packageName);
2549 data.writeInt(waitForDebugger ? 1 : 0);
2550 data.writeInt(persistent ? 1 : 0);
2551 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2552 reply.readException();
2553 data.recycle();
2554 reply.recycle();
2555 }
2556 public void setAlwaysFinish(boolean enabled) throws RemoteException
2557 {
2558 Parcel data = Parcel.obtain();
2559 Parcel reply = Parcel.obtain();
2560 data.writeInterfaceToken(IActivityManager.descriptor);
2561 data.writeInt(enabled ? 1 : 0);
2562 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2563 reply.readException();
2564 data.recycle();
2565 reply.recycle();
2566 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002567 public void setActivityController(IActivityController watcher) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002568 {
2569 Parcel data = Parcel.obtain();
2570 Parcel reply = Parcel.obtain();
2571 data.writeInterfaceToken(IActivityManager.descriptor);
2572 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002573 mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002574 reply.readException();
2575 data.recycle();
2576 reply.recycle();
2577 }
2578 public void enterSafeMode() throws RemoteException {
2579 Parcel data = Parcel.obtain();
2580 data.writeInterfaceToken(IActivityManager.descriptor);
2581 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2582 data.recycle();
2583 }
2584 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2585 Parcel data = Parcel.obtain();
2586 data.writeStrongBinder(sender.asBinder());
2587 data.writeInterfaceToken(IActivityManager.descriptor);
2588 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2589 data.recycle();
2590 }
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07002591 public boolean killPids(int[] pids, String reason) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002592 Parcel data = Parcel.obtain();
2593 Parcel reply = Parcel.obtain();
2594 data.writeInterfaceToken(IActivityManager.descriptor);
2595 data.writeIntArray(pids);
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07002596 data.writeString(reason);
2597 mRemote.transact(KILL_PIDS_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002598 boolean res = reply.readInt() != 0;
2599 data.recycle();
2600 reply.recycle();
2601 return res;
2602 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002603 public void startRunning(String pkg, String cls, String action,
2604 String indata) throws RemoteException {
2605 Parcel data = Parcel.obtain();
2606 Parcel reply = Parcel.obtain();
2607 data.writeInterfaceToken(IActivityManager.descriptor);
2608 data.writeString(pkg);
2609 data.writeString(cls);
2610 data.writeString(action);
2611 data.writeString(indata);
2612 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2613 reply.readException();
2614 data.recycle();
2615 reply.recycle();
2616 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002617 public boolean testIsSystemReady()
2618 {
2619 /* this base class version is never called */
2620 return true;
2621 }
Dan Egnor60d87622009-12-16 16:32:58 -08002622 public void handleApplicationCrash(IBinder app,
2623 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
2624 {
2625 Parcel data = Parcel.obtain();
2626 Parcel reply = Parcel.obtain();
2627 data.writeInterfaceToken(IActivityManager.descriptor);
2628 data.writeStrongBinder(app);
2629 crashInfo.writeToParcel(data, 0);
2630 mRemote.transact(HANDLE_APPLICATION_CRASH_TRANSACTION, data, reply, 0);
2631 reply.readException();
2632 reply.recycle();
2633 data.recycle();
2634 }
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002635
Dan Egnor60d87622009-12-16 16:32:58 -08002636 public boolean handleApplicationWtf(IBinder app, String tag,
Dan Egnorb7f03672009-12-09 16:22:32 -08002637 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002638 {
2639 Parcel data = Parcel.obtain();
2640 Parcel reply = Parcel.obtain();
2641 data.writeInterfaceToken(IActivityManager.descriptor);
2642 data.writeStrongBinder(app);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002643 data.writeString(tag);
Dan Egnorb7f03672009-12-09 16:22:32 -08002644 crashInfo.writeToParcel(data, 0);
Dan Egnor60d87622009-12-16 16:32:58 -08002645 mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002646 reply.readException();
Dan Egnor60d87622009-12-16 16:32:58 -08002647 boolean res = reply.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002648 reply.recycle();
2649 data.recycle();
Dan Egnor60d87622009-12-16 16:32:58 -08002650 return res;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002651 }
Dan Egnorb7f03672009-12-09 16:22:32 -08002652
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002653 public void handleApplicationStrictModeViolation(IBinder app,
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07002654 int violationMask,
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07002655 StrictMode.ViolationInfo info) throws RemoteException
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002656 {
2657 Parcel data = Parcel.obtain();
2658 Parcel reply = Parcel.obtain();
2659 data.writeInterfaceToken(IActivityManager.descriptor);
2660 data.writeStrongBinder(app);
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07002661 data.writeInt(violationMask);
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07002662 info.writeToParcel(data, 0);
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002663 mRemote.transact(HANDLE_APPLICATION_STRICT_MODE_VIOLATION_TRANSACTION, data, reply, 0);
2664 reply.readException();
2665 reply.recycle();
2666 data.recycle();
2667 }
2668
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002669 public void signalPersistentProcesses(int sig) throws RemoteException {
2670 Parcel data = Parcel.obtain();
2671 Parcel reply = Parcel.obtain();
2672 data.writeInterfaceToken(IActivityManager.descriptor);
2673 data.writeInt(sig);
2674 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2675 reply.readException();
2676 data.recycle();
2677 reply.recycle();
2678 }
2679
Dianne Hackborn03abb812010-01-04 18:43:19 -08002680 public void killBackgroundProcesses(String packageName) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002681 Parcel data = Parcel.obtain();
2682 Parcel reply = Parcel.obtain();
2683 data.writeInterfaceToken(IActivityManager.descriptor);
2684 data.writeString(packageName);
Dianne Hackborn03abb812010-01-04 18:43:19 -08002685 mRemote.transact(KILL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0);
2686 reply.readException();
2687 data.recycle();
2688 reply.recycle();
2689 }
2690
2691 public void forceStopPackage(String packageName) throws RemoteException {
2692 Parcel data = Parcel.obtain();
2693 Parcel reply = Parcel.obtain();
2694 data.writeInterfaceToken(IActivityManager.descriptor);
2695 data.writeString(packageName);
2696 mRemote.transact(FORCE_STOP_PACKAGE_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002697 reply.readException();
2698 data.recycle();
2699 reply.recycle();
2700 }
2701
2702 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2703 {
2704 Parcel data = Parcel.obtain();
2705 Parcel reply = Parcel.obtain();
2706 data.writeInterfaceToken(IActivityManager.descriptor);
2707 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2708 reply.readException();
2709 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2710 reply.recycle();
2711 data.recycle();
2712 return res;
2713 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002714
2715 public boolean profileControl(String process, boolean start,
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002716 String path, ParcelFileDescriptor fd) throws RemoteException
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002717 {
2718 Parcel data = Parcel.obtain();
2719 Parcel reply = Parcel.obtain();
2720 data.writeInterfaceToken(IActivityManager.descriptor);
2721 data.writeString(process);
2722 data.writeInt(start ? 1 : 0);
2723 data.writeString(path);
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002724 if (fd != null) {
2725 data.writeInt(1);
2726 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
2727 } else {
2728 data.writeInt(0);
2729 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002730 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2731 reply.readException();
2732 boolean res = reply.readInt() != 0;
2733 reply.recycle();
2734 data.recycle();
2735 return res;
2736 }
2737
Dianne Hackborn55280a92009-05-07 15:53:46 -07002738 public boolean shutdown(int timeout) throws RemoteException
2739 {
2740 Parcel data = Parcel.obtain();
2741 Parcel reply = Parcel.obtain();
2742 data.writeInterfaceToken(IActivityManager.descriptor);
2743 data.writeInt(timeout);
2744 mRemote.transact(SHUTDOWN_TRANSACTION, data, reply, 0);
2745 reply.readException();
2746 boolean res = reply.readInt() != 0;
2747 reply.recycle();
2748 data.recycle();
2749 return res;
2750 }
2751
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07002752 public void stopAppSwitches() throws RemoteException {
2753 Parcel data = Parcel.obtain();
2754 Parcel reply = Parcel.obtain();
2755 data.writeInterfaceToken(IActivityManager.descriptor);
2756 mRemote.transact(STOP_APP_SWITCHES_TRANSACTION, data, reply, 0);
2757 reply.readException();
2758 reply.recycle();
2759 data.recycle();
2760 }
2761
2762 public void resumeAppSwitches() throws RemoteException {
2763 Parcel data = Parcel.obtain();
2764 Parcel reply = Parcel.obtain();
2765 data.writeInterfaceToken(IActivityManager.descriptor);
2766 mRemote.transact(RESUME_APP_SWITCHES_TRANSACTION, data, reply, 0);
2767 reply.readException();
2768 reply.recycle();
2769 data.recycle();
2770 }
2771
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002772 public void registerActivityWatcher(IActivityWatcher watcher)
2773 throws RemoteException {
2774 Parcel data = Parcel.obtain();
2775 Parcel reply = Parcel.obtain();
2776 data.writeInterfaceToken(IActivityManager.descriptor);
2777 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2778 mRemote.transact(REGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2779 reply.readException();
2780 data.recycle();
2781 reply.recycle();
2782 }
2783
2784 public void unregisterActivityWatcher(IActivityWatcher watcher)
2785 throws RemoteException {
2786 Parcel data = Parcel.obtain();
2787 Parcel reply = Parcel.obtain();
2788 data.writeInterfaceToken(IActivityManager.descriptor);
2789 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2790 mRemote.transact(UNREGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2791 reply.readException();
2792 data.recycle();
2793 reply.recycle();
2794 }
2795
Dianne Hackborn2d91af02009-07-16 13:34:33 -07002796 public int startActivityInPackage(int uid,
2797 Intent intent, String resolvedType, IBinder resultTo,
2798 String resultWho, int requestCode, boolean onlyIfNeeded)
2799 throws RemoteException {
2800 Parcel data = Parcel.obtain();
2801 Parcel reply = Parcel.obtain();
2802 data.writeInterfaceToken(IActivityManager.descriptor);
2803 data.writeInt(uid);
2804 intent.writeToParcel(data, 0);
2805 data.writeString(resolvedType);
2806 data.writeStrongBinder(resultTo);
2807 data.writeString(resultWho);
2808 data.writeInt(requestCode);
2809 data.writeInt(onlyIfNeeded ? 1 : 0);
2810 mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
2811 reply.readException();
2812 int result = reply.readInt();
2813 reply.recycle();
2814 data.recycle();
2815 return result;
2816 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002817
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07002818 public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
2819 Parcel data = Parcel.obtain();
2820 Parcel reply = Parcel.obtain();
2821 data.writeInterfaceToken(IActivityManager.descriptor);
2822 data.writeString(pkg);
2823 data.writeInt(uid);
2824 mRemote.transact(KILL_APPLICATION_WITH_UID_TRANSACTION, data, reply, 0);
2825 reply.readException();
2826 data.recycle();
2827 reply.recycle();
2828 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002829
2830 public void closeSystemDialogs(String reason) throws RemoteException {
2831 Parcel data = Parcel.obtain();
2832 Parcel reply = Parcel.obtain();
2833 data.writeInterfaceToken(IActivityManager.descriptor);
2834 data.writeString(reason);
2835 mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
2836 reply.readException();
2837 data.recycle();
2838 reply.recycle();
2839 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002840
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002841 public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002842 throws RemoteException {
2843 Parcel data = Parcel.obtain();
2844 Parcel reply = Parcel.obtain();
2845 data.writeInterfaceToken(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002846 data.writeIntArray(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002847 mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
2848 reply.readException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002849 Debug.MemoryInfo[] res = reply.createTypedArray(Debug.MemoryInfo.CREATOR);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002850 data.recycle();
2851 reply.recycle();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002852 return res;
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002853 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07002854
2855 public void killApplicationProcess(String processName, int uid) throws RemoteException {
2856 Parcel data = Parcel.obtain();
2857 Parcel reply = Parcel.obtain();
2858 data.writeInterfaceToken(IActivityManager.descriptor);
2859 data.writeString(processName);
2860 data.writeInt(uid);
2861 mRemote.transact(KILL_APPLICATION_PROCESS_TRANSACTION, data, reply, 0);
2862 reply.readException();
2863 data.recycle();
2864 reply.recycle();
2865 }
2866
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07002867 public void overridePendingTransition(IBinder token, String packageName,
2868 int enterAnim, int exitAnim) throws RemoteException {
2869 Parcel data = Parcel.obtain();
2870 Parcel reply = Parcel.obtain();
2871 data.writeInterfaceToken(IActivityManager.descriptor);
2872 data.writeStrongBinder(token);
2873 data.writeString(packageName);
2874 data.writeInt(enterAnim);
2875 data.writeInt(exitAnim);
2876 mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
2877 reply.readException();
2878 data.recycle();
2879 reply.recycle();
2880 }
2881
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08002882 public boolean isUserAMonkey() throws RemoteException {
2883 Parcel data = Parcel.obtain();
2884 Parcel reply = Parcel.obtain();
2885 data.writeInterfaceToken(IActivityManager.descriptor);
2886 mRemote.transact(IS_USER_A_MONKEY_TRANSACTION, data, reply, 0);
2887 reply.readException();
2888 boolean res = reply.readInt() != 0;
2889 data.recycle();
2890 reply.recycle();
2891 return res;
2892 }
2893
Dianne Hackborn860755f2010-06-03 18:47:52 -07002894 public void finishHeavyWeightApp() throws RemoteException {
2895 Parcel data = Parcel.obtain();
2896 Parcel reply = Parcel.obtain();
2897 data.writeInterfaceToken(IActivityManager.descriptor);
2898 mRemote.transact(FINISH_HEAVY_WEIGHT_APP_TRANSACTION, data, reply, 0);
2899 reply.readException();
2900 data.recycle();
2901 reply.recycle();
2902 }
2903
Daniel Sandler69a48172010-06-23 16:29:36 -04002904 public void setImmersive(IBinder token, boolean immersive)
2905 throws RemoteException {
2906 Parcel data = Parcel.obtain();
2907 Parcel reply = Parcel.obtain();
2908 data.writeInterfaceToken(IActivityManager.descriptor);
2909 data.writeStrongBinder(token);
2910 data.writeInt(immersive ? 1 : 0);
2911 mRemote.transact(SET_IMMERSIVE_TRANSACTION, data, reply, 0);
2912 reply.readException();
2913 data.recycle();
2914 reply.recycle();
2915 }
2916
2917 public boolean isImmersive(IBinder token)
2918 throws RemoteException {
2919 Parcel data = Parcel.obtain();
2920 Parcel reply = Parcel.obtain();
2921 data.writeInterfaceToken(IActivityManager.descriptor);
2922 data.writeStrongBinder(token);
2923 mRemote.transact(IS_IMMERSIVE_TRANSACTION, data, reply, 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04002924 reply.readException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07002925 boolean res = reply.readInt() == 1;
Daniel Sandler69a48172010-06-23 16:29:36 -04002926 data.recycle();
2927 reply.recycle();
2928 return res;
2929 }
2930
2931 public boolean isTopActivityImmersive()
2932 throws RemoteException {
2933 Parcel data = Parcel.obtain();
2934 Parcel reply = Parcel.obtain();
2935 data.writeInterfaceToken(IActivityManager.descriptor);
2936 mRemote.transact(IS_TOP_ACTIVITY_IMMERSIVE_TRANSACTION, data, reply, 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04002937 reply.readException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07002938 boolean res = reply.readInt() == 1;
Daniel Sandler69a48172010-06-23 16:29:36 -04002939 data.recycle();
2940 reply.recycle();
2941 return res;
2942 }
2943
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07002944 public void crashApplication(int uid, int initialPid, String packageName,
2945 String message) throws RemoteException {
2946 Parcel data = Parcel.obtain();
2947 Parcel reply = Parcel.obtain();
2948 data.writeInterfaceToken(IActivityManager.descriptor);
2949 data.writeInt(uid);
2950 data.writeInt(initialPid);
2951 data.writeString(packageName);
2952 data.writeString(message);
2953 mRemote.transact(CRASH_APPLICATION_TRANSACTION, data, reply, 0);
2954 reply.readException();
2955 data.recycle();
2956 reply.recycle();
2957 }
Andy McFadden824c5102010-07-09 16:26:57 -07002958
Dianne Hackborncca1f0e2010-09-26 18:34:53 -07002959 public String getProviderMimeType(Uri uri)
2960 throws RemoteException {
2961 Parcel data = Parcel.obtain();
2962 Parcel reply = Parcel.obtain();
2963 data.writeInterfaceToken(IActivityManager.descriptor);
2964 uri.writeToParcel(data, 0);
2965 mRemote.transact(GET_PROVIDER_MIME_TYPE_TRANSACTION, data, reply, 0);
2966 reply.readException();
2967 String res = reply.readString();
2968 data.recycle();
2969 reply.recycle();
2970 return res;
2971 }
2972
Dianne Hackborn7e269642010-08-25 19:50:20 -07002973 public IBinder newUriPermissionOwner(String name)
2974 throws RemoteException {
2975 Parcel data = Parcel.obtain();
2976 Parcel reply = Parcel.obtain();
2977 data.writeInterfaceToken(IActivityManager.descriptor);
2978 data.writeString(name);
2979 mRemote.transact(NEW_URI_PERMISSION_OWNER_TRANSACTION, data, reply, 0);
2980 reply.readException();
2981 IBinder res = reply.readStrongBinder();
2982 data.recycle();
2983 reply.recycle();
2984 return res;
2985 }
2986
2987 public void grantUriPermissionFromOwner(IBinder owner, int fromUid, String targetPkg,
2988 Uri uri, int mode) throws RemoteException {
2989 Parcel data = Parcel.obtain();
2990 Parcel reply = Parcel.obtain();
2991 data.writeInterfaceToken(IActivityManager.descriptor);
2992 data.writeStrongBinder(owner);
2993 data.writeInt(fromUid);
2994 data.writeString(targetPkg);
2995 uri.writeToParcel(data, 0);
2996 data.writeInt(mode);
2997 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2998 reply.readException();
2999 data.recycle();
3000 reply.recycle();
3001 }
3002
3003 public void revokeUriPermissionFromOwner(IBinder owner, Uri uri,
3004 int mode) throws RemoteException {
3005 Parcel data = Parcel.obtain();
3006 Parcel reply = Parcel.obtain();
3007 data.writeInterfaceToken(IActivityManager.descriptor);
3008 data.writeStrongBinder(owner);
3009 if (uri != null) {
3010 data.writeInt(1);
3011 uri.writeToParcel(data, 0);
3012 } else {
3013 data.writeInt(0);
3014 }
3015 data.writeInt(mode);
3016 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
3017 reply.readException();
3018 data.recycle();
3019 reply.recycle();
3020 }
Dianne Hackbornc8f84972010-08-25 23:14:44 -07003021
Dianne Hackborn90f4aaf2010-09-27 14:58:44 -07003022 public int checkGrantUriPermission(int callingUid, String targetPkg,
3023 Uri uri, int modeFlags) throws RemoteException {
3024 Parcel data = Parcel.obtain();
3025 Parcel reply = Parcel.obtain();
3026 data.writeInterfaceToken(IActivityManager.descriptor);
3027 data.writeInt(callingUid);
3028 data.writeString(targetPkg);
3029 uri.writeToParcel(data, 0);
3030 data.writeInt(modeFlags);
3031 mRemote.transact(CHECK_GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
3032 reply.readException();
3033 int res = reply.readInt();
3034 data.recycle();
3035 reply.recycle();
3036 return res;
3037 }
3038
Andy McFadden824c5102010-07-09 16:26:57 -07003039 public boolean dumpHeap(String process, boolean managed,
3040 String path, ParcelFileDescriptor fd) throws RemoteException {
3041 Parcel data = Parcel.obtain();
3042 Parcel reply = Parcel.obtain();
3043 data.writeInterfaceToken(IActivityManager.descriptor);
3044 data.writeString(process);
3045 data.writeInt(managed ? 1 : 0);
3046 data.writeString(path);
3047 if (fd != null) {
3048 data.writeInt(1);
3049 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
3050 } else {
3051 data.writeInt(0);
3052 }
3053 mRemote.transact(DUMP_HEAP_TRANSACTION, data, reply, 0);
3054 reply.readException();
3055 boolean res = reply.readInt() != 0;
3056 reply.recycle();
3057 data.recycle();
3058 return res;
3059 }
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07003060
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003061 public int startActivities(IApplicationThread caller,
3062 Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException {
3063 Parcel data = Parcel.obtain();
3064 Parcel reply = Parcel.obtain();
3065 data.writeInterfaceToken(IActivityManager.descriptor);
3066 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
3067 data.writeTypedArray(intents, 0);
3068 data.writeStringArray(resolvedTypes);
3069 data.writeStrongBinder(resultTo);
3070 mRemote.transact(START_ACTIVITIES_TRANSACTION, data, reply, 0);
3071 reply.readException();
3072 int result = reply.readInt();
3073 reply.recycle();
3074 data.recycle();
3075 return result;
3076 }
3077
3078 public int startActivitiesInPackage(int uid,
3079 Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException {
3080 Parcel data = Parcel.obtain();
3081 Parcel reply = Parcel.obtain();
3082 data.writeInterfaceToken(IActivityManager.descriptor);
3083 data.writeInt(uid);
3084 data.writeTypedArray(intents, 0);
3085 data.writeStringArray(resolvedTypes);
3086 data.writeStrongBinder(resultTo);
3087 mRemote.transact(START_ACTIVITIES_IN_PACKAGE_TRANSACTION, data, reply, 0);
3088 reply.readException();
3089 int result = reply.readInt();
3090 reply.recycle();
3091 data.recycle();
3092 return result;
3093 }
3094
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003095 private IBinder mRemote;
3096}