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