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