blob: 3b8aee9afc23ed34c70d7a49a9223c95c5ba93db [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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800982 case HANDLE_APPLICATION_ERROR_TRANSACTION: {
983 data.enforceInterface(IActivityManager.descriptor);
984 IBinder app = data.readStrongBinder();
985 int fl = data.readInt();
986 String tag = data.readString();
987 String shortMsg = data.readString();
988 String longMsg = data.readString();
989 byte[] crashData = data.createByteArray();
990 int res = handleApplicationError(app, fl, tag, shortMsg, longMsg,
991 crashData);
992 reply.writeNoException();
993 reply.writeInt(res);
994 return true;
995 }
996
997 case SIGNAL_PERSISTENT_PROCESSES_TRANSACTION: {
998 data.enforceInterface(IActivityManager.descriptor);
999 int sig = data.readInt();
1000 signalPersistentProcesses(sig);
1001 reply.writeNoException();
1002 return true;
1003 }
1004
1005 case RESTART_PACKAGE_TRANSACTION: {
1006 data.enforceInterface(IActivityManager.descriptor);
1007 String packageName = data.readString();
1008 restartPackage(packageName);
1009 reply.writeNoException();
1010 return true;
1011 }
1012
1013 case GET_DEVICE_CONFIGURATION_TRANSACTION: {
1014 data.enforceInterface(IActivityManager.descriptor);
1015 ConfigurationInfo config = getDeviceConfigurationInfo();
1016 reply.writeNoException();
1017 config.writeToParcel(reply, 0);
1018 return true;
1019 }
1020
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001021 case PROFILE_CONTROL_TRANSACTION: {
1022 data.enforceInterface(IActivityManager.descriptor);
1023 String process = data.readString();
1024 boolean start = data.readInt() != 0;
1025 String path = data.readString();
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07001026 ParcelFileDescriptor fd = data.readInt() != 0
1027 ? data.readFileDescriptor() : null;
1028 boolean res = profileControl(process, start, path, fd);
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001029 reply.writeNoException();
1030 reply.writeInt(res ? 1 : 0);
1031 return true;
1032 }
1033
Dianne Hackborn55280a92009-05-07 15:53:46 -07001034 case SHUTDOWN_TRANSACTION: {
1035 data.enforceInterface(IActivityManager.descriptor);
1036 boolean res = shutdown(data.readInt());
1037 reply.writeNoException();
1038 reply.writeInt(res ? 1 : 0);
1039 return true;
1040 }
1041
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07001042 case STOP_APP_SWITCHES_TRANSACTION: {
1043 data.enforceInterface(IActivityManager.descriptor);
1044 stopAppSwitches();
1045 reply.writeNoException();
1046 return true;
1047 }
1048
1049 case RESUME_APP_SWITCHES_TRANSACTION: {
1050 data.enforceInterface(IActivityManager.descriptor);
1051 resumeAppSwitches();
1052 reply.writeNoException();
1053 return true;
1054 }
1055
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001056 case PEEK_SERVICE_TRANSACTION: {
1057 data.enforceInterface(IActivityManager.descriptor);
1058 Intent service = Intent.CREATOR.createFromParcel(data);
1059 String resolvedType = data.readString();
1060 IBinder binder = peekService(service, resolvedType);
1061 reply.writeNoException();
1062 reply.writeStrongBinder(binder);
1063 return true;
1064 }
Christopher Tate181fafa2009-05-14 11:12:14 -07001065
1066 case START_BACKUP_AGENT_TRANSACTION: {
1067 data.enforceInterface(IActivityManager.descriptor);
1068 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1069 int backupRestoreMode = data.readInt();
1070 boolean success = bindBackupAgent(info, backupRestoreMode);
1071 reply.writeNoException();
1072 reply.writeInt(success ? 1 : 0);
1073 return true;
1074 }
1075
1076 case BACKUP_AGENT_CREATED_TRANSACTION: {
1077 data.enforceInterface(IActivityManager.descriptor);
1078 String packageName = data.readString();
1079 IBinder agent = data.readStrongBinder();
1080 backupAgentCreated(packageName, agent);
1081 reply.writeNoException();
1082 return true;
1083 }
1084
1085 case UNBIND_BACKUP_AGENT_TRANSACTION: {
1086 data.enforceInterface(IActivityManager.descriptor);
1087 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1088 unbindBackupAgent(info);
1089 reply.writeNoException();
1090 return true;
1091 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07001092
1093 case REGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1094 data.enforceInterface(IActivityManager.descriptor);
1095 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1096 data.readStrongBinder());
1097 registerActivityWatcher(watcher);
1098 return true;
1099 }
1100
1101 case UNREGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1102 data.enforceInterface(IActivityManager.descriptor);
1103 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1104 data.readStrongBinder());
1105 unregisterActivityWatcher(watcher);
1106 return true;
1107 }
Dianne Hackborn2d91af02009-07-16 13:34:33 -07001108
1109 case START_ACTIVITY_IN_PACKAGE_TRANSACTION:
1110 {
1111 data.enforceInterface(IActivityManager.descriptor);
1112 int uid = data.readInt();
1113 Intent intent = Intent.CREATOR.createFromParcel(data);
1114 String resolvedType = data.readString();
1115 IBinder resultTo = data.readStrongBinder();
1116 String resultWho = data.readString();
1117 int requestCode = data.readInt();
1118 boolean onlyIfNeeded = data.readInt() != 0;
1119 int result = startActivityInPackage(uid, intent, resolvedType,
1120 resultTo, resultWho, requestCode, onlyIfNeeded);
1121 reply.writeNoException();
1122 reply.writeInt(result);
1123 return true;
1124 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001125
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07001126 case KILL_APPLICATION_WITH_UID_TRANSACTION: {
1127 data.enforceInterface(IActivityManager.descriptor);
1128 String pkg = data.readString();
1129 int uid = data.readInt();
1130 killApplicationWithUid(pkg, uid);
1131 reply.writeNoException();
1132 return true;
1133 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001134
1135 case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
1136 data.enforceInterface(IActivityManager.descriptor);
1137 String reason = data.readString();
1138 closeSystemDialogs(reason);
1139 reply.writeNoException();
1140 return true;
1141 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001142
1143 case GET_PROCESS_MEMORY_INFO_TRANSACTION: {
1144 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001145 int[] pids = data.createIntArray();
1146 Debug.MemoryInfo[] res = getProcessMemoryInfo(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001147 reply.writeNoException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001148 reply.writeTypedArray(res, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001149 return true;
1150 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07001151
1152 case KILL_APPLICATION_PROCESS_TRANSACTION: {
1153 data.enforceInterface(IActivityManager.descriptor);
1154 String processName = data.readString();
1155 int uid = data.readInt();
1156 killApplicationProcess(processName, uid);
1157 reply.writeNoException();
1158 return true;
1159 }
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001160
1161 case OVERRIDE_PENDING_TRANSITION_TRANSACTION: {
1162 data.enforceInterface(IActivityManager.descriptor);
1163 IBinder token = data.readStrongBinder();
1164 String packageName = data.readString();
1165 int enterAnim = data.readInt();
1166 int exitAnim = data.readInt();
1167 overridePendingTransition(token, packageName, enterAnim, exitAnim);
1168 return true;
1169 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001170 }
1171
1172 return super.onTransact(code, data, reply, flags);
1173 }
1174
1175 public IBinder asBinder()
1176 {
1177 return this;
1178 }
1179
1180 private static IActivityManager gDefault;
1181}
1182
1183class ActivityManagerProxy implements IActivityManager
1184{
1185 public ActivityManagerProxy(IBinder remote)
1186 {
1187 mRemote = remote;
1188 }
1189
1190 public IBinder asBinder()
1191 {
1192 return mRemote;
1193 }
1194
1195 public int startActivity(IApplicationThread caller, Intent intent,
1196 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1197 IBinder resultTo, String resultWho,
1198 int requestCode, boolean onlyIfNeeded,
1199 boolean debug) throws RemoteException {
1200 Parcel data = Parcel.obtain();
1201 Parcel reply = Parcel.obtain();
1202 data.writeInterfaceToken(IActivityManager.descriptor);
1203 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1204 intent.writeToParcel(data, 0);
1205 data.writeString(resolvedType);
1206 data.writeTypedArray(grantedUriPermissions, 0);
1207 data.writeInt(grantedMode);
1208 data.writeStrongBinder(resultTo);
1209 data.writeString(resultWho);
1210 data.writeInt(requestCode);
1211 data.writeInt(onlyIfNeeded ? 1 : 0);
1212 data.writeInt(debug ? 1 : 0);
1213 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1214 reply.readException();
1215 int result = reply.readInt();
1216 reply.recycle();
1217 data.recycle();
1218 return result;
1219 }
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001220 public int startActivityIntentSender(IApplicationThread caller,
1221 IntentSender intent, Intent fillInIntent, String resolvedType,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001222 IBinder resultTo, String resultWho, int requestCode,
1223 int flagsMask, int flagsValues) throws RemoteException {
1224 Parcel data = Parcel.obtain();
1225 Parcel reply = Parcel.obtain();
1226 data.writeInterfaceToken(IActivityManager.descriptor);
1227 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1228 intent.writeToParcel(data, 0);
1229 if (fillInIntent != null) {
1230 data.writeInt(1);
1231 fillInIntent.writeToParcel(data, 0);
1232 } else {
1233 data.writeInt(0);
1234 }
1235 data.writeString(resolvedType);
1236 data.writeStrongBinder(resultTo);
1237 data.writeString(resultWho);
1238 data.writeInt(requestCode);
1239 data.writeInt(flagsMask);
1240 data.writeInt(flagsValues);
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001241 mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001242 reply.readException();
1243 int result = reply.readInt();
1244 reply.recycle();
1245 data.recycle();
1246 return result;
1247 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001248 public boolean startNextMatchingActivity(IBinder callingActivity,
1249 Intent intent) throws RemoteException {
1250 Parcel data = Parcel.obtain();
1251 Parcel reply = Parcel.obtain();
1252 data.writeInterfaceToken(IActivityManager.descriptor);
1253 data.writeStrongBinder(callingActivity);
1254 intent.writeToParcel(data, 0);
1255 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1256 reply.readException();
1257 int result = reply.readInt();
1258 reply.recycle();
1259 data.recycle();
1260 return result != 0;
1261 }
1262 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1263 throws RemoteException {
1264 Parcel data = Parcel.obtain();
1265 Parcel reply = Parcel.obtain();
1266 data.writeInterfaceToken(IActivityManager.descriptor);
1267 data.writeStrongBinder(token);
1268 data.writeInt(resultCode);
1269 if (resultData != null) {
1270 data.writeInt(1);
1271 resultData.writeToParcel(data, 0);
1272 } else {
1273 data.writeInt(0);
1274 }
1275 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1276 reply.readException();
1277 boolean res = reply.readInt() != 0;
1278 data.recycle();
1279 reply.recycle();
1280 return res;
1281 }
1282 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1283 {
1284 Parcel data = Parcel.obtain();
1285 Parcel reply = Parcel.obtain();
1286 data.writeInterfaceToken(IActivityManager.descriptor);
1287 data.writeStrongBinder(token);
1288 data.writeString(resultWho);
1289 data.writeInt(requestCode);
1290 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1291 reply.readException();
1292 data.recycle();
1293 reply.recycle();
1294 }
1295 public Intent registerReceiver(IApplicationThread caller,
1296 IIntentReceiver receiver,
1297 IntentFilter filter, String perm) throws RemoteException
1298 {
1299 Parcel data = Parcel.obtain();
1300 Parcel reply = Parcel.obtain();
1301 data.writeInterfaceToken(IActivityManager.descriptor);
1302 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1303 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1304 filter.writeToParcel(data, 0);
1305 data.writeString(perm);
1306 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1307 reply.readException();
1308 Intent intent = null;
1309 int haveIntent = reply.readInt();
1310 if (haveIntent != 0) {
1311 intent = Intent.CREATOR.createFromParcel(reply);
1312 }
1313 reply.recycle();
1314 data.recycle();
1315 return intent;
1316 }
1317 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1318 {
1319 Parcel data = Parcel.obtain();
1320 Parcel reply = Parcel.obtain();
1321 data.writeInterfaceToken(IActivityManager.descriptor);
1322 data.writeStrongBinder(receiver.asBinder());
1323 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1324 reply.readException();
1325 data.recycle();
1326 reply.recycle();
1327 }
1328 public int broadcastIntent(IApplicationThread caller,
1329 Intent intent, String resolvedType, IIntentReceiver resultTo,
1330 int resultCode, String resultData, Bundle map,
1331 String requiredPermission, boolean serialized,
1332 boolean sticky) throws RemoteException
1333 {
1334 Parcel data = Parcel.obtain();
1335 Parcel reply = Parcel.obtain();
1336 data.writeInterfaceToken(IActivityManager.descriptor);
1337 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1338 intent.writeToParcel(data, 0);
1339 data.writeString(resolvedType);
1340 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1341 data.writeInt(resultCode);
1342 data.writeString(resultData);
1343 data.writeBundle(map);
1344 data.writeString(requiredPermission);
1345 data.writeInt(serialized ? 1 : 0);
1346 data.writeInt(sticky ? 1 : 0);
1347 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1348 reply.readException();
1349 int res = reply.readInt();
1350 reply.recycle();
1351 data.recycle();
1352 return res;
1353 }
1354 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1355 {
1356 Parcel data = Parcel.obtain();
1357 Parcel reply = Parcel.obtain();
1358 data.writeInterfaceToken(IActivityManager.descriptor);
1359 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1360 intent.writeToParcel(data, 0);
1361 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1362 reply.readException();
1363 data.recycle();
1364 reply.recycle();
1365 }
1366 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1367 {
1368 Parcel data = Parcel.obtain();
1369 Parcel reply = Parcel.obtain();
1370 data.writeInterfaceToken(IActivityManager.descriptor);
1371 data.writeStrongBinder(who);
1372 data.writeInt(resultCode);
1373 data.writeString(resultData);
1374 data.writeBundle(map);
1375 data.writeInt(abortBroadcast ? 1 : 0);
1376 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1377 reply.readException();
1378 data.recycle();
1379 reply.recycle();
1380 }
1381 public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
1382 {
1383 Parcel data = Parcel.obtain();
1384 Parcel reply = Parcel.obtain();
1385 data.writeInterfaceToken(IActivityManager.descriptor);
1386 data.writeStrongBinder(token);
1387 data.writeInt(isPersistent ? 1 : 0);
1388 mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
1389 reply.readException();
1390 data.recycle();
1391 reply.recycle();
1392 }
1393 public void attachApplication(IApplicationThread app) throws RemoteException
1394 {
1395 Parcel data = Parcel.obtain();
1396 Parcel reply = Parcel.obtain();
1397 data.writeInterfaceToken(IActivityManager.descriptor);
1398 data.writeStrongBinder(app.asBinder());
1399 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1400 reply.readException();
1401 data.recycle();
1402 reply.recycle();
1403 }
Dianne Hackborne88846e2009-09-30 21:34:25 -07001404 public void activityIdle(IBinder token, Configuration config) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001405 {
1406 Parcel data = Parcel.obtain();
1407 Parcel reply = Parcel.obtain();
1408 data.writeInterfaceToken(IActivityManager.descriptor);
1409 data.writeStrongBinder(token);
Dianne Hackborne88846e2009-09-30 21:34:25 -07001410 if (config != null) {
1411 data.writeInt(1);
1412 config.writeToParcel(data, 0);
1413 } else {
1414 data.writeInt(0);
1415 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001416 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1417 reply.readException();
1418 data.recycle();
1419 reply.recycle();
1420 }
1421 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1422 {
1423 Parcel data = Parcel.obtain();
1424 Parcel reply = Parcel.obtain();
1425 data.writeInterfaceToken(IActivityManager.descriptor);
1426 data.writeStrongBinder(token);
1427 data.writeBundle(state);
1428 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1429 reply.readException();
1430 data.recycle();
1431 reply.recycle();
1432 }
1433 public void activityStopped(IBinder token,
1434 Bitmap thumbnail, CharSequence description) throws RemoteException
1435 {
1436 Parcel data = Parcel.obtain();
1437 Parcel reply = Parcel.obtain();
1438 data.writeInterfaceToken(IActivityManager.descriptor);
1439 data.writeStrongBinder(token);
1440 if (thumbnail != null) {
1441 data.writeInt(1);
1442 thumbnail.writeToParcel(data, 0);
1443 } else {
1444 data.writeInt(0);
1445 }
1446 TextUtils.writeToParcel(description, data, 0);
1447 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1448 reply.readException();
1449 data.recycle();
1450 reply.recycle();
1451 }
1452 public void activityDestroyed(IBinder token) throws RemoteException
1453 {
1454 Parcel data = Parcel.obtain();
1455 Parcel reply = Parcel.obtain();
1456 data.writeInterfaceToken(IActivityManager.descriptor);
1457 data.writeStrongBinder(token);
1458 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1459 reply.readException();
1460 data.recycle();
1461 reply.recycle();
1462 }
1463 public String getCallingPackage(IBinder token) throws RemoteException
1464 {
1465 Parcel data = Parcel.obtain();
1466 Parcel reply = Parcel.obtain();
1467 data.writeInterfaceToken(IActivityManager.descriptor);
1468 data.writeStrongBinder(token);
1469 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1470 reply.readException();
1471 String res = reply.readString();
1472 data.recycle();
1473 reply.recycle();
1474 return res;
1475 }
1476 public ComponentName getCallingActivity(IBinder token)
1477 throws RemoteException {
1478 Parcel data = Parcel.obtain();
1479 Parcel reply = Parcel.obtain();
1480 data.writeInterfaceToken(IActivityManager.descriptor);
1481 data.writeStrongBinder(token);
1482 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1483 reply.readException();
1484 ComponentName res = ComponentName.readFromParcel(reply);
1485 data.recycle();
1486 reply.recycle();
1487 return res;
1488 }
1489 public List getTasks(int maxNum, int flags,
1490 IThumbnailReceiver receiver) throws RemoteException {
1491 Parcel data = Parcel.obtain();
1492 Parcel reply = Parcel.obtain();
1493 data.writeInterfaceToken(IActivityManager.descriptor);
1494 data.writeInt(maxNum);
1495 data.writeInt(flags);
1496 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1497 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1498 reply.readException();
1499 ArrayList list = null;
1500 int N = reply.readInt();
1501 if (N >= 0) {
1502 list = new ArrayList();
1503 while (N > 0) {
1504 ActivityManager.RunningTaskInfo info =
1505 ActivityManager.RunningTaskInfo.CREATOR
1506 .createFromParcel(reply);
1507 list.add(info);
1508 N--;
1509 }
1510 }
1511 data.recycle();
1512 reply.recycle();
1513 return list;
1514 }
1515 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1516 int flags) throws RemoteException {
1517 Parcel data = Parcel.obtain();
1518 Parcel reply = Parcel.obtain();
1519 data.writeInterfaceToken(IActivityManager.descriptor);
1520 data.writeInt(maxNum);
1521 data.writeInt(flags);
1522 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1523 reply.readException();
1524 ArrayList<ActivityManager.RecentTaskInfo> list
1525 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1526 data.recycle();
1527 reply.recycle();
1528 return list;
1529 }
1530 public List getServices(int maxNum, int flags) throws RemoteException {
1531 Parcel data = Parcel.obtain();
1532 Parcel reply = Parcel.obtain();
1533 data.writeInterfaceToken(IActivityManager.descriptor);
1534 data.writeInt(maxNum);
1535 data.writeInt(flags);
1536 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1537 reply.readException();
1538 ArrayList list = null;
1539 int N = reply.readInt();
1540 if (N >= 0) {
1541 list = new ArrayList();
1542 while (N > 0) {
1543 ActivityManager.RunningServiceInfo info =
1544 ActivityManager.RunningServiceInfo.CREATOR
1545 .createFromParcel(reply);
1546 list.add(info);
1547 N--;
1548 }
1549 }
1550 data.recycle();
1551 reply.recycle();
1552 return list;
1553 }
1554 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1555 throws RemoteException {
1556 Parcel data = Parcel.obtain();
1557 Parcel reply = Parcel.obtain();
1558 data.writeInterfaceToken(IActivityManager.descriptor);
1559 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1560 reply.readException();
1561 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1562 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1563 data.recycle();
1564 reply.recycle();
1565 return list;
1566 }
1567 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1568 throws RemoteException {
1569 Parcel data = Parcel.obtain();
1570 Parcel reply = Parcel.obtain();
1571 data.writeInterfaceToken(IActivityManager.descriptor);
1572 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1573 reply.readException();
1574 ArrayList<ActivityManager.RunningAppProcessInfo> list
1575 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1576 data.recycle();
1577 reply.recycle();
1578 return list;
1579 }
1580 public void moveTaskToFront(int task) throws RemoteException
1581 {
1582 Parcel data = Parcel.obtain();
1583 Parcel reply = Parcel.obtain();
1584 data.writeInterfaceToken(IActivityManager.descriptor);
1585 data.writeInt(task);
1586 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1587 reply.readException();
1588 data.recycle();
1589 reply.recycle();
1590 }
1591 public void moveTaskToBack(int task) throws RemoteException
1592 {
1593 Parcel data = Parcel.obtain();
1594 Parcel reply = Parcel.obtain();
1595 data.writeInterfaceToken(IActivityManager.descriptor);
1596 data.writeInt(task);
1597 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1598 reply.readException();
1599 data.recycle();
1600 reply.recycle();
1601 }
1602 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1603 throws RemoteException {
1604 Parcel data = Parcel.obtain();
1605 Parcel reply = Parcel.obtain();
1606 data.writeInterfaceToken(IActivityManager.descriptor);
1607 data.writeStrongBinder(token);
1608 data.writeInt(nonRoot ? 1 : 0);
1609 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1610 reply.readException();
1611 boolean res = reply.readInt() != 0;
1612 data.recycle();
1613 reply.recycle();
1614 return res;
1615 }
1616 public void moveTaskBackwards(int task) throws RemoteException
1617 {
1618 Parcel data = Parcel.obtain();
1619 Parcel reply = Parcel.obtain();
1620 data.writeInterfaceToken(IActivityManager.descriptor);
1621 data.writeInt(task);
1622 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1623 reply.readException();
1624 data.recycle();
1625 reply.recycle();
1626 }
1627 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1628 {
1629 Parcel data = Parcel.obtain();
1630 Parcel reply = Parcel.obtain();
1631 data.writeInterfaceToken(IActivityManager.descriptor);
1632 data.writeStrongBinder(token);
1633 data.writeInt(onlyRoot ? 1 : 0);
1634 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1635 reply.readException();
1636 int res = reply.readInt();
1637 data.recycle();
1638 reply.recycle();
1639 return res;
1640 }
1641 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1642 {
1643 Parcel data = Parcel.obtain();
1644 Parcel reply = Parcel.obtain();
1645 data.writeInterfaceToken(IActivityManager.descriptor);
1646 data.writeStrongBinder(token);
1647 ComponentName.writeToParcel(className, data);
1648 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1649 reply.readException();
1650 data.recycle();
1651 reply.recycle();
1652 }
1653 public void reportThumbnail(IBinder token,
1654 Bitmap thumbnail, CharSequence description) throws RemoteException
1655 {
1656 Parcel data = Parcel.obtain();
1657 Parcel reply = Parcel.obtain();
1658 data.writeInterfaceToken(IActivityManager.descriptor);
1659 data.writeStrongBinder(token);
1660 if (thumbnail != null) {
1661 data.writeInt(1);
1662 thumbnail.writeToParcel(data, 0);
1663 } else {
1664 data.writeInt(0);
1665 }
1666 TextUtils.writeToParcel(description, data, 0);
1667 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1668 reply.readException();
1669 data.recycle();
1670 reply.recycle();
1671 }
1672 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1673 String name) throws RemoteException
1674 {
1675 Parcel data = Parcel.obtain();
1676 Parcel reply = Parcel.obtain();
1677 data.writeInterfaceToken(IActivityManager.descriptor);
1678 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1679 data.writeString(name);
1680 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1681 reply.readException();
1682 int res = reply.readInt();
1683 ContentProviderHolder cph = null;
1684 if (res != 0) {
1685 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1686 }
1687 data.recycle();
1688 reply.recycle();
1689 return cph;
1690 }
1691 public void publishContentProviders(IApplicationThread caller,
1692 List<ContentProviderHolder> providers) throws RemoteException
1693 {
1694 Parcel data = Parcel.obtain();
1695 Parcel reply = Parcel.obtain();
1696 data.writeInterfaceToken(IActivityManager.descriptor);
1697 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1698 data.writeTypedList(providers);
1699 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1700 reply.readException();
1701 data.recycle();
1702 reply.recycle();
1703 }
1704
1705 public void removeContentProvider(IApplicationThread caller,
1706 String name) throws RemoteException {
1707 Parcel data = Parcel.obtain();
1708 Parcel reply = Parcel.obtain();
1709 data.writeInterfaceToken(IActivityManager.descriptor);
1710 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1711 data.writeString(name);
1712 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1713 reply.readException();
1714 data.recycle();
1715 reply.recycle();
1716 }
1717
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07001718 public PendingIntent getRunningServiceControlPanel(ComponentName service)
1719 throws RemoteException
1720 {
1721 Parcel data = Parcel.obtain();
1722 Parcel reply = Parcel.obtain();
1723 data.writeInterfaceToken(IActivityManager.descriptor);
1724 service.writeToParcel(data, 0);
1725 mRemote.transact(GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION, data, reply, 0);
1726 reply.readException();
1727 PendingIntent res = PendingIntent.readPendingIntentOrNullFromParcel(reply);
1728 data.recycle();
1729 reply.recycle();
1730 return res;
1731 }
1732
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001733 public ComponentName startService(IApplicationThread caller, Intent service,
1734 String resolvedType) throws RemoteException
1735 {
1736 Parcel data = Parcel.obtain();
1737 Parcel reply = Parcel.obtain();
1738 data.writeInterfaceToken(IActivityManager.descriptor);
1739 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1740 service.writeToParcel(data, 0);
1741 data.writeString(resolvedType);
1742 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
1743 reply.readException();
1744 ComponentName res = ComponentName.readFromParcel(reply);
1745 data.recycle();
1746 reply.recycle();
1747 return res;
1748 }
1749 public int stopService(IApplicationThread caller, Intent service,
1750 String resolvedType) throws RemoteException
1751 {
1752 Parcel data = Parcel.obtain();
1753 Parcel reply = Parcel.obtain();
1754 data.writeInterfaceToken(IActivityManager.descriptor);
1755 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1756 service.writeToParcel(data, 0);
1757 data.writeString(resolvedType);
1758 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
1759 reply.readException();
1760 int res = reply.readInt();
1761 reply.recycle();
1762 data.recycle();
1763 return res;
1764 }
1765 public boolean stopServiceToken(ComponentName className, IBinder token,
1766 int startId) throws RemoteException {
1767 Parcel data = Parcel.obtain();
1768 Parcel reply = Parcel.obtain();
1769 data.writeInterfaceToken(IActivityManager.descriptor);
1770 ComponentName.writeToParcel(className, data);
1771 data.writeStrongBinder(token);
1772 data.writeInt(startId);
1773 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
1774 reply.readException();
1775 boolean res = reply.readInt() != 0;
1776 data.recycle();
1777 reply.recycle();
1778 return res;
1779 }
1780 public void setServiceForeground(ComponentName className, IBinder token,
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07001781 int id, Notification notification, boolean removeNotification) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001782 Parcel data = Parcel.obtain();
1783 Parcel reply = Parcel.obtain();
1784 data.writeInterfaceToken(IActivityManager.descriptor);
1785 ComponentName.writeToParcel(className, data);
1786 data.writeStrongBinder(token);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07001787 data.writeInt(id);
1788 if (notification != null) {
1789 data.writeInt(1);
1790 notification.writeToParcel(data, 0);
1791 } else {
1792 data.writeInt(0);
1793 }
1794 data.writeInt(removeNotification ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001795 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
1796 reply.readException();
1797 data.recycle();
1798 reply.recycle();
1799 }
1800 public int bindService(IApplicationThread caller, IBinder token,
1801 Intent service, String resolvedType, IServiceConnection connection,
1802 int flags) throws RemoteException {
1803 Parcel data = Parcel.obtain();
1804 Parcel reply = Parcel.obtain();
1805 data.writeInterfaceToken(IActivityManager.descriptor);
1806 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1807 data.writeStrongBinder(token);
1808 service.writeToParcel(data, 0);
1809 data.writeString(resolvedType);
1810 data.writeStrongBinder(connection.asBinder());
1811 data.writeInt(flags);
1812 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
1813 reply.readException();
1814 int res = reply.readInt();
1815 data.recycle();
1816 reply.recycle();
1817 return res;
1818 }
1819 public boolean unbindService(IServiceConnection connection) throws RemoteException
1820 {
1821 Parcel data = Parcel.obtain();
1822 Parcel reply = Parcel.obtain();
1823 data.writeInterfaceToken(IActivityManager.descriptor);
1824 data.writeStrongBinder(connection.asBinder());
1825 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
1826 reply.readException();
1827 boolean res = reply.readInt() != 0;
1828 data.recycle();
1829 reply.recycle();
1830 return res;
1831 }
1832
1833 public void publishService(IBinder token,
1834 Intent intent, IBinder service) throws RemoteException {
1835 Parcel data = Parcel.obtain();
1836 Parcel reply = Parcel.obtain();
1837 data.writeInterfaceToken(IActivityManager.descriptor);
1838 data.writeStrongBinder(token);
1839 intent.writeToParcel(data, 0);
1840 data.writeStrongBinder(service);
1841 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
1842 reply.readException();
1843 data.recycle();
1844 reply.recycle();
1845 }
1846
1847 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
1848 throws RemoteException {
1849 Parcel data = Parcel.obtain();
1850 Parcel reply = Parcel.obtain();
1851 data.writeInterfaceToken(IActivityManager.descriptor);
1852 data.writeStrongBinder(token);
1853 intent.writeToParcel(data, 0);
1854 data.writeInt(doRebind ? 1 : 0);
1855 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
1856 reply.readException();
1857 data.recycle();
1858 reply.recycle();
1859 }
1860
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07001861 public void serviceDoneExecuting(IBinder token, int type, int startId,
1862 int res) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001863 Parcel data = Parcel.obtain();
1864 Parcel reply = Parcel.obtain();
1865 data.writeInterfaceToken(IActivityManager.descriptor);
1866 data.writeStrongBinder(token);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07001867 data.writeInt(type);
1868 data.writeInt(startId);
1869 data.writeInt(res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001870 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1871 reply.readException();
1872 data.recycle();
1873 reply.recycle();
1874 }
1875
1876 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
1877 Parcel data = Parcel.obtain();
1878 Parcel reply = Parcel.obtain();
1879 data.writeInterfaceToken(IActivityManager.descriptor);
1880 service.writeToParcel(data, 0);
1881 data.writeString(resolvedType);
1882 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
1883 reply.readException();
1884 IBinder binder = reply.readStrongBinder();
1885 reply.recycle();
1886 data.recycle();
1887 return binder;
1888 }
1889
Christopher Tate181fafa2009-05-14 11:12:14 -07001890 public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
1891 throws RemoteException {
1892 Parcel data = Parcel.obtain();
1893 Parcel reply = Parcel.obtain();
1894 data.writeInterfaceToken(IActivityManager.descriptor);
1895 app.writeToParcel(data, 0);
1896 data.writeInt(backupRestoreMode);
1897 mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
1898 reply.readException();
1899 boolean success = reply.readInt() != 0;
1900 reply.recycle();
1901 data.recycle();
1902 return success;
1903 }
1904
1905 public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException {
1906 Parcel data = Parcel.obtain();
1907 Parcel reply = Parcel.obtain();
1908 data.writeInterfaceToken(IActivityManager.descriptor);
1909 data.writeString(packageName);
1910 data.writeStrongBinder(agent);
1911 mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0);
1912 reply.recycle();
1913 data.recycle();
1914 }
1915
1916 public void unbindBackupAgent(ApplicationInfo app) throws RemoteException {
1917 Parcel data = Parcel.obtain();
1918 Parcel reply = Parcel.obtain();
1919 data.writeInterfaceToken(IActivityManager.descriptor);
1920 app.writeToParcel(data, 0);
1921 mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0);
1922 reply.readException();
1923 reply.recycle();
1924 data.recycle();
1925 }
1926
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001927 public boolean startInstrumentation(ComponentName className, String profileFile,
1928 int flags, Bundle arguments, IInstrumentationWatcher watcher)
1929 throws RemoteException {
1930 Parcel data = Parcel.obtain();
1931 Parcel reply = Parcel.obtain();
1932 data.writeInterfaceToken(IActivityManager.descriptor);
1933 ComponentName.writeToParcel(className, data);
1934 data.writeString(profileFile);
1935 data.writeInt(flags);
1936 data.writeBundle(arguments);
1937 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
1938 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
1939 reply.readException();
1940 boolean res = reply.readInt() != 0;
1941 reply.recycle();
1942 data.recycle();
1943 return res;
1944 }
1945
1946 public void finishInstrumentation(IApplicationThread target,
1947 int resultCode, Bundle results) throws RemoteException {
1948 Parcel data = Parcel.obtain();
1949 Parcel reply = Parcel.obtain();
1950 data.writeInterfaceToken(IActivityManager.descriptor);
1951 data.writeStrongBinder(target != null ? target.asBinder() : null);
1952 data.writeInt(resultCode);
1953 data.writeBundle(results);
1954 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
1955 reply.readException();
1956 data.recycle();
1957 reply.recycle();
1958 }
1959 public Configuration getConfiguration() throws RemoteException
1960 {
1961 Parcel data = Parcel.obtain();
1962 Parcel reply = Parcel.obtain();
1963 data.writeInterfaceToken(IActivityManager.descriptor);
1964 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
1965 reply.readException();
1966 Configuration res = Configuration.CREATOR.createFromParcel(reply);
1967 reply.recycle();
1968 data.recycle();
1969 return res;
1970 }
1971 public void updateConfiguration(Configuration values) throws RemoteException
1972 {
1973 Parcel data = Parcel.obtain();
1974 Parcel reply = Parcel.obtain();
1975 data.writeInterfaceToken(IActivityManager.descriptor);
1976 values.writeToParcel(data, 0);
1977 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
1978 reply.readException();
1979 data.recycle();
1980 reply.recycle();
1981 }
1982 public void setRequestedOrientation(IBinder token, int requestedOrientation)
1983 throws RemoteException {
1984 Parcel data = Parcel.obtain();
1985 Parcel reply = Parcel.obtain();
1986 data.writeInterfaceToken(IActivityManager.descriptor);
1987 data.writeStrongBinder(token);
1988 data.writeInt(requestedOrientation);
1989 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
1990 reply.readException();
1991 data.recycle();
1992 reply.recycle();
1993 }
1994 public int getRequestedOrientation(IBinder token) throws RemoteException {
1995 Parcel data = Parcel.obtain();
1996 Parcel reply = Parcel.obtain();
1997 data.writeInterfaceToken(IActivityManager.descriptor);
1998 data.writeStrongBinder(token);
1999 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2000 reply.readException();
2001 int res = reply.readInt();
2002 data.recycle();
2003 reply.recycle();
2004 return res;
2005 }
2006 public ComponentName getActivityClassForToken(IBinder token)
2007 throws RemoteException {
2008 Parcel data = Parcel.obtain();
2009 Parcel reply = Parcel.obtain();
2010 data.writeInterfaceToken(IActivityManager.descriptor);
2011 data.writeStrongBinder(token);
2012 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
2013 reply.readException();
2014 ComponentName res = ComponentName.readFromParcel(reply);
2015 data.recycle();
2016 reply.recycle();
2017 return res;
2018 }
2019 public String getPackageForToken(IBinder token) throws RemoteException
2020 {
2021 Parcel data = Parcel.obtain();
2022 Parcel reply = Parcel.obtain();
2023 data.writeInterfaceToken(IActivityManager.descriptor);
2024 data.writeStrongBinder(token);
2025 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
2026 reply.readException();
2027 String res = reply.readString();
2028 data.recycle();
2029 reply.recycle();
2030 return res;
2031 }
2032 public IIntentSender getIntentSender(int type,
2033 String packageName, IBinder token, String resultWho,
2034 int requestCode, Intent intent, String resolvedType, int flags)
2035 throws RemoteException {
2036 Parcel data = Parcel.obtain();
2037 Parcel reply = Parcel.obtain();
2038 data.writeInterfaceToken(IActivityManager.descriptor);
2039 data.writeInt(type);
2040 data.writeString(packageName);
2041 data.writeStrongBinder(token);
2042 data.writeString(resultWho);
2043 data.writeInt(requestCode);
2044 if (intent != null) {
2045 data.writeInt(1);
2046 intent.writeToParcel(data, 0);
2047 } else {
2048 data.writeInt(0);
2049 }
2050 data.writeString(resolvedType);
2051 data.writeInt(flags);
2052 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
2053 reply.readException();
2054 IIntentSender res = IIntentSender.Stub.asInterface(
2055 reply.readStrongBinder());
2056 data.recycle();
2057 reply.recycle();
2058 return res;
2059 }
2060 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
2061 Parcel data = Parcel.obtain();
2062 Parcel reply = Parcel.obtain();
2063 data.writeInterfaceToken(IActivityManager.descriptor);
2064 data.writeStrongBinder(sender.asBinder());
2065 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
2066 reply.readException();
2067 data.recycle();
2068 reply.recycle();
2069 }
2070 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
2071 Parcel data = Parcel.obtain();
2072 Parcel reply = Parcel.obtain();
2073 data.writeInterfaceToken(IActivityManager.descriptor);
2074 data.writeStrongBinder(sender.asBinder());
2075 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
2076 reply.readException();
2077 String res = reply.readString();
2078 data.recycle();
2079 reply.recycle();
2080 return res;
2081 }
2082 public void setProcessLimit(int max) throws RemoteException
2083 {
2084 Parcel data = Parcel.obtain();
2085 Parcel reply = Parcel.obtain();
2086 data.writeInterfaceToken(IActivityManager.descriptor);
2087 data.writeInt(max);
2088 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2089 reply.readException();
2090 data.recycle();
2091 reply.recycle();
2092 }
2093 public int getProcessLimit() throws RemoteException
2094 {
2095 Parcel data = Parcel.obtain();
2096 Parcel reply = Parcel.obtain();
2097 data.writeInterfaceToken(IActivityManager.descriptor);
2098 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2099 reply.readException();
2100 int res = reply.readInt();
2101 data.recycle();
2102 reply.recycle();
2103 return res;
2104 }
2105 public void setProcessForeground(IBinder token, int pid,
2106 boolean isForeground) throws RemoteException {
2107 Parcel data = Parcel.obtain();
2108 Parcel reply = Parcel.obtain();
2109 data.writeInterfaceToken(IActivityManager.descriptor);
2110 data.writeStrongBinder(token);
2111 data.writeInt(pid);
2112 data.writeInt(isForeground ? 1 : 0);
2113 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
2114 reply.readException();
2115 data.recycle();
2116 reply.recycle();
2117 }
2118 public int checkPermission(String permission, int pid, int uid)
2119 throws RemoteException {
2120 Parcel data = Parcel.obtain();
2121 Parcel reply = Parcel.obtain();
2122 data.writeInterfaceToken(IActivityManager.descriptor);
2123 data.writeString(permission);
2124 data.writeInt(pid);
2125 data.writeInt(uid);
2126 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
2127 reply.readException();
2128 int res = reply.readInt();
2129 data.recycle();
2130 reply.recycle();
2131 return res;
2132 }
2133 public boolean clearApplicationUserData(final String packageName,
2134 final IPackageDataObserver observer) throws RemoteException {
2135 Parcel data = Parcel.obtain();
2136 Parcel reply = Parcel.obtain();
2137 data.writeInterfaceToken(IActivityManager.descriptor);
2138 data.writeString(packageName);
2139 data.writeStrongBinder(observer.asBinder());
2140 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
2141 reply.readException();
2142 boolean res = reply.readInt() != 0;
2143 data.recycle();
2144 reply.recycle();
2145 return res;
2146 }
2147 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
2148 throws RemoteException {
2149 Parcel data = Parcel.obtain();
2150 Parcel reply = Parcel.obtain();
2151 data.writeInterfaceToken(IActivityManager.descriptor);
2152 uri.writeToParcel(data, 0);
2153 data.writeInt(pid);
2154 data.writeInt(uid);
2155 data.writeInt(mode);
2156 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
2157 reply.readException();
2158 int res = reply.readInt();
2159 data.recycle();
2160 reply.recycle();
2161 return res;
2162 }
2163 public void grantUriPermission(IApplicationThread caller, String targetPkg,
2164 Uri uri, int mode) throws RemoteException {
2165 Parcel data = Parcel.obtain();
2166 Parcel reply = Parcel.obtain();
2167 data.writeInterfaceToken(IActivityManager.descriptor);
2168 data.writeStrongBinder(caller.asBinder());
2169 data.writeString(targetPkg);
2170 uri.writeToParcel(data, 0);
2171 data.writeInt(mode);
2172 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2173 reply.readException();
2174 data.recycle();
2175 reply.recycle();
2176 }
2177 public void revokeUriPermission(IApplicationThread caller, Uri uri,
2178 int mode) throws RemoteException {
2179 Parcel data = Parcel.obtain();
2180 Parcel reply = Parcel.obtain();
2181 data.writeInterfaceToken(IActivityManager.descriptor);
2182 data.writeStrongBinder(caller.asBinder());
2183 uri.writeToParcel(data, 0);
2184 data.writeInt(mode);
2185 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2186 reply.readException();
2187 data.recycle();
2188 reply.recycle();
2189 }
2190 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
2191 throws RemoteException {
2192 Parcel data = Parcel.obtain();
2193 Parcel reply = Parcel.obtain();
2194 data.writeInterfaceToken(IActivityManager.descriptor);
2195 data.writeStrongBinder(who.asBinder());
2196 data.writeInt(waiting ? 1 : 0);
2197 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
2198 reply.readException();
2199 data.recycle();
2200 reply.recycle();
2201 }
2202 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
2203 Parcel data = Parcel.obtain();
2204 Parcel reply = Parcel.obtain();
2205 data.writeInterfaceToken(IActivityManager.descriptor);
2206 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
2207 reply.readException();
2208 outInfo.readFromParcel(reply);
2209 data.recycle();
2210 reply.recycle();
2211 }
2212 public void unhandledBack() throws RemoteException
2213 {
2214 Parcel data = Parcel.obtain();
2215 Parcel reply = Parcel.obtain();
2216 data.writeInterfaceToken(IActivityManager.descriptor);
2217 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
2218 reply.readException();
2219 data.recycle();
2220 reply.recycle();
2221 }
2222 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
2223 {
2224 Parcel data = Parcel.obtain();
2225 Parcel reply = Parcel.obtain();
2226 data.writeInterfaceToken(IActivityManager.descriptor);
2227 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
2228 reply.readException();
2229 ParcelFileDescriptor pfd = null;
2230 if (reply.readInt() != 0) {
2231 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
2232 }
2233 data.recycle();
2234 reply.recycle();
2235 return pfd;
2236 }
2237 public void goingToSleep() throws RemoteException
2238 {
2239 Parcel data = Parcel.obtain();
2240 Parcel reply = Parcel.obtain();
2241 data.writeInterfaceToken(IActivityManager.descriptor);
2242 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
2243 reply.readException();
2244 data.recycle();
2245 reply.recycle();
2246 }
2247 public void wakingUp() throws RemoteException
2248 {
2249 Parcel data = Parcel.obtain();
2250 Parcel reply = Parcel.obtain();
2251 data.writeInterfaceToken(IActivityManager.descriptor);
2252 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
2253 reply.readException();
2254 data.recycle();
2255 reply.recycle();
2256 }
2257 public void setDebugApp(
2258 String packageName, boolean waitForDebugger, boolean persistent)
2259 throws RemoteException
2260 {
2261 Parcel data = Parcel.obtain();
2262 Parcel reply = Parcel.obtain();
2263 data.writeInterfaceToken(IActivityManager.descriptor);
2264 data.writeString(packageName);
2265 data.writeInt(waitForDebugger ? 1 : 0);
2266 data.writeInt(persistent ? 1 : 0);
2267 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2268 reply.readException();
2269 data.recycle();
2270 reply.recycle();
2271 }
2272 public void setAlwaysFinish(boolean enabled) throws RemoteException
2273 {
2274 Parcel data = Parcel.obtain();
2275 Parcel reply = Parcel.obtain();
2276 data.writeInterfaceToken(IActivityManager.descriptor);
2277 data.writeInt(enabled ? 1 : 0);
2278 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2279 reply.readException();
2280 data.recycle();
2281 reply.recycle();
2282 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002283 public void setActivityController(IActivityController watcher) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002284 {
2285 Parcel data = Parcel.obtain();
2286 Parcel reply = Parcel.obtain();
2287 data.writeInterfaceToken(IActivityManager.descriptor);
2288 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002289 mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002290 reply.readException();
2291 data.recycle();
2292 reply.recycle();
2293 }
2294 public void enterSafeMode() throws RemoteException {
2295 Parcel data = Parcel.obtain();
2296 data.writeInterfaceToken(IActivityManager.descriptor);
2297 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2298 data.recycle();
2299 }
2300 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2301 Parcel data = Parcel.obtain();
2302 data.writeStrongBinder(sender.asBinder());
2303 data.writeInterfaceToken(IActivityManager.descriptor);
2304 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2305 data.recycle();
2306 }
2307 public boolean killPidsForMemory(int[] pids) throws RemoteException {
2308 Parcel data = Parcel.obtain();
2309 Parcel reply = Parcel.obtain();
2310 data.writeInterfaceToken(IActivityManager.descriptor);
2311 data.writeIntArray(pids);
2312 mRemote.transact(KILL_PIDS_FOR_MEMORY_TRANSACTION, data, reply, 0);
2313 boolean res = reply.readInt() != 0;
2314 data.recycle();
2315 reply.recycle();
2316 return res;
2317 }
2318 public void reportPss(IApplicationThread caller, int pss) throws RemoteException {
2319 Parcel data = Parcel.obtain();
2320 data.writeInterfaceToken(IActivityManager.descriptor);
2321 data.writeStrongBinder(caller.asBinder());
2322 data.writeInt(pss);
2323 mRemote.transact(REPORT_PSS_TRANSACTION, data, null, 0);
2324 data.recycle();
2325 }
2326 public void startRunning(String pkg, String cls, String action,
2327 String indata) throws RemoteException {
2328 Parcel data = Parcel.obtain();
2329 Parcel reply = Parcel.obtain();
2330 data.writeInterfaceToken(IActivityManager.descriptor);
2331 data.writeString(pkg);
2332 data.writeString(cls);
2333 data.writeString(action);
2334 data.writeString(indata);
2335 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2336 reply.readException();
2337 data.recycle();
2338 reply.recycle();
2339 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002340 public boolean testIsSystemReady()
2341 {
2342 /* this base class version is never called */
2343 return true;
2344 }
2345 public int handleApplicationError(IBinder app, int flags,
2346 String tag, String shortMsg, String longMsg,
2347 byte[] crashData) throws RemoteException
2348 {
2349 Parcel data = Parcel.obtain();
2350 Parcel reply = Parcel.obtain();
2351 data.writeInterfaceToken(IActivityManager.descriptor);
2352 data.writeStrongBinder(app);
2353 data.writeInt(flags);
2354 data.writeString(tag);
2355 data.writeString(shortMsg);
2356 data.writeString(longMsg);
2357 data.writeByteArray(crashData);
2358 mRemote.transact(HANDLE_APPLICATION_ERROR_TRANSACTION, data, reply, 0);
2359 reply.readException();
2360 int res = reply.readInt();
2361 reply.recycle();
2362 data.recycle();
2363 return res;
2364 }
2365
2366 public void signalPersistentProcesses(int sig) throws RemoteException {
2367 Parcel data = Parcel.obtain();
2368 Parcel reply = Parcel.obtain();
2369 data.writeInterfaceToken(IActivityManager.descriptor);
2370 data.writeInt(sig);
2371 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2372 reply.readException();
2373 data.recycle();
2374 reply.recycle();
2375 }
2376
2377 public void restartPackage(String packageName) throws RemoteException {
2378 Parcel data = Parcel.obtain();
2379 Parcel reply = Parcel.obtain();
2380 data.writeInterfaceToken(IActivityManager.descriptor);
2381 data.writeString(packageName);
2382 mRemote.transact(RESTART_PACKAGE_TRANSACTION, data, reply, 0);
2383 reply.readException();
2384 data.recycle();
2385 reply.recycle();
2386 }
2387
2388 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2389 {
2390 Parcel data = Parcel.obtain();
2391 Parcel reply = Parcel.obtain();
2392 data.writeInterfaceToken(IActivityManager.descriptor);
2393 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2394 reply.readException();
2395 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2396 reply.recycle();
2397 data.recycle();
2398 return res;
2399 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002400
2401 public boolean profileControl(String process, boolean start,
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002402 String path, ParcelFileDescriptor fd) throws RemoteException
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002403 {
2404 Parcel data = Parcel.obtain();
2405 Parcel reply = Parcel.obtain();
2406 data.writeInterfaceToken(IActivityManager.descriptor);
2407 data.writeString(process);
2408 data.writeInt(start ? 1 : 0);
2409 data.writeString(path);
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002410 if (fd != null) {
2411 data.writeInt(1);
2412 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
2413 } else {
2414 data.writeInt(0);
2415 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002416 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2417 reply.readException();
2418 boolean res = reply.readInt() != 0;
2419 reply.recycle();
2420 data.recycle();
2421 return res;
2422 }
2423
Dianne Hackborn55280a92009-05-07 15:53:46 -07002424 public boolean shutdown(int timeout) throws RemoteException
2425 {
2426 Parcel data = Parcel.obtain();
2427 Parcel reply = Parcel.obtain();
2428 data.writeInterfaceToken(IActivityManager.descriptor);
2429 data.writeInt(timeout);
2430 mRemote.transact(SHUTDOWN_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 Hackborn95fc68f2009-05-19 18:37:45 -07002438 public void stopAppSwitches() throws RemoteException {
2439 Parcel data = Parcel.obtain();
2440 Parcel reply = Parcel.obtain();
2441 data.writeInterfaceToken(IActivityManager.descriptor);
2442 mRemote.transact(STOP_APP_SWITCHES_TRANSACTION, data, reply, 0);
2443 reply.readException();
2444 reply.recycle();
2445 data.recycle();
2446 }
2447
2448 public void resumeAppSwitches() throws RemoteException {
2449 Parcel data = Parcel.obtain();
2450 Parcel reply = Parcel.obtain();
2451 data.writeInterfaceToken(IActivityManager.descriptor);
2452 mRemote.transact(RESUME_APP_SWITCHES_TRANSACTION, data, reply, 0);
2453 reply.readException();
2454 reply.recycle();
2455 data.recycle();
2456 }
2457
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002458 public void registerActivityWatcher(IActivityWatcher watcher)
2459 throws RemoteException {
2460 Parcel data = Parcel.obtain();
2461 Parcel reply = Parcel.obtain();
2462 data.writeInterfaceToken(IActivityManager.descriptor);
2463 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2464 mRemote.transact(REGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2465 reply.readException();
2466 data.recycle();
2467 reply.recycle();
2468 }
2469
2470 public void unregisterActivityWatcher(IActivityWatcher watcher)
2471 throws RemoteException {
2472 Parcel data = Parcel.obtain();
2473 Parcel reply = Parcel.obtain();
2474 data.writeInterfaceToken(IActivityManager.descriptor);
2475 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2476 mRemote.transact(UNREGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2477 reply.readException();
2478 data.recycle();
2479 reply.recycle();
2480 }
2481
Dianne Hackborn2d91af02009-07-16 13:34:33 -07002482 public int startActivityInPackage(int uid,
2483 Intent intent, String resolvedType, IBinder resultTo,
2484 String resultWho, int requestCode, boolean onlyIfNeeded)
2485 throws RemoteException {
2486 Parcel data = Parcel.obtain();
2487 Parcel reply = Parcel.obtain();
2488 data.writeInterfaceToken(IActivityManager.descriptor);
2489 data.writeInt(uid);
2490 intent.writeToParcel(data, 0);
2491 data.writeString(resolvedType);
2492 data.writeStrongBinder(resultTo);
2493 data.writeString(resultWho);
2494 data.writeInt(requestCode);
2495 data.writeInt(onlyIfNeeded ? 1 : 0);
2496 mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
2497 reply.readException();
2498 int result = reply.readInt();
2499 reply.recycle();
2500 data.recycle();
2501 return result;
2502 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002503
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07002504 public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
2505 Parcel data = Parcel.obtain();
2506 Parcel reply = Parcel.obtain();
2507 data.writeInterfaceToken(IActivityManager.descriptor);
2508 data.writeString(pkg);
2509 data.writeInt(uid);
2510 mRemote.transact(KILL_APPLICATION_WITH_UID_TRANSACTION, data, reply, 0);
2511 reply.readException();
2512 data.recycle();
2513 reply.recycle();
2514 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002515
2516 public void closeSystemDialogs(String reason) throws RemoteException {
2517 Parcel data = Parcel.obtain();
2518 Parcel reply = Parcel.obtain();
2519 data.writeInterfaceToken(IActivityManager.descriptor);
2520 data.writeString(reason);
2521 mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
2522 reply.readException();
2523 data.recycle();
2524 reply.recycle();
2525 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002526
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002527 public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002528 throws RemoteException {
2529 Parcel data = Parcel.obtain();
2530 Parcel reply = Parcel.obtain();
2531 data.writeInterfaceToken(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002532 data.writeIntArray(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002533 mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
2534 reply.readException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002535 Debug.MemoryInfo[] res = reply.createTypedArray(Debug.MemoryInfo.CREATOR);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002536 data.recycle();
2537 reply.recycle();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002538 return res;
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002539 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07002540
2541 public void killApplicationProcess(String processName, int uid) throws RemoteException {
2542 Parcel data = Parcel.obtain();
2543 Parcel reply = Parcel.obtain();
2544 data.writeInterfaceToken(IActivityManager.descriptor);
2545 data.writeString(processName);
2546 data.writeInt(uid);
2547 mRemote.transact(KILL_APPLICATION_PROCESS_TRANSACTION, data, reply, 0);
2548 reply.readException();
2549 data.recycle();
2550 reply.recycle();
2551 }
2552
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07002553 public void overridePendingTransition(IBinder token, String packageName,
2554 int enterAnim, int exitAnim) throws RemoteException {
2555 Parcel data = Parcel.obtain();
2556 Parcel reply = Parcel.obtain();
2557 data.writeInterfaceToken(IActivityManager.descriptor);
2558 data.writeStrongBinder(token);
2559 data.writeString(packageName);
2560 data.writeInt(enterAnim);
2561 data.writeInt(exitAnim);
2562 mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
2563 reply.readException();
2564 data.recycle();
2565 reply.recycle();
2566 }
2567
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002568 private IBinder mRemote;
2569}