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