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