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