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