blob: 6849fd7660351db37f95e9391a4dc16421158e87 [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;
40import android.text.TextUtils;
41import android.util.Config;
42import android.util.Log;
43
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import java.util.ArrayList;
45import java.util.List;
46
47/** {@hide} */
48public abstract class ActivityManagerNative extends Binder implements IActivityManager
49{
50 /**
51 * Cast a Binder object into an activity manager interface, generating
52 * a proxy if needed.
53 */
54 static public IActivityManager asInterface(IBinder obj)
55 {
56 if (obj == null) {
57 return null;
58 }
59 IActivityManager in =
60 (IActivityManager)obj.queryLocalInterface(descriptor);
61 if (in != null) {
62 return in;
63 }
64
65 return new ActivityManagerProxy(obj);
66 }
67
68 /**
69 * Retrieve the system's default/global activity manager.
70 */
71 static public IActivityManager getDefault()
72 {
73 if (gDefault != null) {
74 //if (Config.LOGV) Log.v(
75 // "ActivityManager", "returning cur default = " + gDefault);
76 return gDefault;
77 }
78 IBinder b = ServiceManager.getService("activity");
79 if (Config.LOGV) Log.v(
80 "ActivityManager", "default service binder = " + b);
81 gDefault = asInterface(b);
82 if (Config.LOGV) Log.v(
83 "ActivityManager", "default service = " + gDefault);
84 return gDefault;
85 }
86
87 /**
88 * Convenience for checking whether the system is ready. For internal use only.
89 */
90 static public boolean isSystemReady() {
91 if (!sSystemReady) {
92 sSystemReady = getDefault().testIsSystemReady();
93 }
94 return sSystemReady;
95 }
96 static boolean sSystemReady = false;
97
98 /**
99 * Convenience for sending a sticky broadcast. For internal use only.
100 * If you don't care about permission, use null.
101 */
102 static public void broadcastStickyIntent(Intent intent, String permission)
103 {
104 try {
105 getDefault().broadcastIntent(
106 null, intent, null, null, Activity.RESULT_OK, null, null,
107 null /*permission*/, false, true);
108 } catch (RemoteException ex) {
109 }
110 }
111
112 static public void noteWakeupAlarm(PendingIntent ps) {
113 try {
114 getDefault().noteWakeupAlarm(ps.getTarget());
115 } catch (RemoteException ex) {
116 }
117 }
118
119 public ActivityManagerNative()
120 {
121 attachInterface(this, descriptor);
122 }
123
124 public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
125 throws RemoteException {
126 switch (code) {
127 case START_ACTIVITY_TRANSACTION:
128 {
129 data.enforceInterface(IActivityManager.descriptor);
130 IBinder b = data.readStrongBinder();
131 IApplicationThread app = ApplicationThreadNative.asInterface(b);
132 Intent intent = Intent.CREATOR.createFromParcel(data);
133 String resolvedType = data.readString();
134 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
135 int grantedMode = data.readInt();
136 IBinder resultTo = data.readStrongBinder();
137 String resultWho = data.readString();
138 int requestCode = data.readInt();
139 boolean onlyIfNeeded = data.readInt() != 0;
140 boolean debug = data.readInt() != 0;
141 int result = startActivity(app, intent, resolvedType,
142 grantedUriPermissions, grantedMode, resultTo, resultWho,
143 requestCode, onlyIfNeeded, debug);
144 reply.writeNoException();
145 reply.writeInt(result);
146 return true;
147 }
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700148
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -0800149 case START_ACTIVITY_AND_WAIT_TRANSACTION:
150 {
151 data.enforceInterface(IActivityManager.descriptor);
152 IBinder b = data.readStrongBinder();
153 IApplicationThread app = ApplicationThreadNative.asInterface(b);
154 Intent intent = Intent.CREATOR.createFromParcel(data);
155 String resolvedType = data.readString();
156 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
157 int grantedMode = data.readInt();
158 IBinder resultTo = data.readStrongBinder();
159 String resultWho = data.readString();
160 int requestCode = data.readInt();
161 boolean onlyIfNeeded = data.readInt() != 0;
162 boolean debug = data.readInt() != 0;
163 WaitResult result = startActivityAndWait(app, intent, resolvedType,
164 grantedUriPermissions, grantedMode, resultTo, resultWho,
165 requestCode, onlyIfNeeded, debug);
166 reply.writeNoException();
167 result.writeToParcel(reply, 0);
168 return true;
169 }
170
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700171 case START_ACTIVITY_INTENT_SENDER_TRANSACTION:
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700172 {
173 data.enforceInterface(IActivityManager.descriptor);
174 IBinder b = data.readStrongBinder();
175 IApplicationThread app = ApplicationThreadNative.asInterface(b);
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700176 IntentSender intent = IntentSender.CREATOR.createFromParcel(data);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700177 Intent fillInIntent = null;
178 if (data.readInt() != 0) {
179 fillInIntent = Intent.CREATOR.createFromParcel(data);
180 }
181 String resolvedType = data.readString();
182 IBinder resultTo = data.readStrongBinder();
183 String resultWho = data.readString();
184 int requestCode = data.readInt();
185 int flagsMask = data.readInt();
186 int flagsValues = data.readInt();
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700187 int result = startActivityIntentSender(app, intent,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700188 fillInIntent, resolvedType, resultTo, resultWho,
189 requestCode, flagsMask, flagsValues);
190 reply.writeNoException();
191 reply.writeInt(result);
192 return true;
193 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194
195 case START_NEXT_MATCHING_ACTIVITY_TRANSACTION:
196 {
197 data.enforceInterface(IActivityManager.descriptor);
198 IBinder callingActivity = data.readStrongBinder();
199 Intent intent = Intent.CREATOR.createFromParcel(data);
200 boolean result = startNextMatchingActivity(callingActivity, intent);
201 reply.writeNoException();
202 reply.writeInt(result ? 1 : 0);
203 return true;
204 }
205
206 case FINISH_ACTIVITY_TRANSACTION: {
207 data.enforceInterface(IActivityManager.descriptor);
208 IBinder token = data.readStrongBinder();
209 Intent resultData = null;
210 int resultCode = data.readInt();
211 if (data.readInt() != 0) {
212 resultData = Intent.CREATOR.createFromParcel(data);
213 }
214 boolean res = finishActivity(token, resultCode, resultData);
215 reply.writeNoException();
216 reply.writeInt(res ? 1 : 0);
217 return true;
218 }
219
220 case FINISH_SUB_ACTIVITY_TRANSACTION: {
221 data.enforceInterface(IActivityManager.descriptor);
222 IBinder token = data.readStrongBinder();
223 String resultWho = data.readString();
224 int requestCode = data.readInt();
225 finishSubActivity(token, resultWho, requestCode);
226 reply.writeNoException();
227 return true;
228 }
229
230 case REGISTER_RECEIVER_TRANSACTION:
231 {
232 data.enforceInterface(IActivityManager.descriptor);
233 IBinder b = data.readStrongBinder();
234 IApplicationThread app =
235 b != null ? ApplicationThreadNative.asInterface(b) : null;
236 b = data.readStrongBinder();
237 IIntentReceiver rec
238 = b != null ? IIntentReceiver.Stub.asInterface(b) : null;
239 IntentFilter filter = IntentFilter.CREATOR.createFromParcel(data);
240 String perm = data.readString();
241 Intent intent = registerReceiver(app, rec, filter, perm);
242 reply.writeNoException();
243 if (intent != null) {
244 reply.writeInt(1);
245 intent.writeToParcel(reply, 0);
246 } else {
247 reply.writeInt(0);
248 }
249 return true;
250 }
251
252 case UNREGISTER_RECEIVER_TRANSACTION:
253 {
254 data.enforceInterface(IActivityManager.descriptor);
255 IBinder b = data.readStrongBinder();
256 if (b == null) {
257 return true;
258 }
259 IIntentReceiver rec = IIntentReceiver.Stub.asInterface(b);
260 unregisterReceiver(rec);
261 reply.writeNoException();
262 return true;
263 }
264
265 case BROADCAST_INTENT_TRANSACTION:
266 {
267 data.enforceInterface(IActivityManager.descriptor);
268 IBinder b = data.readStrongBinder();
269 IApplicationThread app =
270 b != null ? ApplicationThreadNative.asInterface(b) : null;
271 Intent intent = Intent.CREATOR.createFromParcel(data);
272 String resolvedType = data.readString();
273 b = data.readStrongBinder();
274 IIntentReceiver resultTo =
275 b != null ? IIntentReceiver.Stub.asInterface(b) : null;
276 int resultCode = data.readInt();
277 String resultData = data.readString();
278 Bundle resultExtras = data.readBundle();
279 String perm = data.readString();
280 boolean serialized = data.readInt() != 0;
281 boolean sticky = data.readInt() != 0;
282 int res = broadcastIntent(app, intent, resolvedType, resultTo,
283 resultCode, resultData, resultExtras, perm,
284 serialized, sticky);
285 reply.writeNoException();
286 reply.writeInt(res);
287 return true;
288 }
289
290 case UNBROADCAST_INTENT_TRANSACTION:
291 {
292 data.enforceInterface(IActivityManager.descriptor);
293 IBinder b = data.readStrongBinder();
294 IApplicationThread app = b != null ? ApplicationThreadNative.asInterface(b) : null;
295 Intent intent = Intent.CREATOR.createFromParcel(data);
296 unbroadcastIntent(app, intent);
297 reply.writeNoException();
298 return true;
299 }
300
301 case FINISH_RECEIVER_TRANSACTION: {
302 data.enforceInterface(IActivityManager.descriptor);
303 IBinder who = data.readStrongBinder();
304 int resultCode = data.readInt();
305 String resultData = data.readString();
306 Bundle resultExtras = data.readBundle();
307 boolean resultAbort = data.readInt() != 0;
308 if (who != null) {
309 finishReceiver(who, resultCode, resultData, resultExtras, resultAbort);
310 }
311 reply.writeNoException();
312 return true;
313 }
314
315 case SET_PERSISTENT_TRANSACTION: {
316 data.enforceInterface(IActivityManager.descriptor);
317 IBinder token = data.readStrongBinder();
318 boolean isPersistent = data.readInt() != 0;
319 if (token != null) {
320 setPersistent(token, isPersistent);
321 }
322 reply.writeNoException();
323 return true;
324 }
325
326 case ATTACH_APPLICATION_TRANSACTION: {
327 data.enforceInterface(IActivityManager.descriptor);
328 IApplicationThread app = ApplicationThreadNative.asInterface(
329 data.readStrongBinder());
330 if (app != null) {
331 attachApplication(app);
332 }
333 reply.writeNoException();
334 return true;
335 }
336
337 case ACTIVITY_IDLE_TRANSACTION: {
338 data.enforceInterface(IActivityManager.descriptor);
339 IBinder token = data.readStrongBinder();
Dianne Hackborne88846e2009-09-30 21:34:25 -0700340 Configuration config = null;
341 if (data.readInt() != 0) {
342 config = Configuration.CREATOR.createFromParcel(data);
343 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800344 if (token != null) {
Dianne Hackborne88846e2009-09-30 21:34:25 -0700345 activityIdle(token, config);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 }
347 reply.writeNoException();
348 return true;
349 }
350
351 case ACTIVITY_PAUSED_TRANSACTION: {
352 data.enforceInterface(IActivityManager.descriptor);
353 IBinder token = data.readStrongBinder();
354 Bundle map = data.readBundle();
355 activityPaused(token, map);
356 reply.writeNoException();
357 return true;
358 }
359
360 case ACTIVITY_STOPPED_TRANSACTION: {
361 data.enforceInterface(IActivityManager.descriptor);
362 IBinder token = data.readStrongBinder();
363 Bitmap thumbnail = data.readInt() != 0
364 ? Bitmap.CREATOR.createFromParcel(data) : null;
365 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
366 activityStopped(token, thumbnail, description);
367 reply.writeNoException();
368 return true;
369 }
370
371 case ACTIVITY_DESTROYED_TRANSACTION: {
372 data.enforceInterface(IActivityManager.descriptor);
373 IBinder token = data.readStrongBinder();
374 activityDestroyed(token);
375 reply.writeNoException();
376 return true;
377 }
378
379 case GET_CALLING_PACKAGE_TRANSACTION: {
380 data.enforceInterface(IActivityManager.descriptor);
381 IBinder token = data.readStrongBinder();
382 String res = token != null ? getCallingPackage(token) : null;
383 reply.writeNoException();
384 reply.writeString(res);
385 return true;
386 }
387
388 case GET_CALLING_ACTIVITY_TRANSACTION: {
389 data.enforceInterface(IActivityManager.descriptor);
390 IBinder token = data.readStrongBinder();
391 ComponentName cn = getCallingActivity(token);
392 reply.writeNoException();
393 ComponentName.writeToParcel(cn, reply);
394 return true;
395 }
396
397 case GET_TASKS_TRANSACTION: {
398 data.enforceInterface(IActivityManager.descriptor);
399 int maxNum = data.readInt();
400 int fl = data.readInt();
401 IBinder receiverBinder = data.readStrongBinder();
402 IThumbnailReceiver receiver = receiverBinder != null
403 ? IThumbnailReceiver.Stub.asInterface(receiverBinder)
404 : null;
405 List list = getTasks(maxNum, fl, receiver);
406 reply.writeNoException();
407 int N = list != null ? list.size() : -1;
408 reply.writeInt(N);
409 int i;
410 for (i=0; i<N; i++) {
411 ActivityManager.RunningTaskInfo info =
412 (ActivityManager.RunningTaskInfo)list.get(i);
413 info.writeToParcel(reply, 0);
414 }
415 return true;
416 }
417
418 case GET_RECENT_TASKS_TRANSACTION: {
419 data.enforceInterface(IActivityManager.descriptor);
420 int maxNum = data.readInt();
421 int fl = data.readInt();
422 List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
423 fl);
424 reply.writeNoException();
425 reply.writeTypedList(list);
426 return true;
427 }
428
429 case GET_SERVICES_TRANSACTION: {
430 data.enforceInterface(IActivityManager.descriptor);
431 int maxNum = data.readInt();
432 int fl = data.readInt();
433 List list = getServices(maxNum, fl);
434 reply.writeNoException();
435 int N = list != null ? list.size() : -1;
436 reply.writeInt(N);
437 int i;
438 for (i=0; i<N; i++) {
439 ActivityManager.RunningServiceInfo info =
440 (ActivityManager.RunningServiceInfo)list.get(i);
441 info.writeToParcel(reply, 0);
442 }
443 return true;
444 }
445
446 case GET_PROCESSES_IN_ERROR_STATE_TRANSACTION: {
447 data.enforceInterface(IActivityManager.descriptor);
448 List<ActivityManager.ProcessErrorStateInfo> list = getProcessesInErrorState();
449 reply.writeNoException();
450 reply.writeTypedList(list);
451 return true;
452 }
453
454 case GET_RUNNING_APP_PROCESSES_TRANSACTION: {
455 data.enforceInterface(IActivityManager.descriptor);
456 List<ActivityManager.RunningAppProcessInfo> list = getRunningAppProcesses();
457 reply.writeNoException();
458 reply.writeTypedList(list);
459 return true;
460 }
461
462 case MOVE_TASK_TO_FRONT_TRANSACTION: {
463 data.enforceInterface(IActivityManager.descriptor);
464 int task = data.readInt();
465 moveTaskToFront(task);
466 reply.writeNoException();
467 return true;
468 }
469
470 case MOVE_TASK_TO_BACK_TRANSACTION: {
471 data.enforceInterface(IActivityManager.descriptor);
472 int task = data.readInt();
473 moveTaskToBack(task);
474 reply.writeNoException();
475 return true;
476 }
477
478 case MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION: {
479 data.enforceInterface(IActivityManager.descriptor);
480 IBinder token = data.readStrongBinder();
481 boolean nonRoot = data.readInt() != 0;
482 boolean res = moveActivityTaskToBack(token, nonRoot);
483 reply.writeNoException();
484 reply.writeInt(res ? 1 : 0);
485 return true;
486 }
487
488 case MOVE_TASK_BACKWARDS_TRANSACTION: {
489 data.enforceInterface(IActivityManager.descriptor);
490 int task = data.readInt();
491 moveTaskBackwards(task);
492 reply.writeNoException();
493 return true;
494 }
495
496 case GET_TASK_FOR_ACTIVITY_TRANSACTION: {
497 data.enforceInterface(IActivityManager.descriptor);
498 IBinder token = data.readStrongBinder();
499 boolean onlyRoot = data.readInt() != 0;
500 int res = token != null
501 ? getTaskForActivity(token, onlyRoot) : -1;
502 reply.writeNoException();
503 reply.writeInt(res);
504 return true;
505 }
506
507 case FINISH_OTHER_INSTANCES_TRANSACTION: {
508 data.enforceInterface(IActivityManager.descriptor);
509 IBinder token = data.readStrongBinder();
510 ComponentName className = ComponentName.readFromParcel(data);
511 finishOtherInstances(token, className);
512 reply.writeNoException();
513 return true;
514 }
515
516 case REPORT_THUMBNAIL_TRANSACTION: {
517 data.enforceInterface(IActivityManager.descriptor);
518 IBinder token = data.readStrongBinder();
519 Bitmap thumbnail = data.readInt() != 0
520 ? Bitmap.CREATOR.createFromParcel(data) : null;
521 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
522 reportThumbnail(token, thumbnail, description);
523 reply.writeNoException();
524 return true;
525 }
526
527 case GET_CONTENT_PROVIDER_TRANSACTION: {
528 data.enforceInterface(IActivityManager.descriptor);
529 IBinder b = data.readStrongBinder();
530 IApplicationThread app = ApplicationThreadNative.asInterface(b);
531 String name = data.readString();
532 ContentProviderHolder cph = getContentProvider(app, name);
533 reply.writeNoException();
534 if (cph != null) {
535 reply.writeInt(1);
536 cph.writeToParcel(reply, 0);
537 } else {
538 reply.writeInt(0);
539 }
540 return true;
541 }
542
543 case PUBLISH_CONTENT_PROVIDERS_TRANSACTION: {
544 data.enforceInterface(IActivityManager.descriptor);
545 IBinder b = data.readStrongBinder();
546 IApplicationThread app = ApplicationThreadNative.asInterface(b);
547 ArrayList<ContentProviderHolder> providers =
548 data.createTypedArrayList(ContentProviderHolder.CREATOR);
549 publishContentProviders(app, providers);
550 reply.writeNoException();
551 return true;
552 }
553
554 case REMOVE_CONTENT_PROVIDER_TRANSACTION: {
555 data.enforceInterface(IActivityManager.descriptor);
556 IBinder b = data.readStrongBinder();
557 IApplicationThread app = ApplicationThreadNative.asInterface(b);
558 String name = data.readString();
559 removeContentProvider(app, name);
560 reply.writeNoException();
561 return true;
562 }
563
Dianne Hackborndd9b82c2009-09-03 00:18:47 -0700564 case GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION: {
565 data.enforceInterface(IActivityManager.descriptor);
566 ComponentName comp = ComponentName.CREATOR.createFromParcel(data);
567 PendingIntent pi = getRunningServiceControlPanel(comp);
568 reply.writeNoException();
569 PendingIntent.writePendingIntentOrNullToParcel(pi, reply);
570 return true;
571 }
572
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573 case START_SERVICE_TRANSACTION: {
574 data.enforceInterface(IActivityManager.descriptor);
575 IBinder b = data.readStrongBinder();
576 IApplicationThread app = ApplicationThreadNative.asInterface(b);
577 Intent service = Intent.CREATOR.createFromParcel(data);
578 String resolvedType = data.readString();
579 ComponentName cn = startService(app, service, resolvedType);
580 reply.writeNoException();
581 ComponentName.writeToParcel(cn, reply);
582 return true;
583 }
584
585 case STOP_SERVICE_TRANSACTION: {
586 data.enforceInterface(IActivityManager.descriptor);
587 IBinder b = data.readStrongBinder();
588 IApplicationThread app = ApplicationThreadNative.asInterface(b);
589 Intent service = Intent.CREATOR.createFromParcel(data);
590 String resolvedType = data.readString();
591 int res = stopService(app, service, resolvedType);
592 reply.writeNoException();
593 reply.writeInt(res);
594 return true;
595 }
596
597 case STOP_SERVICE_TOKEN_TRANSACTION: {
598 data.enforceInterface(IActivityManager.descriptor);
599 ComponentName className = ComponentName.readFromParcel(data);
600 IBinder token = data.readStrongBinder();
601 int startId = data.readInt();
602 boolean res = stopServiceToken(className, token, startId);
603 reply.writeNoException();
604 reply.writeInt(res ? 1 : 0);
605 return true;
606 }
607
608 case SET_SERVICE_FOREGROUND_TRANSACTION: {
609 data.enforceInterface(IActivityManager.descriptor);
610 ComponentName className = ComponentName.readFromParcel(data);
611 IBinder token = data.readStrongBinder();
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700612 int id = data.readInt();
613 Notification notification = null;
614 if (data.readInt() != 0) {
615 notification = Notification.CREATOR.createFromParcel(data);
616 }
617 boolean removeNotification = data.readInt() != 0;
618 setServiceForeground(className, token, id, notification, removeNotification);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800619 reply.writeNoException();
620 return true;
621 }
622
623 case BIND_SERVICE_TRANSACTION: {
624 data.enforceInterface(IActivityManager.descriptor);
625 IBinder b = data.readStrongBinder();
626 IApplicationThread app = ApplicationThreadNative.asInterface(b);
627 IBinder token = data.readStrongBinder();
628 Intent service = Intent.CREATOR.createFromParcel(data);
629 String resolvedType = data.readString();
630 b = data.readStrongBinder();
631 int fl = data.readInt();
632 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
633 int res = bindService(app, token, service, resolvedType, conn, fl);
634 reply.writeNoException();
635 reply.writeInt(res);
636 return true;
637 }
638
639 case UNBIND_SERVICE_TRANSACTION: {
640 data.enforceInterface(IActivityManager.descriptor);
641 IBinder b = data.readStrongBinder();
642 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
643 boolean res = unbindService(conn);
644 reply.writeNoException();
645 reply.writeInt(res ? 1 : 0);
646 return true;
647 }
648
649 case PUBLISH_SERVICE_TRANSACTION: {
650 data.enforceInterface(IActivityManager.descriptor);
651 IBinder token = data.readStrongBinder();
652 Intent intent = Intent.CREATOR.createFromParcel(data);
653 IBinder service = data.readStrongBinder();
654 publishService(token, intent, service);
655 reply.writeNoException();
656 return true;
657 }
658
659 case UNBIND_FINISHED_TRANSACTION: {
660 data.enforceInterface(IActivityManager.descriptor);
661 IBinder token = data.readStrongBinder();
662 Intent intent = Intent.CREATOR.createFromParcel(data);
663 boolean doRebind = data.readInt() != 0;
664 unbindFinished(token, intent, doRebind);
665 reply.writeNoException();
666 return true;
667 }
668
669 case SERVICE_DONE_EXECUTING_TRANSACTION: {
670 data.enforceInterface(IActivityManager.descriptor);
671 IBinder token = data.readStrongBinder();
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700672 int type = data.readInt();
673 int startId = data.readInt();
674 int res = data.readInt();
675 serviceDoneExecuting(token, type, startId, res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800676 reply.writeNoException();
677 return true;
678 }
679
680 case START_INSTRUMENTATION_TRANSACTION: {
681 data.enforceInterface(IActivityManager.descriptor);
682 ComponentName className = ComponentName.readFromParcel(data);
683 String profileFile = data.readString();
684 int fl = data.readInt();
685 Bundle arguments = data.readBundle();
686 IBinder b = data.readStrongBinder();
687 IInstrumentationWatcher w = IInstrumentationWatcher.Stub.asInterface(b);
688 boolean res = startInstrumentation(className, profileFile, fl, arguments, w);
689 reply.writeNoException();
690 reply.writeInt(res ? 1 : 0);
691 return true;
692 }
693
694
695 case FINISH_INSTRUMENTATION_TRANSACTION: {
696 data.enforceInterface(IActivityManager.descriptor);
697 IBinder b = data.readStrongBinder();
698 IApplicationThread app = ApplicationThreadNative.asInterface(b);
699 int resultCode = data.readInt();
700 Bundle results = data.readBundle();
701 finishInstrumentation(app, resultCode, results);
702 reply.writeNoException();
703 return true;
704 }
705
706 case GET_CONFIGURATION_TRANSACTION: {
707 data.enforceInterface(IActivityManager.descriptor);
708 Configuration config = getConfiguration();
709 reply.writeNoException();
710 config.writeToParcel(reply, 0);
711 return true;
712 }
713
714 case UPDATE_CONFIGURATION_TRANSACTION: {
715 data.enforceInterface(IActivityManager.descriptor);
716 Configuration config = Configuration.CREATOR.createFromParcel(data);
717 updateConfiguration(config);
718 reply.writeNoException();
719 return true;
720 }
721
722 case SET_REQUESTED_ORIENTATION_TRANSACTION: {
723 data.enforceInterface(IActivityManager.descriptor);
724 IBinder token = data.readStrongBinder();
725 int requestedOrientation = data.readInt();
726 setRequestedOrientation(token, requestedOrientation);
727 reply.writeNoException();
728 return true;
729 }
730
731 case GET_REQUESTED_ORIENTATION_TRANSACTION: {
732 data.enforceInterface(IActivityManager.descriptor);
733 IBinder token = data.readStrongBinder();
734 int req = getRequestedOrientation(token);
735 reply.writeNoException();
736 reply.writeInt(req);
737 return true;
738 }
739
740 case GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION: {
741 data.enforceInterface(IActivityManager.descriptor);
742 IBinder token = data.readStrongBinder();
743 ComponentName cn = getActivityClassForToken(token);
744 reply.writeNoException();
745 ComponentName.writeToParcel(cn, reply);
746 return true;
747 }
748
749 case GET_PACKAGE_FOR_TOKEN_TRANSACTION: {
750 data.enforceInterface(IActivityManager.descriptor);
751 IBinder token = data.readStrongBinder();
752 reply.writeNoException();
753 reply.writeString(getPackageForToken(token));
754 return true;
755 }
756
757 case GET_INTENT_SENDER_TRANSACTION: {
758 data.enforceInterface(IActivityManager.descriptor);
759 int type = data.readInt();
760 String packageName = data.readString();
761 IBinder token = data.readStrongBinder();
762 String resultWho = data.readString();
763 int requestCode = data.readInt();
764 Intent requestIntent = data.readInt() != 0
765 ? Intent.CREATOR.createFromParcel(data) : null;
766 String requestResolvedType = data.readString();
767 int fl = data.readInt();
768 IIntentSender res = getIntentSender(type, packageName, token,
769 resultWho, requestCode, requestIntent,
770 requestResolvedType, fl);
771 reply.writeNoException();
772 reply.writeStrongBinder(res != null ? res.asBinder() : null);
773 return true;
774 }
775
776 case CANCEL_INTENT_SENDER_TRANSACTION: {
777 data.enforceInterface(IActivityManager.descriptor);
778 IIntentSender r = IIntentSender.Stub.asInterface(
779 data.readStrongBinder());
780 cancelIntentSender(r);
781 reply.writeNoException();
782 return true;
783 }
784
785 case GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION: {
786 data.enforceInterface(IActivityManager.descriptor);
787 IIntentSender r = IIntentSender.Stub.asInterface(
788 data.readStrongBinder());
789 String res = getPackageForIntentSender(r);
790 reply.writeNoException();
791 reply.writeString(res);
792 return true;
793 }
794
795 case SET_PROCESS_LIMIT_TRANSACTION: {
796 data.enforceInterface(IActivityManager.descriptor);
797 int max = data.readInt();
798 setProcessLimit(max);
799 reply.writeNoException();
800 return true;
801 }
802
803 case GET_PROCESS_LIMIT_TRANSACTION: {
804 data.enforceInterface(IActivityManager.descriptor);
805 int limit = getProcessLimit();
806 reply.writeNoException();
807 reply.writeInt(limit);
808 return true;
809 }
810
811 case SET_PROCESS_FOREGROUND_TRANSACTION: {
812 data.enforceInterface(IActivityManager.descriptor);
813 IBinder token = data.readStrongBinder();
814 int pid = data.readInt();
815 boolean isForeground = data.readInt() != 0;
816 setProcessForeground(token, pid, isForeground);
817 reply.writeNoException();
818 return true;
819 }
820
821 case CHECK_PERMISSION_TRANSACTION: {
822 data.enforceInterface(IActivityManager.descriptor);
823 String perm = data.readString();
824 int pid = data.readInt();
825 int uid = data.readInt();
826 int res = checkPermission(perm, pid, uid);
827 reply.writeNoException();
828 reply.writeInt(res);
829 return true;
830 }
831
832 case CHECK_URI_PERMISSION_TRANSACTION: {
833 data.enforceInterface(IActivityManager.descriptor);
834 Uri uri = Uri.CREATOR.createFromParcel(data);
835 int pid = data.readInt();
836 int uid = data.readInt();
837 int mode = data.readInt();
838 int res = checkUriPermission(uri, pid, uid, mode);
839 reply.writeNoException();
840 reply.writeInt(res);
841 return true;
842 }
843
844 case CLEAR_APP_DATA_TRANSACTION: {
845 data.enforceInterface(IActivityManager.descriptor);
846 String packageName = data.readString();
847 IPackageDataObserver observer = IPackageDataObserver.Stub.asInterface(
848 data.readStrongBinder());
849 boolean res = clearApplicationUserData(packageName, observer);
850 reply.writeNoException();
851 reply.writeInt(res ? 1 : 0);
852 return true;
853 }
854
855 case GRANT_URI_PERMISSION_TRANSACTION: {
856 data.enforceInterface(IActivityManager.descriptor);
857 IBinder b = data.readStrongBinder();
858 IApplicationThread app = ApplicationThreadNative.asInterface(b);
859 String targetPkg = data.readString();
860 Uri uri = Uri.CREATOR.createFromParcel(data);
861 int mode = data.readInt();
862 grantUriPermission(app, targetPkg, uri, mode);
863 reply.writeNoException();
864 return true;
865 }
866
867 case REVOKE_URI_PERMISSION_TRANSACTION: {
868 data.enforceInterface(IActivityManager.descriptor);
869 IBinder b = data.readStrongBinder();
870 IApplicationThread app = ApplicationThreadNative.asInterface(b);
871 Uri uri = Uri.CREATOR.createFromParcel(data);
872 int mode = data.readInt();
873 revokeUriPermission(app, uri, mode);
874 reply.writeNoException();
875 return true;
876 }
877
878 case SHOW_WAITING_FOR_DEBUGGER_TRANSACTION: {
879 data.enforceInterface(IActivityManager.descriptor);
880 IBinder b = data.readStrongBinder();
881 IApplicationThread app = ApplicationThreadNative.asInterface(b);
882 boolean waiting = data.readInt() != 0;
883 showWaitingForDebugger(app, waiting);
884 reply.writeNoException();
885 return true;
886 }
887
888 case GET_MEMORY_INFO_TRANSACTION: {
889 data.enforceInterface(IActivityManager.descriptor);
890 ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
891 getMemoryInfo(mi);
892 reply.writeNoException();
893 mi.writeToParcel(reply, 0);
894 return true;
895 }
896
897 case UNHANDLED_BACK_TRANSACTION: {
898 data.enforceInterface(IActivityManager.descriptor);
899 unhandledBack();
900 reply.writeNoException();
901 return true;
902 }
903
904 case OPEN_CONTENT_URI_TRANSACTION: {
905 data.enforceInterface(IActivityManager.descriptor);
906 Uri uri = Uri.parse(data.readString());
907 ParcelFileDescriptor pfd = openContentUri(uri);
908 reply.writeNoException();
909 if (pfd != null) {
910 reply.writeInt(1);
911 pfd.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
912 } else {
913 reply.writeInt(0);
914 }
915 return true;
916 }
917
918 case GOING_TO_SLEEP_TRANSACTION: {
919 data.enforceInterface(IActivityManager.descriptor);
920 goingToSleep();
921 reply.writeNoException();
922 return true;
923 }
924
925 case WAKING_UP_TRANSACTION: {
926 data.enforceInterface(IActivityManager.descriptor);
927 wakingUp();
928 reply.writeNoException();
929 return true;
930 }
931
932 case SET_DEBUG_APP_TRANSACTION: {
933 data.enforceInterface(IActivityManager.descriptor);
934 String pn = data.readString();
935 boolean wfd = data.readInt() != 0;
936 boolean per = data.readInt() != 0;
937 setDebugApp(pn, wfd, per);
938 reply.writeNoException();
939 return true;
940 }
941
942 case SET_ALWAYS_FINISH_TRANSACTION: {
943 data.enforceInterface(IActivityManager.descriptor);
944 boolean enabled = data.readInt() != 0;
945 setAlwaysFinish(enabled);
946 reply.writeNoException();
947 return true;
948 }
949
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700950 case SET_ACTIVITY_CONTROLLER_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800951 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700952 IActivityController watcher = IActivityController.Stub.asInterface(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800953 data.readStrongBinder());
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700954 setActivityController(watcher);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800955 return true;
956 }
957
958 case ENTER_SAFE_MODE_TRANSACTION: {
959 data.enforceInterface(IActivityManager.descriptor);
960 enterSafeMode();
961 reply.writeNoException();
962 return true;
963 }
964
965 case NOTE_WAKEUP_ALARM_TRANSACTION: {
966 data.enforceInterface(IActivityManager.descriptor);
967 IIntentSender is = IIntentSender.Stub.asInterface(
968 data.readStrongBinder());
969 noteWakeupAlarm(is);
970 reply.writeNoException();
971 return true;
972 }
973
974 case KILL_PIDS_FOR_MEMORY_TRANSACTION: {
975 data.enforceInterface(IActivityManager.descriptor);
976 int[] pids = data.createIntArray();
977 boolean res = killPidsForMemory(pids);
978 reply.writeNoException();
979 reply.writeInt(res ? 1 : 0);
980 return true;
981 }
982
983 case REPORT_PSS_TRANSACTION: {
984 data.enforceInterface(IActivityManager.descriptor);
985 IBinder b = data.readStrongBinder();
986 IApplicationThread app = ApplicationThreadNative.asInterface(b);
987 int pss = data.readInt();
988 reportPss(app, pss);
989 reply.writeNoException();
990 return true;
991 }
992
993 case START_RUNNING_TRANSACTION: {
994 data.enforceInterface(IActivityManager.descriptor);
995 String pkg = data.readString();
996 String cls = data.readString();
997 String action = data.readString();
998 String indata = data.readString();
999 startRunning(pkg, cls, action, indata);
1000 reply.writeNoException();
1001 return true;
1002 }
1003
Dan Egnor60d87622009-12-16 16:32:58 -08001004 case HANDLE_APPLICATION_CRASH_TRANSACTION: {
1005 data.enforceInterface(IActivityManager.descriptor);
1006 IBinder app = data.readStrongBinder();
1007 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
1008 handleApplicationCrash(app, ci);
1009 reply.writeNoException();
1010 return true;
1011 }
1012
1013 case HANDLE_APPLICATION_WTF_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001014 data.enforceInterface(IActivityManager.descriptor);
1015 IBinder app = data.readStrongBinder();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001016 String tag = data.readString();
Dan Egnorb7f03672009-12-09 16:22:32 -08001017 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
Dan Egnor60d87622009-12-16 16:32:58 -08001018 boolean res = handleApplicationWtf(app, tag, ci);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001019 reply.writeNoException();
Dan Egnor60d87622009-12-16 16:32:58 -08001020 reply.writeInt(res ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001021 return true;
1022 }
Dan Egnorb7f03672009-12-09 16:22:32 -08001023
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001024 case SIGNAL_PERSISTENT_PROCESSES_TRANSACTION: {
1025 data.enforceInterface(IActivityManager.descriptor);
1026 int sig = data.readInt();
1027 signalPersistentProcesses(sig);
1028 reply.writeNoException();
1029 return true;
1030 }
1031
Dianne Hackborn03abb812010-01-04 18:43:19 -08001032 case KILL_BACKGROUND_PROCESSES_TRANSACTION: {
1033 data.enforceInterface(IActivityManager.descriptor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001034 String packageName = data.readString();
Dianne Hackborn03abb812010-01-04 18:43:19 -08001035 killBackgroundProcesses(packageName);
1036 reply.writeNoException();
1037 return true;
1038 }
1039
1040 case FORCE_STOP_PACKAGE_TRANSACTION: {
1041 data.enforceInterface(IActivityManager.descriptor);
1042 String packageName = data.readString();
1043 forceStopPackage(packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001044 reply.writeNoException();
1045 return true;
1046 }
1047
1048 case GET_DEVICE_CONFIGURATION_TRANSACTION: {
1049 data.enforceInterface(IActivityManager.descriptor);
1050 ConfigurationInfo config = getDeviceConfigurationInfo();
1051 reply.writeNoException();
1052 config.writeToParcel(reply, 0);
1053 return true;
1054 }
1055
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001056 case PROFILE_CONTROL_TRANSACTION: {
1057 data.enforceInterface(IActivityManager.descriptor);
1058 String process = data.readString();
1059 boolean start = data.readInt() != 0;
1060 String path = data.readString();
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07001061 ParcelFileDescriptor fd = data.readInt() != 0
1062 ? data.readFileDescriptor() : null;
1063 boolean res = profileControl(process, start, path, fd);
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001064 reply.writeNoException();
1065 reply.writeInt(res ? 1 : 0);
1066 return true;
1067 }
1068
Dianne Hackborn55280a92009-05-07 15:53:46 -07001069 case SHUTDOWN_TRANSACTION: {
1070 data.enforceInterface(IActivityManager.descriptor);
1071 boolean res = shutdown(data.readInt());
1072 reply.writeNoException();
1073 reply.writeInt(res ? 1 : 0);
1074 return true;
1075 }
1076
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07001077 case STOP_APP_SWITCHES_TRANSACTION: {
1078 data.enforceInterface(IActivityManager.descriptor);
1079 stopAppSwitches();
1080 reply.writeNoException();
1081 return true;
1082 }
1083
1084 case RESUME_APP_SWITCHES_TRANSACTION: {
1085 data.enforceInterface(IActivityManager.descriptor);
1086 resumeAppSwitches();
1087 reply.writeNoException();
1088 return true;
1089 }
1090
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001091 case PEEK_SERVICE_TRANSACTION: {
1092 data.enforceInterface(IActivityManager.descriptor);
1093 Intent service = Intent.CREATOR.createFromParcel(data);
1094 String resolvedType = data.readString();
1095 IBinder binder = peekService(service, resolvedType);
1096 reply.writeNoException();
1097 reply.writeStrongBinder(binder);
1098 return true;
1099 }
Christopher Tate181fafa2009-05-14 11:12:14 -07001100
1101 case START_BACKUP_AGENT_TRANSACTION: {
1102 data.enforceInterface(IActivityManager.descriptor);
1103 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1104 int backupRestoreMode = data.readInt();
1105 boolean success = bindBackupAgent(info, backupRestoreMode);
1106 reply.writeNoException();
1107 reply.writeInt(success ? 1 : 0);
1108 return true;
1109 }
1110
1111 case BACKUP_AGENT_CREATED_TRANSACTION: {
1112 data.enforceInterface(IActivityManager.descriptor);
1113 String packageName = data.readString();
1114 IBinder agent = data.readStrongBinder();
1115 backupAgentCreated(packageName, agent);
1116 reply.writeNoException();
1117 return true;
1118 }
1119
1120 case UNBIND_BACKUP_AGENT_TRANSACTION: {
1121 data.enforceInterface(IActivityManager.descriptor);
1122 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1123 unbindBackupAgent(info);
1124 reply.writeNoException();
1125 return true;
1126 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07001127
1128 case REGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1129 data.enforceInterface(IActivityManager.descriptor);
1130 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1131 data.readStrongBinder());
1132 registerActivityWatcher(watcher);
1133 return true;
1134 }
1135
1136 case UNREGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1137 data.enforceInterface(IActivityManager.descriptor);
1138 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1139 data.readStrongBinder());
1140 unregisterActivityWatcher(watcher);
1141 return true;
1142 }
Dianne Hackborn2d91af02009-07-16 13:34:33 -07001143
1144 case START_ACTIVITY_IN_PACKAGE_TRANSACTION:
1145 {
1146 data.enforceInterface(IActivityManager.descriptor);
1147 int uid = data.readInt();
1148 Intent intent = Intent.CREATOR.createFromParcel(data);
1149 String resolvedType = data.readString();
1150 IBinder resultTo = data.readStrongBinder();
1151 String resultWho = data.readString();
1152 int requestCode = data.readInt();
1153 boolean onlyIfNeeded = data.readInt() != 0;
1154 int result = startActivityInPackage(uid, intent, resolvedType,
1155 resultTo, resultWho, requestCode, onlyIfNeeded);
1156 reply.writeNoException();
1157 reply.writeInt(result);
1158 return true;
1159 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001160
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07001161 case KILL_APPLICATION_WITH_UID_TRANSACTION: {
1162 data.enforceInterface(IActivityManager.descriptor);
1163 String pkg = data.readString();
1164 int uid = data.readInt();
1165 killApplicationWithUid(pkg, uid);
1166 reply.writeNoException();
1167 return true;
1168 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001169
1170 case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
1171 data.enforceInterface(IActivityManager.descriptor);
1172 String reason = data.readString();
1173 closeSystemDialogs(reason);
1174 reply.writeNoException();
1175 return true;
1176 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001177
1178 case GET_PROCESS_MEMORY_INFO_TRANSACTION: {
1179 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001180 int[] pids = data.createIntArray();
1181 Debug.MemoryInfo[] res = getProcessMemoryInfo(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001182 reply.writeNoException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001183 reply.writeTypedArray(res, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001184 return true;
1185 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07001186
1187 case KILL_APPLICATION_PROCESS_TRANSACTION: {
1188 data.enforceInterface(IActivityManager.descriptor);
1189 String processName = data.readString();
1190 int uid = data.readInt();
1191 killApplicationProcess(processName, uid);
1192 reply.writeNoException();
1193 return true;
1194 }
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001195
1196 case OVERRIDE_PENDING_TRANSITION_TRANSACTION: {
1197 data.enforceInterface(IActivityManager.descriptor);
1198 IBinder token = data.readStrongBinder();
1199 String packageName = data.readString();
1200 int enterAnim = data.readInt();
1201 int exitAnim = data.readInt();
1202 overridePendingTransition(token, packageName, enterAnim, exitAnim);
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08001203 reply.writeNoException();
1204 return true;
1205 }
1206
1207 case IS_USER_A_MONKEY_TRANSACTION: {
1208 data.enforceInterface(IActivityManager.descriptor);
1209 reply.writeInt(isUserAMonkey() ? 1 : 0);
1210 reply.writeNoException();
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001211 return true;
1212 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001213 }
1214
1215 return super.onTransact(code, data, reply, flags);
1216 }
1217
1218 public IBinder asBinder()
1219 {
1220 return this;
1221 }
1222
1223 private static IActivityManager gDefault;
1224}
1225
1226class ActivityManagerProxy implements IActivityManager
1227{
1228 public ActivityManagerProxy(IBinder remote)
1229 {
1230 mRemote = remote;
1231 }
1232
1233 public IBinder asBinder()
1234 {
1235 return mRemote;
1236 }
1237
1238 public int startActivity(IApplicationThread caller, Intent intent,
1239 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1240 IBinder resultTo, String resultWho,
1241 int requestCode, boolean onlyIfNeeded,
1242 boolean debug) throws RemoteException {
1243 Parcel data = Parcel.obtain();
1244 Parcel reply = Parcel.obtain();
1245 data.writeInterfaceToken(IActivityManager.descriptor);
1246 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1247 intent.writeToParcel(data, 0);
1248 data.writeString(resolvedType);
1249 data.writeTypedArray(grantedUriPermissions, 0);
1250 data.writeInt(grantedMode);
1251 data.writeStrongBinder(resultTo);
1252 data.writeString(resultWho);
1253 data.writeInt(requestCode);
1254 data.writeInt(onlyIfNeeded ? 1 : 0);
1255 data.writeInt(debug ? 1 : 0);
1256 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1257 reply.readException();
1258 int result = reply.readInt();
1259 reply.recycle();
1260 data.recycle();
1261 return result;
1262 }
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -08001263 public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
1264 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1265 IBinder resultTo, String resultWho,
1266 int requestCode, boolean onlyIfNeeded,
1267 boolean debug) throws RemoteException {
1268 Parcel data = Parcel.obtain();
1269 Parcel reply = Parcel.obtain();
1270 data.writeInterfaceToken(IActivityManager.descriptor);
1271 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1272 intent.writeToParcel(data, 0);
1273 data.writeString(resolvedType);
1274 data.writeTypedArray(grantedUriPermissions, 0);
1275 data.writeInt(grantedMode);
1276 data.writeStrongBinder(resultTo);
1277 data.writeString(resultWho);
1278 data.writeInt(requestCode);
1279 data.writeInt(onlyIfNeeded ? 1 : 0);
1280 data.writeInt(debug ? 1 : 0);
1281 mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
1282 reply.readException();
1283 WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
1284 reply.recycle();
1285 data.recycle();
1286 return result;
1287 }
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001288 public int startActivityIntentSender(IApplicationThread caller,
1289 IntentSender intent, Intent fillInIntent, String resolvedType,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001290 IBinder resultTo, String resultWho, int requestCode,
1291 int flagsMask, int flagsValues) throws RemoteException {
1292 Parcel data = Parcel.obtain();
1293 Parcel reply = Parcel.obtain();
1294 data.writeInterfaceToken(IActivityManager.descriptor);
1295 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1296 intent.writeToParcel(data, 0);
1297 if (fillInIntent != null) {
1298 data.writeInt(1);
1299 fillInIntent.writeToParcel(data, 0);
1300 } else {
1301 data.writeInt(0);
1302 }
1303 data.writeString(resolvedType);
1304 data.writeStrongBinder(resultTo);
1305 data.writeString(resultWho);
1306 data.writeInt(requestCode);
1307 data.writeInt(flagsMask);
1308 data.writeInt(flagsValues);
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001309 mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001310 reply.readException();
1311 int result = reply.readInt();
1312 reply.recycle();
1313 data.recycle();
1314 return result;
1315 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001316 public boolean startNextMatchingActivity(IBinder callingActivity,
1317 Intent intent) throws RemoteException {
1318 Parcel data = Parcel.obtain();
1319 Parcel reply = Parcel.obtain();
1320 data.writeInterfaceToken(IActivityManager.descriptor);
1321 data.writeStrongBinder(callingActivity);
1322 intent.writeToParcel(data, 0);
1323 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1324 reply.readException();
1325 int result = reply.readInt();
1326 reply.recycle();
1327 data.recycle();
1328 return result != 0;
1329 }
1330 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1331 throws RemoteException {
1332 Parcel data = Parcel.obtain();
1333 Parcel reply = Parcel.obtain();
1334 data.writeInterfaceToken(IActivityManager.descriptor);
1335 data.writeStrongBinder(token);
1336 data.writeInt(resultCode);
1337 if (resultData != null) {
1338 data.writeInt(1);
1339 resultData.writeToParcel(data, 0);
1340 } else {
1341 data.writeInt(0);
1342 }
1343 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1344 reply.readException();
1345 boolean res = reply.readInt() != 0;
1346 data.recycle();
1347 reply.recycle();
1348 return res;
1349 }
1350 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1351 {
1352 Parcel data = Parcel.obtain();
1353 Parcel reply = Parcel.obtain();
1354 data.writeInterfaceToken(IActivityManager.descriptor);
1355 data.writeStrongBinder(token);
1356 data.writeString(resultWho);
1357 data.writeInt(requestCode);
1358 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1359 reply.readException();
1360 data.recycle();
1361 reply.recycle();
1362 }
1363 public Intent registerReceiver(IApplicationThread caller,
1364 IIntentReceiver receiver,
1365 IntentFilter filter, String perm) throws RemoteException
1366 {
1367 Parcel data = Parcel.obtain();
1368 Parcel reply = Parcel.obtain();
1369 data.writeInterfaceToken(IActivityManager.descriptor);
1370 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1371 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1372 filter.writeToParcel(data, 0);
1373 data.writeString(perm);
1374 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1375 reply.readException();
1376 Intent intent = null;
1377 int haveIntent = reply.readInt();
1378 if (haveIntent != 0) {
1379 intent = Intent.CREATOR.createFromParcel(reply);
1380 }
1381 reply.recycle();
1382 data.recycle();
1383 return intent;
1384 }
1385 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1386 {
1387 Parcel data = Parcel.obtain();
1388 Parcel reply = Parcel.obtain();
1389 data.writeInterfaceToken(IActivityManager.descriptor);
1390 data.writeStrongBinder(receiver.asBinder());
1391 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1392 reply.readException();
1393 data.recycle();
1394 reply.recycle();
1395 }
1396 public int broadcastIntent(IApplicationThread caller,
1397 Intent intent, String resolvedType, IIntentReceiver resultTo,
1398 int resultCode, String resultData, Bundle map,
1399 String requiredPermission, boolean serialized,
1400 boolean sticky) throws RemoteException
1401 {
1402 Parcel data = Parcel.obtain();
1403 Parcel reply = Parcel.obtain();
1404 data.writeInterfaceToken(IActivityManager.descriptor);
1405 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1406 intent.writeToParcel(data, 0);
1407 data.writeString(resolvedType);
1408 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1409 data.writeInt(resultCode);
1410 data.writeString(resultData);
1411 data.writeBundle(map);
1412 data.writeString(requiredPermission);
1413 data.writeInt(serialized ? 1 : 0);
1414 data.writeInt(sticky ? 1 : 0);
1415 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1416 reply.readException();
1417 int res = reply.readInt();
1418 reply.recycle();
1419 data.recycle();
1420 return res;
1421 }
1422 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1423 {
1424 Parcel data = Parcel.obtain();
1425 Parcel reply = Parcel.obtain();
1426 data.writeInterfaceToken(IActivityManager.descriptor);
1427 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1428 intent.writeToParcel(data, 0);
1429 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1430 reply.readException();
1431 data.recycle();
1432 reply.recycle();
1433 }
1434 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1435 {
1436 Parcel data = Parcel.obtain();
1437 Parcel reply = Parcel.obtain();
1438 data.writeInterfaceToken(IActivityManager.descriptor);
1439 data.writeStrongBinder(who);
1440 data.writeInt(resultCode);
1441 data.writeString(resultData);
1442 data.writeBundle(map);
1443 data.writeInt(abortBroadcast ? 1 : 0);
1444 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1445 reply.readException();
1446 data.recycle();
1447 reply.recycle();
1448 }
1449 public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
1450 {
1451 Parcel data = Parcel.obtain();
1452 Parcel reply = Parcel.obtain();
1453 data.writeInterfaceToken(IActivityManager.descriptor);
1454 data.writeStrongBinder(token);
1455 data.writeInt(isPersistent ? 1 : 0);
1456 mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
1457 reply.readException();
1458 data.recycle();
1459 reply.recycle();
1460 }
1461 public void attachApplication(IApplicationThread app) throws RemoteException
1462 {
1463 Parcel data = Parcel.obtain();
1464 Parcel reply = Parcel.obtain();
1465 data.writeInterfaceToken(IActivityManager.descriptor);
1466 data.writeStrongBinder(app.asBinder());
1467 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1468 reply.readException();
1469 data.recycle();
1470 reply.recycle();
1471 }
Dianne Hackborne88846e2009-09-30 21:34:25 -07001472 public void activityIdle(IBinder token, Configuration config) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001473 {
1474 Parcel data = Parcel.obtain();
1475 Parcel reply = Parcel.obtain();
1476 data.writeInterfaceToken(IActivityManager.descriptor);
1477 data.writeStrongBinder(token);
Dianne Hackborne88846e2009-09-30 21:34:25 -07001478 if (config != null) {
1479 data.writeInt(1);
1480 config.writeToParcel(data, 0);
1481 } else {
1482 data.writeInt(0);
1483 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001484 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1485 reply.readException();
1486 data.recycle();
1487 reply.recycle();
1488 }
1489 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1490 {
1491 Parcel data = Parcel.obtain();
1492 Parcel reply = Parcel.obtain();
1493 data.writeInterfaceToken(IActivityManager.descriptor);
1494 data.writeStrongBinder(token);
1495 data.writeBundle(state);
1496 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1497 reply.readException();
1498 data.recycle();
1499 reply.recycle();
1500 }
1501 public void activityStopped(IBinder token,
1502 Bitmap thumbnail, CharSequence description) throws RemoteException
1503 {
1504 Parcel data = Parcel.obtain();
1505 Parcel reply = Parcel.obtain();
1506 data.writeInterfaceToken(IActivityManager.descriptor);
1507 data.writeStrongBinder(token);
1508 if (thumbnail != null) {
1509 data.writeInt(1);
1510 thumbnail.writeToParcel(data, 0);
1511 } else {
1512 data.writeInt(0);
1513 }
1514 TextUtils.writeToParcel(description, data, 0);
1515 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1516 reply.readException();
1517 data.recycle();
1518 reply.recycle();
1519 }
1520 public void activityDestroyed(IBinder token) throws RemoteException
1521 {
1522 Parcel data = Parcel.obtain();
1523 Parcel reply = Parcel.obtain();
1524 data.writeInterfaceToken(IActivityManager.descriptor);
1525 data.writeStrongBinder(token);
1526 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1527 reply.readException();
1528 data.recycle();
1529 reply.recycle();
1530 }
1531 public String getCallingPackage(IBinder token) throws RemoteException
1532 {
1533 Parcel data = Parcel.obtain();
1534 Parcel reply = Parcel.obtain();
1535 data.writeInterfaceToken(IActivityManager.descriptor);
1536 data.writeStrongBinder(token);
1537 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1538 reply.readException();
1539 String res = reply.readString();
1540 data.recycle();
1541 reply.recycle();
1542 return res;
1543 }
1544 public ComponentName getCallingActivity(IBinder token)
1545 throws RemoteException {
1546 Parcel data = Parcel.obtain();
1547 Parcel reply = Parcel.obtain();
1548 data.writeInterfaceToken(IActivityManager.descriptor);
1549 data.writeStrongBinder(token);
1550 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1551 reply.readException();
1552 ComponentName res = ComponentName.readFromParcel(reply);
1553 data.recycle();
1554 reply.recycle();
1555 return res;
1556 }
1557 public List getTasks(int maxNum, int flags,
1558 IThumbnailReceiver receiver) throws RemoteException {
1559 Parcel data = Parcel.obtain();
1560 Parcel reply = Parcel.obtain();
1561 data.writeInterfaceToken(IActivityManager.descriptor);
1562 data.writeInt(maxNum);
1563 data.writeInt(flags);
1564 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1565 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1566 reply.readException();
1567 ArrayList list = null;
1568 int N = reply.readInt();
1569 if (N >= 0) {
1570 list = new ArrayList();
1571 while (N > 0) {
1572 ActivityManager.RunningTaskInfo info =
1573 ActivityManager.RunningTaskInfo.CREATOR
1574 .createFromParcel(reply);
1575 list.add(info);
1576 N--;
1577 }
1578 }
1579 data.recycle();
1580 reply.recycle();
1581 return list;
1582 }
1583 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1584 int flags) throws RemoteException {
1585 Parcel data = Parcel.obtain();
1586 Parcel reply = Parcel.obtain();
1587 data.writeInterfaceToken(IActivityManager.descriptor);
1588 data.writeInt(maxNum);
1589 data.writeInt(flags);
1590 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1591 reply.readException();
1592 ArrayList<ActivityManager.RecentTaskInfo> list
1593 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1594 data.recycle();
1595 reply.recycle();
1596 return list;
1597 }
1598 public List getServices(int maxNum, int flags) throws RemoteException {
1599 Parcel data = Parcel.obtain();
1600 Parcel reply = Parcel.obtain();
1601 data.writeInterfaceToken(IActivityManager.descriptor);
1602 data.writeInt(maxNum);
1603 data.writeInt(flags);
1604 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1605 reply.readException();
1606 ArrayList list = null;
1607 int N = reply.readInt();
1608 if (N >= 0) {
1609 list = new ArrayList();
1610 while (N > 0) {
1611 ActivityManager.RunningServiceInfo info =
1612 ActivityManager.RunningServiceInfo.CREATOR
1613 .createFromParcel(reply);
1614 list.add(info);
1615 N--;
1616 }
1617 }
1618 data.recycle();
1619 reply.recycle();
1620 return list;
1621 }
1622 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1623 throws RemoteException {
1624 Parcel data = Parcel.obtain();
1625 Parcel reply = Parcel.obtain();
1626 data.writeInterfaceToken(IActivityManager.descriptor);
1627 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1628 reply.readException();
1629 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1630 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1631 data.recycle();
1632 reply.recycle();
1633 return list;
1634 }
1635 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1636 throws RemoteException {
1637 Parcel data = Parcel.obtain();
1638 Parcel reply = Parcel.obtain();
1639 data.writeInterfaceToken(IActivityManager.descriptor);
1640 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1641 reply.readException();
1642 ArrayList<ActivityManager.RunningAppProcessInfo> list
1643 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1644 data.recycle();
1645 reply.recycle();
1646 return list;
1647 }
1648 public void moveTaskToFront(int task) throws RemoteException
1649 {
1650 Parcel data = Parcel.obtain();
1651 Parcel reply = Parcel.obtain();
1652 data.writeInterfaceToken(IActivityManager.descriptor);
1653 data.writeInt(task);
1654 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1655 reply.readException();
1656 data.recycle();
1657 reply.recycle();
1658 }
1659 public void moveTaskToBack(int task) throws RemoteException
1660 {
1661 Parcel data = Parcel.obtain();
1662 Parcel reply = Parcel.obtain();
1663 data.writeInterfaceToken(IActivityManager.descriptor);
1664 data.writeInt(task);
1665 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1666 reply.readException();
1667 data.recycle();
1668 reply.recycle();
1669 }
1670 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1671 throws RemoteException {
1672 Parcel data = Parcel.obtain();
1673 Parcel reply = Parcel.obtain();
1674 data.writeInterfaceToken(IActivityManager.descriptor);
1675 data.writeStrongBinder(token);
1676 data.writeInt(nonRoot ? 1 : 0);
1677 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1678 reply.readException();
1679 boolean res = reply.readInt() != 0;
1680 data.recycle();
1681 reply.recycle();
1682 return res;
1683 }
1684 public void moveTaskBackwards(int task) throws RemoteException
1685 {
1686 Parcel data = Parcel.obtain();
1687 Parcel reply = Parcel.obtain();
1688 data.writeInterfaceToken(IActivityManager.descriptor);
1689 data.writeInt(task);
1690 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1691 reply.readException();
1692 data.recycle();
1693 reply.recycle();
1694 }
1695 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1696 {
1697 Parcel data = Parcel.obtain();
1698 Parcel reply = Parcel.obtain();
1699 data.writeInterfaceToken(IActivityManager.descriptor);
1700 data.writeStrongBinder(token);
1701 data.writeInt(onlyRoot ? 1 : 0);
1702 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1703 reply.readException();
1704 int res = reply.readInt();
1705 data.recycle();
1706 reply.recycle();
1707 return res;
1708 }
1709 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1710 {
1711 Parcel data = Parcel.obtain();
1712 Parcel reply = Parcel.obtain();
1713 data.writeInterfaceToken(IActivityManager.descriptor);
1714 data.writeStrongBinder(token);
1715 ComponentName.writeToParcel(className, data);
1716 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1717 reply.readException();
1718 data.recycle();
1719 reply.recycle();
1720 }
1721 public void reportThumbnail(IBinder token,
1722 Bitmap thumbnail, CharSequence description) throws RemoteException
1723 {
1724 Parcel data = Parcel.obtain();
1725 Parcel reply = Parcel.obtain();
1726 data.writeInterfaceToken(IActivityManager.descriptor);
1727 data.writeStrongBinder(token);
1728 if (thumbnail != null) {
1729 data.writeInt(1);
1730 thumbnail.writeToParcel(data, 0);
1731 } else {
1732 data.writeInt(0);
1733 }
1734 TextUtils.writeToParcel(description, data, 0);
1735 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1736 reply.readException();
1737 data.recycle();
1738 reply.recycle();
1739 }
1740 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1741 String name) throws RemoteException
1742 {
1743 Parcel data = Parcel.obtain();
1744 Parcel reply = Parcel.obtain();
1745 data.writeInterfaceToken(IActivityManager.descriptor);
1746 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1747 data.writeString(name);
1748 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1749 reply.readException();
1750 int res = reply.readInt();
1751 ContentProviderHolder cph = null;
1752 if (res != 0) {
1753 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1754 }
1755 data.recycle();
1756 reply.recycle();
1757 return cph;
1758 }
1759 public void publishContentProviders(IApplicationThread caller,
1760 List<ContentProviderHolder> providers) throws RemoteException
1761 {
1762 Parcel data = Parcel.obtain();
1763 Parcel reply = Parcel.obtain();
1764 data.writeInterfaceToken(IActivityManager.descriptor);
1765 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1766 data.writeTypedList(providers);
1767 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1768 reply.readException();
1769 data.recycle();
1770 reply.recycle();
1771 }
1772
1773 public void removeContentProvider(IApplicationThread caller,
1774 String name) throws RemoteException {
1775 Parcel data = Parcel.obtain();
1776 Parcel reply = Parcel.obtain();
1777 data.writeInterfaceToken(IActivityManager.descriptor);
1778 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1779 data.writeString(name);
1780 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1781 reply.readException();
1782 data.recycle();
1783 reply.recycle();
1784 }
1785
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07001786 public PendingIntent getRunningServiceControlPanel(ComponentName service)
1787 throws RemoteException
1788 {
1789 Parcel data = Parcel.obtain();
1790 Parcel reply = Parcel.obtain();
1791 data.writeInterfaceToken(IActivityManager.descriptor);
1792 service.writeToParcel(data, 0);
1793 mRemote.transact(GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION, data, reply, 0);
1794 reply.readException();
1795 PendingIntent res = PendingIntent.readPendingIntentOrNullFromParcel(reply);
1796 data.recycle();
1797 reply.recycle();
1798 return res;
1799 }
1800
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001801 public ComponentName startService(IApplicationThread caller, Intent service,
1802 String resolvedType) throws RemoteException
1803 {
1804 Parcel data = Parcel.obtain();
1805 Parcel reply = Parcel.obtain();
1806 data.writeInterfaceToken(IActivityManager.descriptor);
1807 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1808 service.writeToParcel(data, 0);
1809 data.writeString(resolvedType);
1810 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
1811 reply.readException();
1812 ComponentName res = ComponentName.readFromParcel(reply);
1813 data.recycle();
1814 reply.recycle();
1815 return res;
1816 }
1817 public int stopService(IApplicationThread caller, Intent service,
1818 String resolvedType) throws RemoteException
1819 {
1820 Parcel data = Parcel.obtain();
1821 Parcel reply = Parcel.obtain();
1822 data.writeInterfaceToken(IActivityManager.descriptor);
1823 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1824 service.writeToParcel(data, 0);
1825 data.writeString(resolvedType);
1826 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
1827 reply.readException();
1828 int res = reply.readInt();
1829 reply.recycle();
1830 data.recycle();
1831 return res;
1832 }
1833 public boolean stopServiceToken(ComponentName className, IBinder token,
1834 int startId) throws RemoteException {
1835 Parcel data = Parcel.obtain();
1836 Parcel reply = Parcel.obtain();
1837 data.writeInterfaceToken(IActivityManager.descriptor);
1838 ComponentName.writeToParcel(className, data);
1839 data.writeStrongBinder(token);
1840 data.writeInt(startId);
1841 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
1842 reply.readException();
1843 boolean res = reply.readInt() != 0;
1844 data.recycle();
1845 reply.recycle();
1846 return res;
1847 }
1848 public void setServiceForeground(ComponentName className, IBinder token,
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07001849 int id, Notification notification, boolean removeNotification) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001850 Parcel data = Parcel.obtain();
1851 Parcel reply = Parcel.obtain();
1852 data.writeInterfaceToken(IActivityManager.descriptor);
1853 ComponentName.writeToParcel(className, data);
1854 data.writeStrongBinder(token);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07001855 data.writeInt(id);
1856 if (notification != null) {
1857 data.writeInt(1);
1858 notification.writeToParcel(data, 0);
1859 } else {
1860 data.writeInt(0);
1861 }
1862 data.writeInt(removeNotification ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001863 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
1864 reply.readException();
1865 data.recycle();
1866 reply.recycle();
1867 }
1868 public int bindService(IApplicationThread caller, IBinder token,
1869 Intent service, String resolvedType, IServiceConnection connection,
1870 int flags) throws RemoteException {
1871 Parcel data = Parcel.obtain();
1872 Parcel reply = Parcel.obtain();
1873 data.writeInterfaceToken(IActivityManager.descriptor);
1874 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1875 data.writeStrongBinder(token);
1876 service.writeToParcel(data, 0);
1877 data.writeString(resolvedType);
1878 data.writeStrongBinder(connection.asBinder());
1879 data.writeInt(flags);
1880 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
1881 reply.readException();
1882 int res = reply.readInt();
1883 data.recycle();
1884 reply.recycle();
1885 return res;
1886 }
1887 public boolean unbindService(IServiceConnection connection) throws RemoteException
1888 {
1889 Parcel data = Parcel.obtain();
1890 Parcel reply = Parcel.obtain();
1891 data.writeInterfaceToken(IActivityManager.descriptor);
1892 data.writeStrongBinder(connection.asBinder());
1893 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
1894 reply.readException();
1895 boolean res = reply.readInt() != 0;
1896 data.recycle();
1897 reply.recycle();
1898 return res;
1899 }
1900
1901 public void publishService(IBinder token,
1902 Intent intent, IBinder service) throws RemoteException {
1903 Parcel data = Parcel.obtain();
1904 Parcel reply = Parcel.obtain();
1905 data.writeInterfaceToken(IActivityManager.descriptor);
1906 data.writeStrongBinder(token);
1907 intent.writeToParcel(data, 0);
1908 data.writeStrongBinder(service);
1909 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
1910 reply.readException();
1911 data.recycle();
1912 reply.recycle();
1913 }
1914
1915 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
1916 throws RemoteException {
1917 Parcel data = Parcel.obtain();
1918 Parcel reply = Parcel.obtain();
1919 data.writeInterfaceToken(IActivityManager.descriptor);
1920 data.writeStrongBinder(token);
1921 intent.writeToParcel(data, 0);
1922 data.writeInt(doRebind ? 1 : 0);
1923 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
1924 reply.readException();
1925 data.recycle();
1926 reply.recycle();
1927 }
1928
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07001929 public void serviceDoneExecuting(IBinder token, int type, int startId,
1930 int res) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001931 Parcel data = Parcel.obtain();
1932 Parcel reply = Parcel.obtain();
1933 data.writeInterfaceToken(IActivityManager.descriptor);
1934 data.writeStrongBinder(token);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07001935 data.writeInt(type);
1936 data.writeInt(startId);
1937 data.writeInt(res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001938 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1939 reply.readException();
1940 data.recycle();
1941 reply.recycle();
1942 }
1943
1944 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
1945 Parcel data = Parcel.obtain();
1946 Parcel reply = Parcel.obtain();
1947 data.writeInterfaceToken(IActivityManager.descriptor);
1948 service.writeToParcel(data, 0);
1949 data.writeString(resolvedType);
1950 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
1951 reply.readException();
1952 IBinder binder = reply.readStrongBinder();
1953 reply.recycle();
1954 data.recycle();
1955 return binder;
1956 }
1957
Christopher Tate181fafa2009-05-14 11:12:14 -07001958 public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
1959 throws RemoteException {
1960 Parcel data = Parcel.obtain();
1961 Parcel reply = Parcel.obtain();
1962 data.writeInterfaceToken(IActivityManager.descriptor);
1963 app.writeToParcel(data, 0);
1964 data.writeInt(backupRestoreMode);
1965 mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
1966 reply.readException();
1967 boolean success = reply.readInt() != 0;
1968 reply.recycle();
1969 data.recycle();
1970 return success;
1971 }
1972
1973 public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException {
1974 Parcel data = Parcel.obtain();
1975 Parcel reply = Parcel.obtain();
1976 data.writeInterfaceToken(IActivityManager.descriptor);
1977 data.writeString(packageName);
1978 data.writeStrongBinder(agent);
1979 mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0);
1980 reply.recycle();
1981 data.recycle();
1982 }
1983
1984 public void unbindBackupAgent(ApplicationInfo app) throws RemoteException {
1985 Parcel data = Parcel.obtain();
1986 Parcel reply = Parcel.obtain();
1987 data.writeInterfaceToken(IActivityManager.descriptor);
1988 app.writeToParcel(data, 0);
1989 mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0);
1990 reply.readException();
1991 reply.recycle();
1992 data.recycle();
1993 }
1994
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001995 public boolean startInstrumentation(ComponentName className, String profileFile,
1996 int flags, Bundle arguments, IInstrumentationWatcher watcher)
1997 throws RemoteException {
1998 Parcel data = Parcel.obtain();
1999 Parcel reply = Parcel.obtain();
2000 data.writeInterfaceToken(IActivityManager.descriptor);
2001 ComponentName.writeToParcel(className, data);
2002 data.writeString(profileFile);
2003 data.writeInt(flags);
2004 data.writeBundle(arguments);
2005 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2006 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2007 reply.readException();
2008 boolean res = reply.readInt() != 0;
2009 reply.recycle();
2010 data.recycle();
2011 return res;
2012 }
2013
2014 public void finishInstrumentation(IApplicationThread target,
2015 int resultCode, Bundle results) throws RemoteException {
2016 Parcel data = Parcel.obtain();
2017 Parcel reply = Parcel.obtain();
2018 data.writeInterfaceToken(IActivityManager.descriptor);
2019 data.writeStrongBinder(target != null ? target.asBinder() : null);
2020 data.writeInt(resultCode);
2021 data.writeBundle(results);
2022 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2023 reply.readException();
2024 data.recycle();
2025 reply.recycle();
2026 }
2027 public Configuration getConfiguration() throws RemoteException
2028 {
2029 Parcel data = Parcel.obtain();
2030 Parcel reply = Parcel.obtain();
2031 data.writeInterfaceToken(IActivityManager.descriptor);
2032 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
2033 reply.readException();
2034 Configuration res = Configuration.CREATOR.createFromParcel(reply);
2035 reply.recycle();
2036 data.recycle();
2037 return res;
2038 }
2039 public void updateConfiguration(Configuration values) throws RemoteException
2040 {
2041 Parcel data = Parcel.obtain();
2042 Parcel reply = Parcel.obtain();
2043 data.writeInterfaceToken(IActivityManager.descriptor);
2044 values.writeToParcel(data, 0);
2045 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
2046 reply.readException();
2047 data.recycle();
2048 reply.recycle();
2049 }
2050 public void setRequestedOrientation(IBinder token, int requestedOrientation)
2051 throws RemoteException {
2052 Parcel data = Parcel.obtain();
2053 Parcel reply = Parcel.obtain();
2054 data.writeInterfaceToken(IActivityManager.descriptor);
2055 data.writeStrongBinder(token);
2056 data.writeInt(requestedOrientation);
2057 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2058 reply.readException();
2059 data.recycle();
2060 reply.recycle();
2061 }
2062 public int getRequestedOrientation(IBinder token) throws RemoteException {
2063 Parcel data = Parcel.obtain();
2064 Parcel reply = Parcel.obtain();
2065 data.writeInterfaceToken(IActivityManager.descriptor);
2066 data.writeStrongBinder(token);
2067 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2068 reply.readException();
2069 int res = reply.readInt();
2070 data.recycle();
2071 reply.recycle();
2072 return res;
2073 }
2074 public ComponentName getActivityClassForToken(IBinder token)
2075 throws RemoteException {
2076 Parcel data = Parcel.obtain();
2077 Parcel reply = Parcel.obtain();
2078 data.writeInterfaceToken(IActivityManager.descriptor);
2079 data.writeStrongBinder(token);
2080 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
2081 reply.readException();
2082 ComponentName res = ComponentName.readFromParcel(reply);
2083 data.recycle();
2084 reply.recycle();
2085 return res;
2086 }
2087 public String getPackageForToken(IBinder token) throws RemoteException
2088 {
2089 Parcel data = Parcel.obtain();
2090 Parcel reply = Parcel.obtain();
2091 data.writeInterfaceToken(IActivityManager.descriptor);
2092 data.writeStrongBinder(token);
2093 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
2094 reply.readException();
2095 String res = reply.readString();
2096 data.recycle();
2097 reply.recycle();
2098 return res;
2099 }
2100 public IIntentSender getIntentSender(int type,
2101 String packageName, IBinder token, String resultWho,
2102 int requestCode, Intent intent, String resolvedType, int flags)
2103 throws RemoteException {
2104 Parcel data = Parcel.obtain();
2105 Parcel reply = Parcel.obtain();
2106 data.writeInterfaceToken(IActivityManager.descriptor);
2107 data.writeInt(type);
2108 data.writeString(packageName);
2109 data.writeStrongBinder(token);
2110 data.writeString(resultWho);
2111 data.writeInt(requestCode);
2112 if (intent != null) {
2113 data.writeInt(1);
2114 intent.writeToParcel(data, 0);
2115 } else {
2116 data.writeInt(0);
2117 }
2118 data.writeString(resolvedType);
2119 data.writeInt(flags);
2120 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
2121 reply.readException();
2122 IIntentSender res = IIntentSender.Stub.asInterface(
2123 reply.readStrongBinder());
2124 data.recycle();
2125 reply.recycle();
2126 return res;
2127 }
2128 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
2129 Parcel data = Parcel.obtain();
2130 Parcel reply = Parcel.obtain();
2131 data.writeInterfaceToken(IActivityManager.descriptor);
2132 data.writeStrongBinder(sender.asBinder());
2133 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
2134 reply.readException();
2135 data.recycle();
2136 reply.recycle();
2137 }
2138 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
2139 Parcel data = Parcel.obtain();
2140 Parcel reply = Parcel.obtain();
2141 data.writeInterfaceToken(IActivityManager.descriptor);
2142 data.writeStrongBinder(sender.asBinder());
2143 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
2144 reply.readException();
2145 String res = reply.readString();
2146 data.recycle();
2147 reply.recycle();
2148 return res;
2149 }
2150 public void setProcessLimit(int max) throws RemoteException
2151 {
2152 Parcel data = Parcel.obtain();
2153 Parcel reply = Parcel.obtain();
2154 data.writeInterfaceToken(IActivityManager.descriptor);
2155 data.writeInt(max);
2156 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2157 reply.readException();
2158 data.recycle();
2159 reply.recycle();
2160 }
2161 public int getProcessLimit() throws RemoteException
2162 {
2163 Parcel data = Parcel.obtain();
2164 Parcel reply = Parcel.obtain();
2165 data.writeInterfaceToken(IActivityManager.descriptor);
2166 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2167 reply.readException();
2168 int res = reply.readInt();
2169 data.recycle();
2170 reply.recycle();
2171 return res;
2172 }
2173 public void setProcessForeground(IBinder token, int pid,
2174 boolean isForeground) throws RemoteException {
2175 Parcel data = Parcel.obtain();
2176 Parcel reply = Parcel.obtain();
2177 data.writeInterfaceToken(IActivityManager.descriptor);
2178 data.writeStrongBinder(token);
2179 data.writeInt(pid);
2180 data.writeInt(isForeground ? 1 : 0);
2181 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
2182 reply.readException();
2183 data.recycle();
2184 reply.recycle();
2185 }
2186 public int checkPermission(String permission, int pid, int uid)
2187 throws RemoteException {
2188 Parcel data = Parcel.obtain();
2189 Parcel reply = Parcel.obtain();
2190 data.writeInterfaceToken(IActivityManager.descriptor);
2191 data.writeString(permission);
2192 data.writeInt(pid);
2193 data.writeInt(uid);
2194 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
2195 reply.readException();
2196 int res = reply.readInt();
2197 data.recycle();
2198 reply.recycle();
2199 return res;
2200 }
2201 public boolean clearApplicationUserData(final String packageName,
2202 final IPackageDataObserver observer) throws RemoteException {
2203 Parcel data = Parcel.obtain();
2204 Parcel reply = Parcel.obtain();
2205 data.writeInterfaceToken(IActivityManager.descriptor);
2206 data.writeString(packageName);
2207 data.writeStrongBinder(observer.asBinder());
2208 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
2209 reply.readException();
2210 boolean res = reply.readInt() != 0;
2211 data.recycle();
2212 reply.recycle();
2213 return res;
2214 }
2215 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
2216 throws RemoteException {
2217 Parcel data = Parcel.obtain();
2218 Parcel reply = Parcel.obtain();
2219 data.writeInterfaceToken(IActivityManager.descriptor);
2220 uri.writeToParcel(data, 0);
2221 data.writeInt(pid);
2222 data.writeInt(uid);
2223 data.writeInt(mode);
2224 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
2225 reply.readException();
2226 int res = reply.readInt();
2227 data.recycle();
2228 reply.recycle();
2229 return res;
2230 }
2231 public void grantUriPermission(IApplicationThread caller, String targetPkg,
2232 Uri uri, int mode) throws RemoteException {
2233 Parcel data = Parcel.obtain();
2234 Parcel reply = Parcel.obtain();
2235 data.writeInterfaceToken(IActivityManager.descriptor);
2236 data.writeStrongBinder(caller.asBinder());
2237 data.writeString(targetPkg);
2238 uri.writeToParcel(data, 0);
2239 data.writeInt(mode);
2240 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2241 reply.readException();
2242 data.recycle();
2243 reply.recycle();
2244 }
2245 public void revokeUriPermission(IApplicationThread caller, Uri uri,
2246 int mode) throws RemoteException {
2247 Parcel data = Parcel.obtain();
2248 Parcel reply = Parcel.obtain();
2249 data.writeInterfaceToken(IActivityManager.descriptor);
2250 data.writeStrongBinder(caller.asBinder());
2251 uri.writeToParcel(data, 0);
2252 data.writeInt(mode);
2253 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2254 reply.readException();
2255 data.recycle();
2256 reply.recycle();
2257 }
2258 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
2259 throws RemoteException {
2260 Parcel data = Parcel.obtain();
2261 Parcel reply = Parcel.obtain();
2262 data.writeInterfaceToken(IActivityManager.descriptor);
2263 data.writeStrongBinder(who.asBinder());
2264 data.writeInt(waiting ? 1 : 0);
2265 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
2266 reply.readException();
2267 data.recycle();
2268 reply.recycle();
2269 }
2270 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
2271 Parcel data = Parcel.obtain();
2272 Parcel reply = Parcel.obtain();
2273 data.writeInterfaceToken(IActivityManager.descriptor);
2274 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
2275 reply.readException();
2276 outInfo.readFromParcel(reply);
2277 data.recycle();
2278 reply.recycle();
2279 }
2280 public void unhandledBack() throws RemoteException
2281 {
2282 Parcel data = Parcel.obtain();
2283 Parcel reply = Parcel.obtain();
2284 data.writeInterfaceToken(IActivityManager.descriptor);
2285 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
2286 reply.readException();
2287 data.recycle();
2288 reply.recycle();
2289 }
2290 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
2291 {
2292 Parcel data = Parcel.obtain();
2293 Parcel reply = Parcel.obtain();
2294 data.writeInterfaceToken(IActivityManager.descriptor);
2295 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
2296 reply.readException();
2297 ParcelFileDescriptor pfd = null;
2298 if (reply.readInt() != 0) {
2299 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
2300 }
2301 data.recycle();
2302 reply.recycle();
2303 return pfd;
2304 }
2305 public void goingToSleep() throws RemoteException
2306 {
2307 Parcel data = Parcel.obtain();
2308 Parcel reply = Parcel.obtain();
2309 data.writeInterfaceToken(IActivityManager.descriptor);
2310 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
2311 reply.readException();
2312 data.recycle();
2313 reply.recycle();
2314 }
2315 public void wakingUp() throws RemoteException
2316 {
2317 Parcel data = Parcel.obtain();
2318 Parcel reply = Parcel.obtain();
2319 data.writeInterfaceToken(IActivityManager.descriptor);
2320 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
2321 reply.readException();
2322 data.recycle();
2323 reply.recycle();
2324 }
2325 public void setDebugApp(
2326 String packageName, boolean waitForDebugger, boolean persistent)
2327 throws RemoteException
2328 {
2329 Parcel data = Parcel.obtain();
2330 Parcel reply = Parcel.obtain();
2331 data.writeInterfaceToken(IActivityManager.descriptor);
2332 data.writeString(packageName);
2333 data.writeInt(waitForDebugger ? 1 : 0);
2334 data.writeInt(persistent ? 1 : 0);
2335 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2336 reply.readException();
2337 data.recycle();
2338 reply.recycle();
2339 }
2340 public void setAlwaysFinish(boolean enabled) throws RemoteException
2341 {
2342 Parcel data = Parcel.obtain();
2343 Parcel reply = Parcel.obtain();
2344 data.writeInterfaceToken(IActivityManager.descriptor);
2345 data.writeInt(enabled ? 1 : 0);
2346 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2347 reply.readException();
2348 data.recycle();
2349 reply.recycle();
2350 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002351 public void setActivityController(IActivityController watcher) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002352 {
2353 Parcel data = Parcel.obtain();
2354 Parcel reply = Parcel.obtain();
2355 data.writeInterfaceToken(IActivityManager.descriptor);
2356 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002357 mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002358 reply.readException();
2359 data.recycle();
2360 reply.recycle();
2361 }
2362 public void enterSafeMode() throws RemoteException {
2363 Parcel data = Parcel.obtain();
2364 data.writeInterfaceToken(IActivityManager.descriptor);
2365 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2366 data.recycle();
2367 }
2368 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2369 Parcel data = Parcel.obtain();
2370 data.writeStrongBinder(sender.asBinder());
2371 data.writeInterfaceToken(IActivityManager.descriptor);
2372 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2373 data.recycle();
2374 }
2375 public boolean killPidsForMemory(int[] pids) throws RemoteException {
2376 Parcel data = Parcel.obtain();
2377 Parcel reply = Parcel.obtain();
2378 data.writeInterfaceToken(IActivityManager.descriptor);
2379 data.writeIntArray(pids);
2380 mRemote.transact(KILL_PIDS_FOR_MEMORY_TRANSACTION, data, reply, 0);
2381 boolean res = reply.readInt() != 0;
2382 data.recycle();
2383 reply.recycle();
2384 return res;
2385 }
2386 public void reportPss(IApplicationThread caller, int pss) throws RemoteException {
2387 Parcel data = Parcel.obtain();
2388 data.writeInterfaceToken(IActivityManager.descriptor);
2389 data.writeStrongBinder(caller.asBinder());
2390 data.writeInt(pss);
2391 mRemote.transact(REPORT_PSS_TRANSACTION, data, null, 0);
2392 data.recycle();
2393 }
2394 public void startRunning(String pkg, String cls, String action,
2395 String indata) throws RemoteException {
2396 Parcel data = Parcel.obtain();
2397 Parcel reply = Parcel.obtain();
2398 data.writeInterfaceToken(IActivityManager.descriptor);
2399 data.writeString(pkg);
2400 data.writeString(cls);
2401 data.writeString(action);
2402 data.writeString(indata);
2403 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2404 reply.readException();
2405 data.recycle();
2406 reply.recycle();
2407 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002408 public boolean testIsSystemReady()
2409 {
2410 /* this base class version is never called */
2411 return true;
2412 }
Dan Egnor60d87622009-12-16 16:32:58 -08002413 public void handleApplicationCrash(IBinder app,
2414 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
2415 {
2416 Parcel data = Parcel.obtain();
2417 Parcel reply = Parcel.obtain();
2418 data.writeInterfaceToken(IActivityManager.descriptor);
2419 data.writeStrongBinder(app);
2420 crashInfo.writeToParcel(data, 0);
2421 mRemote.transact(HANDLE_APPLICATION_CRASH_TRANSACTION, data, reply, 0);
2422 reply.readException();
2423 reply.recycle();
2424 data.recycle();
2425 }
2426 public boolean handleApplicationWtf(IBinder app, String tag,
Dan Egnorb7f03672009-12-09 16:22:32 -08002427 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002428 {
2429 Parcel data = Parcel.obtain();
2430 Parcel reply = Parcel.obtain();
2431 data.writeInterfaceToken(IActivityManager.descriptor);
2432 data.writeStrongBinder(app);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002433 data.writeString(tag);
Dan Egnorb7f03672009-12-09 16:22:32 -08002434 crashInfo.writeToParcel(data, 0);
Dan Egnor60d87622009-12-16 16:32:58 -08002435 mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002436 reply.readException();
Dan Egnor60d87622009-12-16 16:32:58 -08002437 boolean res = reply.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002438 reply.recycle();
2439 data.recycle();
Dan Egnor60d87622009-12-16 16:32:58 -08002440 return res;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002441 }
Dan Egnorb7f03672009-12-09 16:22:32 -08002442
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002443 public void signalPersistentProcesses(int sig) throws RemoteException {
2444 Parcel data = Parcel.obtain();
2445 Parcel reply = Parcel.obtain();
2446 data.writeInterfaceToken(IActivityManager.descriptor);
2447 data.writeInt(sig);
2448 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2449 reply.readException();
2450 data.recycle();
2451 reply.recycle();
2452 }
2453
Dianne Hackborn03abb812010-01-04 18:43:19 -08002454 public void killBackgroundProcesses(String packageName) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002455 Parcel data = Parcel.obtain();
2456 Parcel reply = Parcel.obtain();
2457 data.writeInterfaceToken(IActivityManager.descriptor);
2458 data.writeString(packageName);
Dianne Hackborn03abb812010-01-04 18:43:19 -08002459 mRemote.transact(KILL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0);
2460 reply.readException();
2461 data.recycle();
2462 reply.recycle();
2463 }
2464
2465 public void forceStopPackage(String packageName) throws RemoteException {
2466 Parcel data = Parcel.obtain();
2467 Parcel reply = Parcel.obtain();
2468 data.writeInterfaceToken(IActivityManager.descriptor);
2469 data.writeString(packageName);
2470 mRemote.transact(FORCE_STOP_PACKAGE_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002471 reply.readException();
2472 data.recycle();
2473 reply.recycle();
2474 }
2475
2476 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2477 {
2478 Parcel data = Parcel.obtain();
2479 Parcel reply = Parcel.obtain();
2480 data.writeInterfaceToken(IActivityManager.descriptor);
2481 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2482 reply.readException();
2483 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2484 reply.recycle();
2485 data.recycle();
2486 return res;
2487 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002488
2489 public boolean profileControl(String process, boolean start,
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002490 String path, ParcelFileDescriptor fd) throws RemoteException
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002491 {
2492 Parcel data = Parcel.obtain();
2493 Parcel reply = Parcel.obtain();
2494 data.writeInterfaceToken(IActivityManager.descriptor);
2495 data.writeString(process);
2496 data.writeInt(start ? 1 : 0);
2497 data.writeString(path);
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002498 if (fd != null) {
2499 data.writeInt(1);
2500 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
2501 } else {
2502 data.writeInt(0);
2503 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002504 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2505 reply.readException();
2506 boolean res = reply.readInt() != 0;
2507 reply.recycle();
2508 data.recycle();
2509 return res;
2510 }
2511
Dianne Hackborn55280a92009-05-07 15:53:46 -07002512 public boolean shutdown(int timeout) throws RemoteException
2513 {
2514 Parcel data = Parcel.obtain();
2515 Parcel reply = Parcel.obtain();
2516 data.writeInterfaceToken(IActivityManager.descriptor);
2517 data.writeInt(timeout);
2518 mRemote.transact(SHUTDOWN_TRANSACTION, data, reply, 0);
2519 reply.readException();
2520 boolean res = reply.readInt() != 0;
2521 reply.recycle();
2522 data.recycle();
2523 return res;
2524 }
2525
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07002526 public void stopAppSwitches() throws RemoteException {
2527 Parcel data = Parcel.obtain();
2528 Parcel reply = Parcel.obtain();
2529 data.writeInterfaceToken(IActivityManager.descriptor);
2530 mRemote.transact(STOP_APP_SWITCHES_TRANSACTION, data, reply, 0);
2531 reply.readException();
2532 reply.recycle();
2533 data.recycle();
2534 }
2535
2536 public void resumeAppSwitches() throws RemoteException {
2537 Parcel data = Parcel.obtain();
2538 Parcel reply = Parcel.obtain();
2539 data.writeInterfaceToken(IActivityManager.descriptor);
2540 mRemote.transact(RESUME_APP_SWITCHES_TRANSACTION, data, reply, 0);
2541 reply.readException();
2542 reply.recycle();
2543 data.recycle();
2544 }
2545
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002546 public void registerActivityWatcher(IActivityWatcher watcher)
2547 throws RemoteException {
2548 Parcel data = Parcel.obtain();
2549 Parcel reply = Parcel.obtain();
2550 data.writeInterfaceToken(IActivityManager.descriptor);
2551 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2552 mRemote.transact(REGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2553 reply.readException();
2554 data.recycle();
2555 reply.recycle();
2556 }
2557
2558 public void unregisterActivityWatcher(IActivityWatcher watcher)
2559 throws RemoteException {
2560 Parcel data = Parcel.obtain();
2561 Parcel reply = Parcel.obtain();
2562 data.writeInterfaceToken(IActivityManager.descriptor);
2563 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2564 mRemote.transact(UNREGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2565 reply.readException();
2566 data.recycle();
2567 reply.recycle();
2568 }
2569
Dianne Hackborn2d91af02009-07-16 13:34:33 -07002570 public int startActivityInPackage(int uid,
2571 Intent intent, String resolvedType, IBinder resultTo,
2572 String resultWho, int requestCode, boolean onlyIfNeeded)
2573 throws RemoteException {
2574 Parcel data = Parcel.obtain();
2575 Parcel reply = Parcel.obtain();
2576 data.writeInterfaceToken(IActivityManager.descriptor);
2577 data.writeInt(uid);
2578 intent.writeToParcel(data, 0);
2579 data.writeString(resolvedType);
2580 data.writeStrongBinder(resultTo);
2581 data.writeString(resultWho);
2582 data.writeInt(requestCode);
2583 data.writeInt(onlyIfNeeded ? 1 : 0);
2584 mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
2585 reply.readException();
2586 int result = reply.readInt();
2587 reply.recycle();
2588 data.recycle();
2589 return result;
2590 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002591
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07002592 public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
2593 Parcel data = Parcel.obtain();
2594 Parcel reply = Parcel.obtain();
2595 data.writeInterfaceToken(IActivityManager.descriptor);
2596 data.writeString(pkg);
2597 data.writeInt(uid);
2598 mRemote.transact(KILL_APPLICATION_WITH_UID_TRANSACTION, data, reply, 0);
2599 reply.readException();
2600 data.recycle();
2601 reply.recycle();
2602 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002603
2604 public void closeSystemDialogs(String reason) throws RemoteException {
2605 Parcel data = Parcel.obtain();
2606 Parcel reply = Parcel.obtain();
2607 data.writeInterfaceToken(IActivityManager.descriptor);
2608 data.writeString(reason);
2609 mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
2610 reply.readException();
2611 data.recycle();
2612 reply.recycle();
2613 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002614
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002615 public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002616 throws RemoteException {
2617 Parcel data = Parcel.obtain();
2618 Parcel reply = Parcel.obtain();
2619 data.writeInterfaceToken(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002620 data.writeIntArray(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002621 mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
2622 reply.readException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002623 Debug.MemoryInfo[] res = reply.createTypedArray(Debug.MemoryInfo.CREATOR);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002624 data.recycle();
2625 reply.recycle();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002626 return res;
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002627 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07002628
2629 public void killApplicationProcess(String processName, int uid) throws RemoteException {
2630 Parcel data = Parcel.obtain();
2631 Parcel reply = Parcel.obtain();
2632 data.writeInterfaceToken(IActivityManager.descriptor);
2633 data.writeString(processName);
2634 data.writeInt(uid);
2635 mRemote.transact(KILL_APPLICATION_PROCESS_TRANSACTION, data, reply, 0);
2636 reply.readException();
2637 data.recycle();
2638 reply.recycle();
2639 }
2640
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07002641 public void overridePendingTransition(IBinder token, String packageName,
2642 int enterAnim, int exitAnim) throws RemoteException {
2643 Parcel data = Parcel.obtain();
2644 Parcel reply = Parcel.obtain();
2645 data.writeInterfaceToken(IActivityManager.descriptor);
2646 data.writeStrongBinder(token);
2647 data.writeString(packageName);
2648 data.writeInt(enterAnim);
2649 data.writeInt(exitAnim);
2650 mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
2651 reply.readException();
2652 data.recycle();
2653 reply.recycle();
2654 }
2655
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08002656 public boolean isUserAMonkey() throws RemoteException {
2657 Parcel data = Parcel.obtain();
2658 Parcel reply = Parcel.obtain();
2659 data.writeInterfaceToken(IActivityManager.descriptor);
2660 mRemote.transact(IS_USER_A_MONKEY_TRANSACTION, data, reply, 0);
2661 reply.readException();
2662 boolean res = reply.readInt() != 0;
2663 data.recycle();
2664 reply.recycle();
2665 return res;
2666 }
2667
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002668 private IBinder mRemote;
2669}