blob: 6d5686a40c3362ab1fd8a2aba7b3edcf7c352220 [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 Hackborn8f7f35e2010-02-25 18:48:12 -0800149 case START_ACTIVITY_AND_WAIT_TRANSACTION:
150 {
151 data.enforceInterface(IActivityManager.descriptor);
152 IBinder b = data.readStrongBinder();
153 IApplicationThread app = ApplicationThreadNative.asInterface(b);
154 Intent intent = Intent.CREATOR.createFromParcel(data);
155 String resolvedType = data.readString();
156 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
157 int grantedMode = data.readInt();
158 IBinder resultTo = data.readStrongBinder();
159 String resultWho = data.readString();
160 int requestCode = data.readInt();
161 boolean onlyIfNeeded = data.readInt() != 0;
162 boolean debug = data.readInt() != 0;
163 WaitResult result = startActivityAndWait(app, intent, resolvedType,
164 grantedUriPermissions, grantedMode, resultTo, resultWho,
165 requestCode, onlyIfNeeded, debug);
166 reply.writeNoException();
167 result.writeToParcel(reply, 0);
168 return true;
169 }
170
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700171 case START_ACTIVITY_INTENT_SENDER_TRANSACTION:
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700172 {
173 data.enforceInterface(IActivityManager.descriptor);
174 IBinder b = data.readStrongBinder();
175 IApplicationThread app = ApplicationThreadNative.asInterface(b);
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700176 IntentSender intent = IntentSender.CREATOR.createFromParcel(data);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700177 Intent fillInIntent = null;
178 if (data.readInt() != 0) {
179 fillInIntent = Intent.CREATOR.createFromParcel(data);
180 }
181 String resolvedType = data.readString();
182 IBinder resultTo = data.readStrongBinder();
183 String resultWho = data.readString();
184 int requestCode = data.readInt();
185 int flagsMask = data.readInt();
186 int flagsValues = data.readInt();
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700187 int result = startActivityIntentSender(app, intent,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700188 fillInIntent, resolvedType, resultTo, resultWho,
189 requestCode, flagsMask, flagsValues);
190 reply.writeNoException();
191 reply.writeInt(result);
192 return true;
193 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194
195 case START_NEXT_MATCHING_ACTIVITY_TRANSACTION:
196 {
197 data.enforceInterface(IActivityManager.descriptor);
198 IBinder callingActivity = data.readStrongBinder();
199 Intent intent = Intent.CREATOR.createFromParcel(data);
200 boolean result = startNextMatchingActivity(callingActivity, intent);
201 reply.writeNoException();
202 reply.writeInt(result ? 1 : 0);
203 return true;
204 }
205
206 case FINISH_ACTIVITY_TRANSACTION: {
207 data.enforceInterface(IActivityManager.descriptor);
208 IBinder token = data.readStrongBinder();
209 Intent resultData = null;
210 int resultCode = data.readInt();
211 if (data.readInt() != 0) {
212 resultData = Intent.CREATOR.createFromParcel(data);
213 }
214 boolean res = finishActivity(token, resultCode, resultData);
215 reply.writeNoException();
216 reply.writeInt(res ? 1 : 0);
217 return true;
218 }
219
220 case FINISH_SUB_ACTIVITY_TRANSACTION: {
221 data.enforceInterface(IActivityManager.descriptor);
222 IBinder token = data.readStrongBinder();
223 String resultWho = data.readString();
224 int requestCode = data.readInt();
225 finishSubActivity(token, resultWho, requestCode);
226 reply.writeNoException();
227 return true;
228 }
229
Dianne Hackborn061d58a2010-03-12 15:07:06 -0800230 case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: {
231 data.enforceInterface(IActivityManager.descriptor);
232 IBinder token = data.readStrongBinder();
233 boolean res = willActivityBeVisible(token);
234 reply.writeNoException();
235 reply.writeInt(res ? 1 : 0);
236 return true;
237 }
238
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800239 case REGISTER_RECEIVER_TRANSACTION:
240 {
241 data.enforceInterface(IActivityManager.descriptor);
242 IBinder b = data.readStrongBinder();
243 IApplicationThread app =
244 b != null ? ApplicationThreadNative.asInterface(b) : null;
245 b = data.readStrongBinder();
246 IIntentReceiver rec
247 = b != null ? IIntentReceiver.Stub.asInterface(b) : null;
248 IntentFilter filter = IntentFilter.CREATOR.createFromParcel(data);
249 String perm = data.readString();
250 Intent intent = registerReceiver(app, rec, filter, perm);
251 reply.writeNoException();
252 if (intent != null) {
253 reply.writeInt(1);
254 intent.writeToParcel(reply, 0);
255 } else {
256 reply.writeInt(0);
257 }
258 return true;
259 }
260
261 case UNREGISTER_RECEIVER_TRANSACTION:
262 {
263 data.enforceInterface(IActivityManager.descriptor);
264 IBinder b = data.readStrongBinder();
265 if (b == null) {
266 return true;
267 }
268 IIntentReceiver rec = IIntentReceiver.Stub.asInterface(b);
269 unregisterReceiver(rec);
270 reply.writeNoException();
271 return true;
272 }
273
274 case BROADCAST_INTENT_TRANSACTION:
275 {
276 data.enforceInterface(IActivityManager.descriptor);
277 IBinder b = data.readStrongBinder();
278 IApplicationThread app =
279 b != null ? ApplicationThreadNative.asInterface(b) : null;
280 Intent intent = Intent.CREATOR.createFromParcel(data);
281 String resolvedType = data.readString();
282 b = data.readStrongBinder();
283 IIntentReceiver resultTo =
284 b != null ? IIntentReceiver.Stub.asInterface(b) : null;
285 int resultCode = data.readInt();
286 String resultData = data.readString();
287 Bundle resultExtras = data.readBundle();
288 String perm = data.readString();
289 boolean serialized = data.readInt() != 0;
290 boolean sticky = data.readInt() != 0;
291 int res = broadcastIntent(app, intent, resolvedType, resultTo,
292 resultCode, resultData, resultExtras, perm,
293 serialized, sticky);
294 reply.writeNoException();
295 reply.writeInt(res);
296 return true;
297 }
298
299 case UNBROADCAST_INTENT_TRANSACTION:
300 {
301 data.enforceInterface(IActivityManager.descriptor);
302 IBinder b = data.readStrongBinder();
303 IApplicationThread app = b != null ? ApplicationThreadNative.asInterface(b) : null;
304 Intent intent = Intent.CREATOR.createFromParcel(data);
305 unbroadcastIntent(app, intent);
306 reply.writeNoException();
307 return true;
308 }
309
310 case FINISH_RECEIVER_TRANSACTION: {
311 data.enforceInterface(IActivityManager.descriptor);
312 IBinder who = data.readStrongBinder();
313 int resultCode = data.readInt();
314 String resultData = data.readString();
315 Bundle resultExtras = data.readBundle();
316 boolean resultAbort = data.readInt() != 0;
317 if (who != null) {
318 finishReceiver(who, resultCode, resultData, resultExtras, resultAbort);
319 }
320 reply.writeNoException();
321 return true;
322 }
323
324 case SET_PERSISTENT_TRANSACTION: {
325 data.enforceInterface(IActivityManager.descriptor);
326 IBinder token = data.readStrongBinder();
327 boolean isPersistent = data.readInt() != 0;
328 if (token != null) {
329 setPersistent(token, isPersistent);
330 }
331 reply.writeNoException();
332 return true;
333 }
334
335 case ATTACH_APPLICATION_TRANSACTION: {
336 data.enforceInterface(IActivityManager.descriptor);
337 IApplicationThread app = ApplicationThreadNative.asInterface(
338 data.readStrongBinder());
339 if (app != null) {
340 attachApplication(app);
341 }
342 reply.writeNoException();
343 return true;
344 }
345
346 case ACTIVITY_IDLE_TRANSACTION: {
347 data.enforceInterface(IActivityManager.descriptor);
348 IBinder token = data.readStrongBinder();
Dianne Hackborne88846e2009-09-30 21:34:25 -0700349 Configuration config = null;
350 if (data.readInt() != 0) {
351 config = Configuration.CREATOR.createFromParcel(data);
352 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800353 if (token != null) {
Dianne Hackborne88846e2009-09-30 21:34:25 -0700354 activityIdle(token, config);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355 }
356 reply.writeNoException();
357 return true;
358 }
359
360 case ACTIVITY_PAUSED_TRANSACTION: {
361 data.enforceInterface(IActivityManager.descriptor);
362 IBinder token = data.readStrongBinder();
363 Bundle map = data.readBundle();
364 activityPaused(token, map);
365 reply.writeNoException();
366 return true;
367 }
368
369 case ACTIVITY_STOPPED_TRANSACTION: {
370 data.enforceInterface(IActivityManager.descriptor);
371 IBinder token = data.readStrongBinder();
372 Bitmap thumbnail = data.readInt() != 0
373 ? Bitmap.CREATOR.createFromParcel(data) : null;
374 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
375 activityStopped(token, thumbnail, description);
376 reply.writeNoException();
377 return true;
378 }
379
380 case ACTIVITY_DESTROYED_TRANSACTION: {
381 data.enforceInterface(IActivityManager.descriptor);
382 IBinder token = data.readStrongBinder();
383 activityDestroyed(token);
384 reply.writeNoException();
385 return true;
386 }
387
388 case GET_CALLING_PACKAGE_TRANSACTION: {
389 data.enforceInterface(IActivityManager.descriptor);
390 IBinder token = data.readStrongBinder();
391 String res = token != null ? getCallingPackage(token) : null;
392 reply.writeNoException();
393 reply.writeString(res);
394 return true;
395 }
396
397 case GET_CALLING_ACTIVITY_TRANSACTION: {
398 data.enforceInterface(IActivityManager.descriptor);
399 IBinder token = data.readStrongBinder();
400 ComponentName cn = getCallingActivity(token);
401 reply.writeNoException();
402 ComponentName.writeToParcel(cn, reply);
403 return true;
404 }
405
406 case GET_TASKS_TRANSACTION: {
407 data.enforceInterface(IActivityManager.descriptor);
408 int maxNum = data.readInt();
409 int fl = data.readInt();
410 IBinder receiverBinder = data.readStrongBinder();
411 IThumbnailReceiver receiver = receiverBinder != null
412 ? IThumbnailReceiver.Stub.asInterface(receiverBinder)
413 : null;
414 List list = getTasks(maxNum, fl, receiver);
415 reply.writeNoException();
416 int N = list != null ? list.size() : -1;
417 reply.writeInt(N);
418 int i;
419 for (i=0; i<N; i++) {
420 ActivityManager.RunningTaskInfo info =
421 (ActivityManager.RunningTaskInfo)list.get(i);
422 info.writeToParcel(reply, 0);
423 }
424 return true;
425 }
426
427 case GET_RECENT_TASKS_TRANSACTION: {
428 data.enforceInterface(IActivityManager.descriptor);
429 int maxNum = data.readInt();
430 int fl = data.readInt();
431 List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
432 fl);
433 reply.writeNoException();
434 reply.writeTypedList(list);
435 return true;
436 }
437
438 case GET_SERVICES_TRANSACTION: {
439 data.enforceInterface(IActivityManager.descriptor);
440 int maxNum = data.readInt();
441 int fl = data.readInt();
442 List list = getServices(maxNum, fl);
443 reply.writeNoException();
444 int N = list != null ? list.size() : -1;
445 reply.writeInt(N);
446 int i;
447 for (i=0; i<N; i++) {
448 ActivityManager.RunningServiceInfo info =
449 (ActivityManager.RunningServiceInfo)list.get(i);
450 info.writeToParcel(reply, 0);
451 }
452 return true;
453 }
454
455 case GET_PROCESSES_IN_ERROR_STATE_TRANSACTION: {
456 data.enforceInterface(IActivityManager.descriptor);
457 List<ActivityManager.ProcessErrorStateInfo> list = getProcessesInErrorState();
458 reply.writeNoException();
459 reply.writeTypedList(list);
460 return true;
461 }
462
463 case GET_RUNNING_APP_PROCESSES_TRANSACTION: {
464 data.enforceInterface(IActivityManager.descriptor);
465 List<ActivityManager.RunningAppProcessInfo> list = getRunningAppProcesses();
466 reply.writeNoException();
467 reply.writeTypedList(list);
468 return true;
469 }
470
471 case MOVE_TASK_TO_FRONT_TRANSACTION: {
472 data.enforceInterface(IActivityManager.descriptor);
473 int task = data.readInt();
474 moveTaskToFront(task);
475 reply.writeNoException();
476 return true;
477 }
478
479 case MOVE_TASK_TO_BACK_TRANSACTION: {
480 data.enforceInterface(IActivityManager.descriptor);
481 int task = data.readInt();
482 moveTaskToBack(task);
483 reply.writeNoException();
484 return true;
485 }
486
487 case MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION: {
488 data.enforceInterface(IActivityManager.descriptor);
489 IBinder token = data.readStrongBinder();
490 boolean nonRoot = data.readInt() != 0;
491 boolean res = moveActivityTaskToBack(token, nonRoot);
492 reply.writeNoException();
493 reply.writeInt(res ? 1 : 0);
494 return true;
495 }
496
497 case MOVE_TASK_BACKWARDS_TRANSACTION: {
498 data.enforceInterface(IActivityManager.descriptor);
499 int task = data.readInt();
500 moveTaskBackwards(task);
501 reply.writeNoException();
502 return true;
503 }
504
505 case GET_TASK_FOR_ACTIVITY_TRANSACTION: {
506 data.enforceInterface(IActivityManager.descriptor);
507 IBinder token = data.readStrongBinder();
508 boolean onlyRoot = data.readInt() != 0;
509 int res = token != null
510 ? getTaskForActivity(token, onlyRoot) : -1;
511 reply.writeNoException();
512 reply.writeInt(res);
513 return true;
514 }
515
516 case FINISH_OTHER_INSTANCES_TRANSACTION: {
517 data.enforceInterface(IActivityManager.descriptor);
518 IBinder token = data.readStrongBinder();
519 ComponentName className = ComponentName.readFromParcel(data);
520 finishOtherInstances(token, className);
521 reply.writeNoException();
522 return true;
523 }
524
525 case REPORT_THUMBNAIL_TRANSACTION: {
526 data.enforceInterface(IActivityManager.descriptor);
527 IBinder token = data.readStrongBinder();
528 Bitmap thumbnail = data.readInt() != 0
529 ? Bitmap.CREATOR.createFromParcel(data) : null;
530 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
531 reportThumbnail(token, thumbnail, description);
532 reply.writeNoException();
533 return true;
534 }
535
536 case GET_CONTENT_PROVIDER_TRANSACTION: {
537 data.enforceInterface(IActivityManager.descriptor);
538 IBinder b = data.readStrongBinder();
539 IApplicationThread app = ApplicationThreadNative.asInterface(b);
540 String name = data.readString();
541 ContentProviderHolder cph = getContentProvider(app, name);
542 reply.writeNoException();
543 if (cph != null) {
544 reply.writeInt(1);
545 cph.writeToParcel(reply, 0);
546 } else {
547 reply.writeInt(0);
548 }
549 return true;
550 }
551
552 case PUBLISH_CONTENT_PROVIDERS_TRANSACTION: {
553 data.enforceInterface(IActivityManager.descriptor);
554 IBinder b = data.readStrongBinder();
555 IApplicationThread app = ApplicationThreadNative.asInterface(b);
556 ArrayList<ContentProviderHolder> providers =
557 data.createTypedArrayList(ContentProviderHolder.CREATOR);
558 publishContentProviders(app, providers);
559 reply.writeNoException();
560 return true;
561 }
562
563 case REMOVE_CONTENT_PROVIDER_TRANSACTION: {
564 data.enforceInterface(IActivityManager.descriptor);
565 IBinder b = data.readStrongBinder();
566 IApplicationThread app = ApplicationThreadNative.asInterface(b);
567 String name = data.readString();
568 removeContentProvider(app, name);
569 reply.writeNoException();
570 return true;
571 }
572
Dianne Hackborndd9b82c2009-09-03 00:18:47 -0700573 case GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION: {
574 data.enforceInterface(IActivityManager.descriptor);
575 ComponentName comp = ComponentName.CREATOR.createFromParcel(data);
576 PendingIntent pi = getRunningServiceControlPanel(comp);
577 reply.writeNoException();
578 PendingIntent.writePendingIntentOrNullToParcel(pi, reply);
579 return true;
580 }
581
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800582 case START_SERVICE_TRANSACTION: {
583 data.enforceInterface(IActivityManager.descriptor);
584 IBinder b = data.readStrongBinder();
585 IApplicationThread app = ApplicationThreadNative.asInterface(b);
586 Intent service = Intent.CREATOR.createFromParcel(data);
587 String resolvedType = data.readString();
588 ComponentName cn = startService(app, service, resolvedType);
589 reply.writeNoException();
590 ComponentName.writeToParcel(cn, reply);
591 return true;
592 }
593
594 case STOP_SERVICE_TRANSACTION: {
595 data.enforceInterface(IActivityManager.descriptor);
596 IBinder b = data.readStrongBinder();
597 IApplicationThread app = ApplicationThreadNative.asInterface(b);
598 Intent service = Intent.CREATOR.createFromParcel(data);
599 String resolvedType = data.readString();
600 int res = stopService(app, service, resolvedType);
601 reply.writeNoException();
602 reply.writeInt(res);
603 return true;
604 }
605
606 case STOP_SERVICE_TOKEN_TRANSACTION: {
607 data.enforceInterface(IActivityManager.descriptor);
608 ComponentName className = ComponentName.readFromParcel(data);
609 IBinder token = data.readStrongBinder();
610 int startId = data.readInt();
611 boolean res = stopServiceToken(className, token, startId);
612 reply.writeNoException();
613 reply.writeInt(res ? 1 : 0);
614 return true;
615 }
616
617 case SET_SERVICE_FOREGROUND_TRANSACTION: {
618 data.enforceInterface(IActivityManager.descriptor);
619 ComponentName className = ComponentName.readFromParcel(data);
620 IBinder token = data.readStrongBinder();
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700621 int id = data.readInt();
622 Notification notification = null;
623 if (data.readInt() != 0) {
624 notification = Notification.CREATOR.createFromParcel(data);
625 }
626 boolean removeNotification = data.readInt() != 0;
627 setServiceForeground(className, token, id, notification, removeNotification);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800628 reply.writeNoException();
629 return true;
630 }
631
632 case BIND_SERVICE_TRANSACTION: {
633 data.enforceInterface(IActivityManager.descriptor);
634 IBinder b = data.readStrongBinder();
635 IApplicationThread app = ApplicationThreadNative.asInterface(b);
636 IBinder token = data.readStrongBinder();
637 Intent service = Intent.CREATOR.createFromParcel(data);
638 String resolvedType = data.readString();
639 b = data.readStrongBinder();
640 int fl = data.readInt();
641 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
642 int res = bindService(app, token, service, resolvedType, conn, fl);
643 reply.writeNoException();
644 reply.writeInt(res);
645 return true;
646 }
647
648 case UNBIND_SERVICE_TRANSACTION: {
649 data.enforceInterface(IActivityManager.descriptor);
650 IBinder b = data.readStrongBinder();
651 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
652 boolean res = unbindService(conn);
653 reply.writeNoException();
654 reply.writeInt(res ? 1 : 0);
655 return true;
656 }
657
658 case PUBLISH_SERVICE_TRANSACTION: {
659 data.enforceInterface(IActivityManager.descriptor);
660 IBinder token = data.readStrongBinder();
661 Intent intent = Intent.CREATOR.createFromParcel(data);
662 IBinder service = data.readStrongBinder();
663 publishService(token, intent, service);
664 reply.writeNoException();
665 return true;
666 }
667
668 case UNBIND_FINISHED_TRANSACTION: {
669 data.enforceInterface(IActivityManager.descriptor);
670 IBinder token = data.readStrongBinder();
671 Intent intent = Intent.CREATOR.createFromParcel(data);
672 boolean doRebind = data.readInt() != 0;
673 unbindFinished(token, intent, doRebind);
674 reply.writeNoException();
675 return true;
676 }
677
678 case SERVICE_DONE_EXECUTING_TRANSACTION: {
679 data.enforceInterface(IActivityManager.descriptor);
680 IBinder token = data.readStrongBinder();
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700681 int type = data.readInt();
682 int startId = data.readInt();
683 int res = data.readInt();
684 serviceDoneExecuting(token, type, startId, res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800685 reply.writeNoException();
686 return true;
687 }
688
689 case START_INSTRUMENTATION_TRANSACTION: {
690 data.enforceInterface(IActivityManager.descriptor);
691 ComponentName className = ComponentName.readFromParcel(data);
692 String profileFile = data.readString();
693 int fl = data.readInt();
694 Bundle arguments = data.readBundle();
695 IBinder b = data.readStrongBinder();
696 IInstrumentationWatcher w = IInstrumentationWatcher.Stub.asInterface(b);
697 boolean res = startInstrumentation(className, profileFile, fl, arguments, w);
698 reply.writeNoException();
699 reply.writeInt(res ? 1 : 0);
700 return true;
701 }
702
703
704 case FINISH_INSTRUMENTATION_TRANSACTION: {
705 data.enforceInterface(IActivityManager.descriptor);
706 IBinder b = data.readStrongBinder();
707 IApplicationThread app = ApplicationThreadNative.asInterface(b);
708 int resultCode = data.readInt();
709 Bundle results = data.readBundle();
710 finishInstrumentation(app, resultCode, results);
711 reply.writeNoException();
712 return true;
713 }
714
715 case GET_CONFIGURATION_TRANSACTION: {
716 data.enforceInterface(IActivityManager.descriptor);
717 Configuration config = getConfiguration();
718 reply.writeNoException();
719 config.writeToParcel(reply, 0);
720 return true;
721 }
722
723 case UPDATE_CONFIGURATION_TRANSACTION: {
724 data.enforceInterface(IActivityManager.descriptor);
725 Configuration config = Configuration.CREATOR.createFromParcel(data);
726 updateConfiguration(config);
727 reply.writeNoException();
728 return true;
729 }
730
731 case SET_REQUESTED_ORIENTATION_TRANSACTION: {
732 data.enforceInterface(IActivityManager.descriptor);
733 IBinder token = data.readStrongBinder();
734 int requestedOrientation = data.readInt();
735 setRequestedOrientation(token, requestedOrientation);
736 reply.writeNoException();
737 return true;
738 }
739
740 case GET_REQUESTED_ORIENTATION_TRANSACTION: {
741 data.enforceInterface(IActivityManager.descriptor);
742 IBinder token = data.readStrongBinder();
743 int req = getRequestedOrientation(token);
744 reply.writeNoException();
745 reply.writeInt(req);
746 return true;
747 }
748
749 case GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION: {
750 data.enforceInterface(IActivityManager.descriptor);
751 IBinder token = data.readStrongBinder();
752 ComponentName cn = getActivityClassForToken(token);
753 reply.writeNoException();
754 ComponentName.writeToParcel(cn, reply);
755 return true;
756 }
757
758 case GET_PACKAGE_FOR_TOKEN_TRANSACTION: {
759 data.enforceInterface(IActivityManager.descriptor);
760 IBinder token = data.readStrongBinder();
761 reply.writeNoException();
762 reply.writeString(getPackageForToken(token));
763 return true;
764 }
765
766 case GET_INTENT_SENDER_TRANSACTION: {
767 data.enforceInterface(IActivityManager.descriptor);
768 int type = data.readInt();
769 String packageName = data.readString();
770 IBinder token = data.readStrongBinder();
771 String resultWho = data.readString();
772 int requestCode = data.readInt();
773 Intent requestIntent = data.readInt() != 0
774 ? Intent.CREATOR.createFromParcel(data) : null;
775 String requestResolvedType = data.readString();
776 int fl = data.readInt();
777 IIntentSender res = getIntentSender(type, packageName, token,
778 resultWho, requestCode, requestIntent,
779 requestResolvedType, fl);
780 reply.writeNoException();
781 reply.writeStrongBinder(res != null ? res.asBinder() : null);
782 return true;
783 }
784
785 case CANCEL_INTENT_SENDER_TRANSACTION: {
786 data.enforceInterface(IActivityManager.descriptor);
787 IIntentSender r = IIntentSender.Stub.asInterface(
788 data.readStrongBinder());
789 cancelIntentSender(r);
790 reply.writeNoException();
791 return true;
792 }
793
794 case GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION: {
795 data.enforceInterface(IActivityManager.descriptor);
796 IIntentSender r = IIntentSender.Stub.asInterface(
797 data.readStrongBinder());
798 String res = getPackageForIntentSender(r);
799 reply.writeNoException();
800 reply.writeString(res);
801 return true;
802 }
803
804 case SET_PROCESS_LIMIT_TRANSACTION: {
805 data.enforceInterface(IActivityManager.descriptor);
806 int max = data.readInt();
807 setProcessLimit(max);
808 reply.writeNoException();
809 return true;
810 }
811
812 case GET_PROCESS_LIMIT_TRANSACTION: {
813 data.enforceInterface(IActivityManager.descriptor);
814 int limit = getProcessLimit();
815 reply.writeNoException();
816 reply.writeInt(limit);
817 return true;
818 }
819
820 case SET_PROCESS_FOREGROUND_TRANSACTION: {
821 data.enforceInterface(IActivityManager.descriptor);
822 IBinder token = data.readStrongBinder();
823 int pid = data.readInt();
824 boolean isForeground = data.readInt() != 0;
825 setProcessForeground(token, pid, isForeground);
826 reply.writeNoException();
827 return true;
828 }
829
830 case CHECK_PERMISSION_TRANSACTION: {
831 data.enforceInterface(IActivityManager.descriptor);
832 String perm = data.readString();
833 int pid = data.readInt();
834 int uid = data.readInt();
835 int res = checkPermission(perm, pid, uid);
836 reply.writeNoException();
837 reply.writeInt(res);
838 return true;
839 }
840
841 case CHECK_URI_PERMISSION_TRANSACTION: {
842 data.enforceInterface(IActivityManager.descriptor);
843 Uri uri = Uri.CREATOR.createFromParcel(data);
844 int pid = data.readInt();
845 int uid = data.readInt();
846 int mode = data.readInt();
847 int res = checkUriPermission(uri, pid, uid, mode);
848 reply.writeNoException();
849 reply.writeInt(res);
850 return true;
851 }
852
853 case CLEAR_APP_DATA_TRANSACTION: {
854 data.enforceInterface(IActivityManager.descriptor);
855 String packageName = data.readString();
856 IPackageDataObserver observer = IPackageDataObserver.Stub.asInterface(
857 data.readStrongBinder());
858 boolean res = clearApplicationUserData(packageName, observer);
859 reply.writeNoException();
860 reply.writeInt(res ? 1 : 0);
861 return true;
862 }
863
864 case GRANT_URI_PERMISSION_TRANSACTION: {
865 data.enforceInterface(IActivityManager.descriptor);
866 IBinder b = data.readStrongBinder();
867 IApplicationThread app = ApplicationThreadNative.asInterface(b);
868 String targetPkg = data.readString();
869 Uri uri = Uri.CREATOR.createFromParcel(data);
870 int mode = data.readInt();
871 grantUriPermission(app, targetPkg, uri, mode);
872 reply.writeNoException();
873 return true;
874 }
875
876 case REVOKE_URI_PERMISSION_TRANSACTION: {
877 data.enforceInterface(IActivityManager.descriptor);
878 IBinder b = data.readStrongBinder();
879 IApplicationThread app = ApplicationThreadNative.asInterface(b);
880 Uri uri = Uri.CREATOR.createFromParcel(data);
881 int mode = data.readInt();
882 revokeUriPermission(app, uri, mode);
883 reply.writeNoException();
884 return true;
885 }
886
887 case SHOW_WAITING_FOR_DEBUGGER_TRANSACTION: {
888 data.enforceInterface(IActivityManager.descriptor);
889 IBinder b = data.readStrongBinder();
890 IApplicationThread app = ApplicationThreadNative.asInterface(b);
891 boolean waiting = data.readInt() != 0;
892 showWaitingForDebugger(app, waiting);
893 reply.writeNoException();
894 return true;
895 }
896
897 case GET_MEMORY_INFO_TRANSACTION: {
898 data.enforceInterface(IActivityManager.descriptor);
899 ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
900 getMemoryInfo(mi);
901 reply.writeNoException();
902 mi.writeToParcel(reply, 0);
903 return true;
904 }
905
906 case UNHANDLED_BACK_TRANSACTION: {
907 data.enforceInterface(IActivityManager.descriptor);
908 unhandledBack();
909 reply.writeNoException();
910 return true;
911 }
912
913 case OPEN_CONTENT_URI_TRANSACTION: {
914 data.enforceInterface(IActivityManager.descriptor);
915 Uri uri = Uri.parse(data.readString());
916 ParcelFileDescriptor pfd = openContentUri(uri);
917 reply.writeNoException();
918 if (pfd != null) {
919 reply.writeInt(1);
920 pfd.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
921 } else {
922 reply.writeInt(0);
923 }
924 return true;
925 }
926
927 case GOING_TO_SLEEP_TRANSACTION: {
928 data.enforceInterface(IActivityManager.descriptor);
929 goingToSleep();
930 reply.writeNoException();
931 return true;
932 }
933
934 case WAKING_UP_TRANSACTION: {
935 data.enforceInterface(IActivityManager.descriptor);
936 wakingUp();
937 reply.writeNoException();
938 return true;
939 }
940
941 case SET_DEBUG_APP_TRANSACTION: {
942 data.enforceInterface(IActivityManager.descriptor);
943 String pn = data.readString();
944 boolean wfd = data.readInt() != 0;
945 boolean per = data.readInt() != 0;
946 setDebugApp(pn, wfd, per);
947 reply.writeNoException();
948 return true;
949 }
950
951 case SET_ALWAYS_FINISH_TRANSACTION: {
952 data.enforceInterface(IActivityManager.descriptor);
953 boolean enabled = data.readInt() != 0;
954 setAlwaysFinish(enabled);
955 reply.writeNoException();
956 return true;
957 }
958
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700959 case SET_ACTIVITY_CONTROLLER_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800960 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700961 IActivityController watcher = IActivityController.Stub.asInterface(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962 data.readStrongBinder());
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700963 setActivityController(watcher);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800964 return true;
965 }
966
967 case ENTER_SAFE_MODE_TRANSACTION: {
968 data.enforceInterface(IActivityManager.descriptor);
969 enterSafeMode();
970 reply.writeNoException();
971 return true;
972 }
973
974 case NOTE_WAKEUP_ALARM_TRANSACTION: {
975 data.enforceInterface(IActivityManager.descriptor);
976 IIntentSender is = IIntentSender.Stub.asInterface(
977 data.readStrongBinder());
978 noteWakeupAlarm(is);
979 reply.writeNoException();
980 return true;
981 }
982
983 case KILL_PIDS_FOR_MEMORY_TRANSACTION: {
984 data.enforceInterface(IActivityManager.descriptor);
985 int[] pids = data.createIntArray();
986 boolean res = killPidsForMemory(pids);
987 reply.writeNoException();
988 reply.writeInt(res ? 1 : 0);
989 return true;
990 }
991
992 case REPORT_PSS_TRANSACTION: {
993 data.enforceInterface(IActivityManager.descriptor);
994 IBinder b = data.readStrongBinder();
995 IApplicationThread app = ApplicationThreadNative.asInterface(b);
996 int pss = data.readInt();
997 reportPss(app, pss);
998 reply.writeNoException();
999 return true;
1000 }
1001
1002 case START_RUNNING_TRANSACTION: {
1003 data.enforceInterface(IActivityManager.descriptor);
1004 String pkg = data.readString();
1005 String cls = data.readString();
1006 String action = data.readString();
1007 String indata = data.readString();
1008 startRunning(pkg, cls, action, indata);
1009 reply.writeNoException();
1010 return true;
1011 }
1012
Dan Egnor60d87622009-12-16 16:32:58 -08001013 case HANDLE_APPLICATION_CRASH_TRANSACTION: {
1014 data.enforceInterface(IActivityManager.descriptor);
1015 IBinder app = data.readStrongBinder();
1016 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
1017 handleApplicationCrash(app, ci);
1018 reply.writeNoException();
1019 return true;
1020 }
1021
1022 case HANDLE_APPLICATION_WTF_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001023 data.enforceInterface(IActivityManager.descriptor);
1024 IBinder app = data.readStrongBinder();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001025 String tag = data.readString();
Dan Egnorb7f03672009-12-09 16:22:32 -08001026 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
Dan Egnor60d87622009-12-16 16:32:58 -08001027 boolean res = handleApplicationWtf(app, tag, ci);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001028 reply.writeNoException();
Dan Egnor60d87622009-12-16 16:32:58 -08001029 reply.writeInt(res ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001030 return true;
1031 }
Dan Egnorb7f03672009-12-09 16:22:32 -08001032
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001033 case SIGNAL_PERSISTENT_PROCESSES_TRANSACTION: {
1034 data.enforceInterface(IActivityManager.descriptor);
1035 int sig = data.readInt();
1036 signalPersistentProcesses(sig);
1037 reply.writeNoException();
1038 return true;
1039 }
1040
Dianne Hackborn03abb812010-01-04 18:43:19 -08001041 case KILL_BACKGROUND_PROCESSES_TRANSACTION: {
1042 data.enforceInterface(IActivityManager.descriptor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001043 String packageName = data.readString();
Dianne Hackborn03abb812010-01-04 18:43:19 -08001044 killBackgroundProcesses(packageName);
1045 reply.writeNoException();
1046 return true;
1047 }
1048
1049 case FORCE_STOP_PACKAGE_TRANSACTION: {
1050 data.enforceInterface(IActivityManager.descriptor);
1051 String packageName = data.readString();
1052 forceStopPackage(packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001053 reply.writeNoException();
1054 return true;
1055 }
1056
1057 case GET_DEVICE_CONFIGURATION_TRANSACTION: {
1058 data.enforceInterface(IActivityManager.descriptor);
1059 ConfigurationInfo config = getDeviceConfigurationInfo();
1060 reply.writeNoException();
1061 config.writeToParcel(reply, 0);
1062 return true;
1063 }
1064
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001065 case PROFILE_CONTROL_TRANSACTION: {
1066 data.enforceInterface(IActivityManager.descriptor);
1067 String process = data.readString();
1068 boolean start = data.readInt() != 0;
1069 String path = data.readString();
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07001070 ParcelFileDescriptor fd = data.readInt() != 0
1071 ? data.readFileDescriptor() : null;
1072 boolean res = profileControl(process, start, path, fd);
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001073 reply.writeNoException();
1074 reply.writeInt(res ? 1 : 0);
1075 return true;
1076 }
1077
Dianne Hackborn55280a92009-05-07 15:53:46 -07001078 case SHUTDOWN_TRANSACTION: {
1079 data.enforceInterface(IActivityManager.descriptor);
1080 boolean res = shutdown(data.readInt());
1081 reply.writeNoException();
1082 reply.writeInt(res ? 1 : 0);
1083 return true;
1084 }
1085
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07001086 case STOP_APP_SWITCHES_TRANSACTION: {
1087 data.enforceInterface(IActivityManager.descriptor);
1088 stopAppSwitches();
1089 reply.writeNoException();
1090 return true;
1091 }
1092
1093 case RESUME_APP_SWITCHES_TRANSACTION: {
1094 data.enforceInterface(IActivityManager.descriptor);
1095 resumeAppSwitches();
1096 reply.writeNoException();
1097 return true;
1098 }
1099
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001100 case PEEK_SERVICE_TRANSACTION: {
1101 data.enforceInterface(IActivityManager.descriptor);
1102 Intent service = Intent.CREATOR.createFromParcel(data);
1103 String resolvedType = data.readString();
1104 IBinder binder = peekService(service, resolvedType);
1105 reply.writeNoException();
1106 reply.writeStrongBinder(binder);
1107 return true;
1108 }
Christopher Tate181fafa2009-05-14 11:12:14 -07001109
1110 case START_BACKUP_AGENT_TRANSACTION: {
1111 data.enforceInterface(IActivityManager.descriptor);
1112 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1113 int backupRestoreMode = data.readInt();
1114 boolean success = bindBackupAgent(info, backupRestoreMode);
1115 reply.writeNoException();
1116 reply.writeInt(success ? 1 : 0);
1117 return true;
1118 }
1119
1120 case BACKUP_AGENT_CREATED_TRANSACTION: {
1121 data.enforceInterface(IActivityManager.descriptor);
1122 String packageName = data.readString();
1123 IBinder agent = data.readStrongBinder();
1124 backupAgentCreated(packageName, agent);
1125 reply.writeNoException();
1126 return true;
1127 }
1128
1129 case UNBIND_BACKUP_AGENT_TRANSACTION: {
1130 data.enforceInterface(IActivityManager.descriptor);
1131 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1132 unbindBackupAgent(info);
1133 reply.writeNoException();
1134 return true;
1135 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07001136
1137 case REGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1138 data.enforceInterface(IActivityManager.descriptor);
1139 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1140 data.readStrongBinder());
1141 registerActivityWatcher(watcher);
1142 return true;
1143 }
1144
1145 case UNREGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1146 data.enforceInterface(IActivityManager.descriptor);
1147 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1148 data.readStrongBinder());
1149 unregisterActivityWatcher(watcher);
1150 return true;
1151 }
Dianne Hackborn2d91af02009-07-16 13:34:33 -07001152
1153 case START_ACTIVITY_IN_PACKAGE_TRANSACTION:
1154 {
1155 data.enforceInterface(IActivityManager.descriptor);
1156 int uid = data.readInt();
1157 Intent intent = Intent.CREATOR.createFromParcel(data);
1158 String resolvedType = data.readString();
1159 IBinder resultTo = data.readStrongBinder();
1160 String resultWho = data.readString();
1161 int requestCode = data.readInt();
1162 boolean onlyIfNeeded = data.readInt() != 0;
1163 int result = startActivityInPackage(uid, intent, resolvedType,
1164 resultTo, resultWho, requestCode, onlyIfNeeded);
1165 reply.writeNoException();
1166 reply.writeInt(result);
1167 return true;
1168 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001169
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07001170 case KILL_APPLICATION_WITH_UID_TRANSACTION: {
1171 data.enforceInterface(IActivityManager.descriptor);
1172 String pkg = data.readString();
1173 int uid = data.readInt();
1174 killApplicationWithUid(pkg, uid);
1175 reply.writeNoException();
1176 return true;
1177 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001178
1179 case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
1180 data.enforceInterface(IActivityManager.descriptor);
1181 String reason = data.readString();
1182 closeSystemDialogs(reason);
1183 reply.writeNoException();
1184 return true;
1185 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001186
1187 case GET_PROCESS_MEMORY_INFO_TRANSACTION: {
1188 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001189 int[] pids = data.createIntArray();
1190 Debug.MemoryInfo[] res = getProcessMemoryInfo(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001191 reply.writeNoException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001192 reply.writeTypedArray(res, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001193 return true;
1194 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07001195
1196 case KILL_APPLICATION_PROCESS_TRANSACTION: {
1197 data.enforceInterface(IActivityManager.descriptor);
1198 String processName = data.readString();
1199 int uid = data.readInt();
1200 killApplicationProcess(processName, uid);
1201 reply.writeNoException();
1202 return true;
1203 }
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001204
1205 case OVERRIDE_PENDING_TRANSITION_TRANSACTION: {
1206 data.enforceInterface(IActivityManager.descriptor);
1207 IBinder token = data.readStrongBinder();
1208 String packageName = data.readString();
1209 int enterAnim = data.readInt();
1210 int exitAnim = data.readInt();
1211 overridePendingTransition(token, packageName, enterAnim, exitAnim);
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08001212 reply.writeNoException();
1213 return true;
1214 }
1215
1216 case IS_USER_A_MONKEY_TRANSACTION: {
1217 data.enforceInterface(IActivityManager.descriptor);
1218 reply.writeInt(isUserAMonkey() ? 1 : 0);
1219 reply.writeNoException();
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001220 return true;
1221 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001222 }
1223
1224 return super.onTransact(code, data, reply, flags);
1225 }
1226
1227 public IBinder asBinder()
1228 {
1229 return this;
1230 }
1231
1232 private static IActivityManager gDefault;
1233}
1234
1235class ActivityManagerProxy implements IActivityManager
1236{
1237 public ActivityManagerProxy(IBinder remote)
1238 {
1239 mRemote = remote;
1240 }
1241
1242 public IBinder asBinder()
1243 {
1244 return mRemote;
1245 }
1246
1247 public int startActivity(IApplicationThread caller, Intent intent,
1248 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1249 IBinder resultTo, String resultWho,
1250 int requestCode, boolean onlyIfNeeded,
1251 boolean debug) throws RemoteException {
1252 Parcel data = Parcel.obtain();
1253 Parcel reply = Parcel.obtain();
1254 data.writeInterfaceToken(IActivityManager.descriptor);
1255 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1256 intent.writeToParcel(data, 0);
1257 data.writeString(resolvedType);
1258 data.writeTypedArray(grantedUriPermissions, 0);
1259 data.writeInt(grantedMode);
1260 data.writeStrongBinder(resultTo);
1261 data.writeString(resultWho);
1262 data.writeInt(requestCode);
1263 data.writeInt(onlyIfNeeded ? 1 : 0);
1264 data.writeInt(debug ? 1 : 0);
1265 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1266 reply.readException();
1267 int result = reply.readInt();
1268 reply.recycle();
1269 data.recycle();
1270 return result;
1271 }
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -08001272 public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
1273 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1274 IBinder resultTo, String resultWho,
1275 int requestCode, boolean onlyIfNeeded,
1276 boolean debug) throws RemoteException {
1277 Parcel data = Parcel.obtain();
1278 Parcel reply = Parcel.obtain();
1279 data.writeInterfaceToken(IActivityManager.descriptor);
1280 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1281 intent.writeToParcel(data, 0);
1282 data.writeString(resolvedType);
1283 data.writeTypedArray(grantedUriPermissions, 0);
1284 data.writeInt(grantedMode);
1285 data.writeStrongBinder(resultTo);
1286 data.writeString(resultWho);
1287 data.writeInt(requestCode);
1288 data.writeInt(onlyIfNeeded ? 1 : 0);
1289 data.writeInt(debug ? 1 : 0);
1290 mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
1291 reply.readException();
1292 WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
1293 reply.recycle();
1294 data.recycle();
1295 return result;
1296 }
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001297 public int startActivityIntentSender(IApplicationThread caller,
1298 IntentSender intent, Intent fillInIntent, String resolvedType,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001299 IBinder resultTo, String resultWho, int requestCode,
1300 int flagsMask, int flagsValues) throws RemoteException {
1301 Parcel data = Parcel.obtain();
1302 Parcel reply = Parcel.obtain();
1303 data.writeInterfaceToken(IActivityManager.descriptor);
1304 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1305 intent.writeToParcel(data, 0);
1306 if (fillInIntent != null) {
1307 data.writeInt(1);
1308 fillInIntent.writeToParcel(data, 0);
1309 } else {
1310 data.writeInt(0);
1311 }
1312 data.writeString(resolvedType);
1313 data.writeStrongBinder(resultTo);
1314 data.writeString(resultWho);
1315 data.writeInt(requestCode);
1316 data.writeInt(flagsMask);
1317 data.writeInt(flagsValues);
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001318 mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001319 reply.readException();
1320 int result = reply.readInt();
1321 reply.recycle();
1322 data.recycle();
1323 return result;
1324 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001325 public boolean startNextMatchingActivity(IBinder callingActivity,
1326 Intent intent) throws RemoteException {
1327 Parcel data = Parcel.obtain();
1328 Parcel reply = Parcel.obtain();
1329 data.writeInterfaceToken(IActivityManager.descriptor);
1330 data.writeStrongBinder(callingActivity);
1331 intent.writeToParcel(data, 0);
1332 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1333 reply.readException();
1334 int result = reply.readInt();
1335 reply.recycle();
1336 data.recycle();
1337 return result != 0;
1338 }
1339 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1340 throws RemoteException {
1341 Parcel data = Parcel.obtain();
1342 Parcel reply = Parcel.obtain();
1343 data.writeInterfaceToken(IActivityManager.descriptor);
1344 data.writeStrongBinder(token);
1345 data.writeInt(resultCode);
1346 if (resultData != null) {
1347 data.writeInt(1);
1348 resultData.writeToParcel(data, 0);
1349 } else {
1350 data.writeInt(0);
1351 }
1352 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1353 reply.readException();
1354 boolean res = reply.readInt() != 0;
1355 data.recycle();
1356 reply.recycle();
1357 return res;
1358 }
1359 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1360 {
1361 Parcel data = Parcel.obtain();
1362 Parcel reply = Parcel.obtain();
1363 data.writeInterfaceToken(IActivityManager.descriptor);
1364 data.writeStrongBinder(token);
1365 data.writeString(resultWho);
1366 data.writeInt(requestCode);
1367 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1368 reply.readException();
1369 data.recycle();
1370 reply.recycle();
1371 }
Dianne Hackborn061d58a2010-03-12 15:07:06 -08001372 public boolean willActivityBeVisible(IBinder token) throws RemoteException {
1373 Parcel data = Parcel.obtain();
1374 Parcel reply = Parcel.obtain();
1375 data.writeInterfaceToken(IActivityManager.descriptor);
1376 data.writeStrongBinder(token);
1377 mRemote.transact(WILL_ACTIVITY_BE_VISIBLE_TRANSACTION, data, reply, 0);
1378 reply.readException();
1379 boolean res = reply.readInt() != 0;
1380 data.recycle();
1381 reply.recycle();
1382 return res;
1383 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001384 public Intent registerReceiver(IApplicationThread caller,
1385 IIntentReceiver receiver,
1386 IntentFilter filter, String perm) throws RemoteException
1387 {
1388 Parcel data = Parcel.obtain();
1389 Parcel reply = Parcel.obtain();
1390 data.writeInterfaceToken(IActivityManager.descriptor);
1391 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1392 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1393 filter.writeToParcel(data, 0);
1394 data.writeString(perm);
1395 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1396 reply.readException();
1397 Intent intent = null;
1398 int haveIntent = reply.readInt();
1399 if (haveIntent != 0) {
1400 intent = Intent.CREATOR.createFromParcel(reply);
1401 }
1402 reply.recycle();
1403 data.recycle();
1404 return intent;
1405 }
1406 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1407 {
1408 Parcel data = Parcel.obtain();
1409 Parcel reply = Parcel.obtain();
1410 data.writeInterfaceToken(IActivityManager.descriptor);
1411 data.writeStrongBinder(receiver.asBinder());
1412 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1413 reply.readException();
1414 data.recycle();
1415 reply.recycle();
1416 }
1417 public int broadcastIntent(IApplicationThread caller,
1418 Intent intent, String resolvedType, IIntentReceiver resultTo,
1419 int resultCode, String resultData, Bundle map,
1420 String requiredPermission, boolean serialized,
1421 boolean sticky) throws RemoteException
1422 {
1423 Parcel data = Parcel.obtain();
1424 Parcel reply = Parcel.obtain();
1425 data.writeInterfaceToken(IActivityManager.descriptor);
1426 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1427 intent.writeToParcel(data, 0);
1428 data.writeString(resolvedType);
1429 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1430 data.writeInt(resultCode);
1431 data.writeString(resultData);
1432 data.writeBundle(map);
1433 data.writeString(requiredPermission);
1434 data.writeInt(serialized ? 1 : 0);
1435 data.writeInt(sticky ? 1 : 0);
1436 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1437 reply.readException();
1438 int res = reply.readInt();
1439 reply.recycle();
1440 data.recycle();
1441 return res;
1442 }
1443 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1444 {
1445 Parcel data = Parcel.obtain();
1446 Parcel reply = Parcel.obtain();
1447 data.writeInterfaceToken(IActivityManager.descriptor);
1448 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1449 intent.writeToParcel(data, 0);
1450 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1451 reply.readException();
1452 data.recycle();
1453 reply.recycle();
1454 }
1455 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1456 {
1457 Parcel data = Parcel.obtain();
1458 Parcel reply = Parcel.obtain();
1459 data.writeInterfaceToken(IActivityManager.descriptor);
1460 data.writeStrongBinder(who);
1461 data.writeInt(resultCode);
1462 data.writeString(resultData);
1463 data.writeBundle(map);
1464 data.writeInt(abortBroadcast ? 1 : 0);
1465 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1466 reply.readException();
1467 data.recycle();
1468 reply.recycle();
1469 }
1470 public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
1471 {
1472 Parcel data = Parcel.obtain();
1473 Parcel reply = Parcel.obtain();
1474 data.writeInterfaceToken(IActivityManager.descriptor);
1475 data.writeStrongBinder(token);
1476 data.writeInt(isPersistent ? 1 : 0);
1477 mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
1478 reply.readException();
1479 data.recycle();
1480 reply.recycle();
1481 }
1482 public void attachApplication(IApplicationThread app) throws RemoteException
1483 {
1484 Parcel data = Parcel.obtain();
1485 Parcel reply = Parcel.obtain();
1486 data.writeInterfaceToken(IActivityManager.descriptor);
1487 data.writeStrongBinder(app.asBinder());
1488 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1489 reply.readException();
1490 data.recycle();
1491 reply.recycle();
1492 }
Dianne Hackborne88846e2009-09-30 21:34:25 -07001493 public void activityIdle(IBinder token, Configuration config) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001494 {
1495 Parcel data = Parcel.obtain();
1496 Parcel reply = Parcel.obtain();
1497 data.writeInterfaceToken(IActivityManager.descriptor);
1498 data.writeStrongBinder(token);
Dianne Hackborne88846e2009-09-30 21:34:25 -07001499 if (config != null) {
1500 data.writeInt(1);
1501 config.writeToParcel(data, 0);
1502 } else {
1503 data.writeInt(0);
1504 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001505 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1506 reply.readException();
1507 data.recycle();
1508 reply.recycle();
1509 }
1510 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1511 {
1512 Parcel data = Parcel.obtain();
1513 Parcel reply = Parcel.obtain();
1514 data.writeInterfaceToken(IActivityManager.descriptor);
1515 data.writeStrongBinder(token);
1516 data.writeBundle(state);
1517 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1518 reply.readException();
1519 data.recycle();
1520 reply.recycle();
1521 }
1522 public void activityStopped(IBinder token,
1523 Bitmap thumbnail, CharSequence description) throws RemoteException
1524 {
1525 Parcel data = Parcel.obtain();
1526 Parcel reply = Parcel.obtain();
1527 data.writeInterfaceToken(IActivityManager.descriptor);
1528 data.writeStrongBinder(token);
1529 if (thumbnail != null) {
1530 data.writeInt(1);
1531 thumbnail.writeToParcel(data, 0);
1532 } else {
1533 data.writeInt(0);
1534 }
1535 TextUtils.writeToParcel(description, data, 0);
1536 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1537 reply.readException();
1538 data.recycle();
1539 reply.recycle();
1540 }
1541 public void activityDestroyed(IBinder token) throws RemoteException
1542 {
1543 Parcel data = Parcel.obtain();
1544 Parcel reply = Parcel.obtain();
1545 data.writeInterfaceToken(IActivityManager.descriptor);
1546 data.writeStrongBinder(token);
1547 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1548 reply.readException();
1549 data.recycle();
1550 reply.recycle();
1551 }
1552 public String getCallingPackage(IBinder token) throws RemoteException
1553 {
1554 Parcel data = Parcel.obtain();
1555 Parcel reply = Parcel.obtain();
1556 data.writeInterfaceToken(IActivityManager.descriptor);
1557 data.writeStrongBinder(token);
1558 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1559 reply.readException();
1560 String res = reply.readString();
1561 data.recycle();
1562 reply.recycle();
1563 return res;
1564 }
1565 public ComponentName getCallingActivity(IBinder token)
1566 throws RemoteException {
1567 Parcel data = Parcel.obtain();
1568 Parcel reply = Parcel.obtain();
1569 data.writeInterfaceToken(IActivityManager.descriptor);
1570 data.writeStrongBinder(token);
1571 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1572 reply.readException();
1573 ComponentName res = ComponentName.readFromParcel(reply);
1574 data.recycle();
1575 reply.recycle();
1576 return res;
1577 }
1578 public List getTasks(int maxNum, int flags,
1579 IThumbnailReceiver receiver) throws RemoteException {
1580 Parcel data = Parcel.obtain();
1581 Parcel reply = Parcel.obtain();
1582 data.writeInterfaceToken(IActivityManager.descriptor);
1583 data.writeInt(maxNum);
1584 data.writeInt(flags);
1585 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1586 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1587 reply.readException();
1588 ArrayList list = null;
1589 int N = reply.readInt();
1590 if (N >= 0) {
1591 list = new ArrayList();
1592 while (N > 0) {
1593 ActivityManager.RunningTaskInfo info =
1594 ActivityManager.RunningTaskInfo.CREATOR
1595 .createFromParcel(reply);
1596 list.add(info);
1597 N--;
1598 }
1599 }
1600 data.recycle();
1601 reply.recycle();
1602 return list;
1603 }
1604 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1605 int flags) throws RemoteException {
1606 Parcel data = Parcel.obtain();
1607 Parcel reply = Parcel.obtain();
1608 data.writeInterfaceToken(IActivityManager.descriptor);
1609 data.writeInt(maxNum);
1610 data.writeInt(flags);
1611 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1612 reply.readException();
1613 ArrayList<ActivityManager.RecentTaskInfo> list
1614 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1615 data.recycle();
1616 reply.recycle();
1617 return list;
1618 }
1619 public List getServices(int maxNum, int flags) throws RemoteException {
1620 Parcel data = Parcel.obtain();
1621 Parcel reply = Parcel.obtain();
1622 data.writeInterfaceToken(IActivityManager.descriptor);
1623 data.writeInt(maxNum);
1624 data.writeInt(flags);
1625 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1626 reply.readException();
1627 ArrayList list = null;
1628 int N = reply.readInt();
1629 if (N >= 0) {
1630 list = new ArrayList();
1631 while (N > 0) {
1632 ActivityManager.RunningServiceInfo info =
1633 ActivityManager.RunningServiceInfo.CREATOR
1634 .createFromParcel(reply);
1635 list.add(info);
1636 N--;
1637 }
1638 }
1639 data.recycle();
1640 reply.recycle();
1641 return list;
1642 }
1643 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1644 throws RemoteException {
1645 Parcel data = Parcel.obtain();
1646 Parcel reply = Parcel.obtain();
1647 data.writeInterfaceToken(IActivityManager.descriptor);
1648 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1649 reply.readException();
1650 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1651 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1652 data.recycle();
1653 reply.recycle();
1654 return list;
1655 }
1656 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1657 throws RemoteException {
1658 Parcel data = Parcel.obtain();
1659 Parcel reply = Parcel.obtain();
1660 data.writeInterfaceToken(IActivityManager.descriptor);
1661 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1662 reply.readException();
1663 ArrayList<ActivityManager.RunningAppProcessInfo> list
1664 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1665 data.recycle();
1666 reply.recycle();
1667 return list;
1668 }
1669 public void moveTaskToFront(int task) throws RemoteException
1670 {
1671 Parcel data = Parcel.obtain();
1672 Parcel reply = Parcel.obtain();
1673 data.writeInterfaceToken(IActivityManager.descriptor);
1674 data.writeInt(task);
1675 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1676 reply.readException();
1677 data.recycle();
1678 reply.recycle();
1679 }
1680 public void moveTaskToBack(int task) throws RemoteException
1681 {
1682 Parcel data = Parcel.obtain();
1683 Parcel reply = Parcel.obtain();
1684 data.writeInterfaceToken(IActivityManager.descriptor);
1685 data.writeInt(task);
1686 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1687 reply.readException();
1688 data.recycle();
1689 reply.recycle();
1690 }
1691 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1692 throws RemoteException {
1693 Parcel data = Parcel.obtain();
1694 Parcel reply = Parcel.obtain();
1695 data.writeInterfaceToken(IActivityManager.descriptor);
1696 data.writeStrongBinder(token);
1697 data.writeInt(nonRoot ? 1 : 0);
1698 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1699 reply.readException();
1700 boolean res = reply.readInt() != 0;
1701 data.recycle();
1702 reply.recycle();
1703 return res;
1704 }
1705 public void moveTaskBackwards(int task) throws RemoteException
1706 {
1707 Parcel data = Parcel.obtain();
1708 Parcel reply = Parcel.obtain();
1709 data.writeInterfaceToken(IActivityManager.descriptor);
1710 data.writeInt(task);
1711 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1712 reply.readException();
1713 data.recycle();
1714 reply.recycle();
1715 }
1716 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1717 {
1718 Parcel data = Parcel.obtain();
1719 Parcel reply = Parcel.obtain();
1720 data.writeInterfaceToken(IActivityManager.descriptor);
1721 data.writeStrongBinder(token);
1722 data.writeInt(onlyRoot ? 1 : 0);
1723 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1724 reply.readException();
1725 int res = reply.readInt();
1726 data.recycle();
1727 reply.recycle();
1728 return res;
1729 }
1730 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1731 {
1732 Parcel data = Parcel.obtain();
1733 Parcel reply = Parcel.obtain();
1734 data.writeInterfaceToken(IActivityManager.descriptor);
1735 data.writeStrongBinder(token);
1736 ComponentName.writeToParcel(className, data);
1737 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1738 reply.readException();
1739 data.recycle();
1740 reply.recycle();
1741 }
1742 public void reportThumbnail(IBinder token,
1743 Bitmap thumbnail, CharSequence description) throws RemoteException
1744 {
1745 Parcel data = Parcel.obtain();
1746 Parcel reply = Parcel.obtain();
1747 data.writeInterfaceToken(IActivityManager.descriptor);
1748 data.writeStrongBinder(token);
1749 if (thumbnail != null) {
1750 data.writeInt(1);
1751 thumbnail.writeToParcel(data, 0);
1752 } else {
1753 data.writeInt(0);
1754 }
1755 TextUtils.writeToParcel(description, data, 0);
1756 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1757 reply.readException();
1758 data.recycle();
1759 reply.recycle();
1760 }
1761 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1762 String name) throws RemoteException
1763 {
1764 Parcel data = Parcel.obtain();
1765 Parcel reply = Parcel.obtain();
1766 data.writeInterfaceToken(IActivityManager.descriptor);
1767 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1768 data.writeString(name);
1769 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1770 reply.readException();
1771 int res = reply.readInt();
1772 ContentProviderHolder cph = null;
1773 if (res != 0) {
1774 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1775 }
1776 data.recycle();
1777 reply.recycle();
1778 return cph;
1779 }
1780 public void publishContentProviders(IApplicationThread caller,
1781 List<ContentProviderHolder> providers) throws RemoteException
1782 {
1783 Parcel data = Parcel.obtain();
1784 Parcel reply = Parcel.obtain();
1785 data.writeInterfaceToken(IActivityManager.descriptor);
1786 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1787 data.writeTypedList(providers);
1788 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1789 reply.readException();
1790 data.recycle();
1791 reply.recycle();
1792 }
1793
1794 public void removeContentProvider(IApplicationThread caller,
1795 String name) throws RemoteException {
1796 Parcel data = Parcel.obtain();
1797 Parcel reply = Parcel.obtain();
1798 data.writeInterfaceToken(IActivityManager.descriptor);
1799 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1800 data.writeString(name);
1801 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1802 reply.readException();
1803 data.recycle();
1804 reply.recycle();
1805 }
1806
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07001807 public PendingIntent getRunningServiceControlPanel(ComponentName service)
1808 throws RemoteException
1809 {
1810 Parcel data = Parcel.obtain();
1811 Parcel reply = Parcel.obtain();
1812 data.writeInterfaceToken(IActivityManager.descriptor);
1813 service.writeToParcel(data, 0);
1814 mRemote.transact(GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION, data, reply, 0);
1815 reply.readException();
1816 PendingIntent res = PendingIntent.readPendingIntentOrNullFromParcel(reply);
1817 data.recycle();
1818 reply.recycle();
1819 return res;
1820 }
1821
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001822 public ComponentName startService(IApplicationThread caller, Intent service,
1823 String resolvedType) throws RemoteException
1824 {
1825 Parcel data = Parcel.obtain();
1826 Parcel reply = Parcel.obtain();
1827 data.writeInterfaceToken(IActivityManager.descriptor);
1828 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1829 service.writeToParcel(data, 0);
1830 data.writeString(resolvedType);
1831 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
1832 reply.readException();
1833 ComponentName res = ComponentName.readFromParcel(reply);
1834 data.recycle();
1835 reply.recycle();
1836 return res;
1837 }
1838 public int stopService(IApplicationThread caller, Intent service,
1839 String resolvedType) throws RemoteException
1840 {
1841 Parcel data = Parcel.obtain();
1842 Parcel reply = Parcel.obtain();
1843 data.writeInterfaceToken(IActivityManager.descriptor);
1844 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1845 service.writeToParcel(data, 0);
1846 data.writeString(resolvedType);
1847 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
1848 reply.readException();
1849 int res = reply.readInt();
1850 reply.recycle();
1851 data.recycle();
1852 return res;
1853 }
1854 public boolean stopServiceToken(ComponentName className, IBinder token,
1855 int startId) throws RemoteException {
1856 Parcel data = Parcel.obtain();
1857 Parcel reply = Parcel.obtain();
1858 data.writeInterfaceToken(IActivityManager.descriptor);
1859 ComponentName.writeToParcel(className, data);
1860 data.writeStrongBinder(token);
1861 data.writeInt(startId);
1862 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
1863 reply.readException();
1864 boolean res = reply.readInt() != 0;
1865 data.recycle();
1866 reply.recycle();
1867 return res;
1868 }
1869 public void setServiceForeground(ComponentName className, IBinder token,
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07001870 int id, Notification notification, boolean removeNotification) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001871 Parcel data = Parcel.obtain();
1872 Parcel reply = Parcel.obtain();
1873 data.writeInterfaceToken(IActivityManager.descriptor);
1874 ComponentName.writeToParcel(className, data);
1875 data.writeStrongBinder(token);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07001876 data.writeInt(id);
1877 if (notification != null) {
1878 data.writeInt(1);
1879 notification.writeToParcel(data, 0);
1880 } else {
1881 data.writeInt(0);
1882 }
1883 data.writeInt(removeNotification ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001884 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
1885 reply.readException();
1886 data.recycle();
1887 reply.recycle();
1888 }
1889 public int bindService(IApplicationThread caller, IBinder token,
1890 Intent service, String resolvedType, IServiceConnection connection,
1891 int flags) throws RemoteException {
1892 Parcel data = Parcel.obtain();
1893 Parcel reply = Parcel.obtain();
1894 data.writeInterfaceToken(IActivityManager.descriptor);
1895 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1896 data.writeStrongBinder(token);
1897 service.writeToParcel(data, 0);
1898 data.writeString(resolvedType);
1899 data.writeStrongBinder(connection.asBinder());
1900 data.writeInt(flags);
1901 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
1902 reply.readException();
1903 int res = reply.readInt();
1904 data.recycle();
1905 reply.recycle();
1906 return res;
1907 }
1908 public boolean unbindService(IServiceConnection connection) throws RemoteException
1909 {
1910 Parcel data = Parcel.obtain();
1911 Parcel reply = Parcel.obtain();
1912 data.writeInterfaceToken(IActivityManager.descriptor);
1913 data.writeStrongBinder(connection.asBinder());
1914 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
1915 reply.readException();
1916 boolean res = reply.readInt() != 0;
1917 data.recycle();
1918 reply.recycle();
1919 return res;
1920 }
1921
1922 public void publishService(IBinder token,
1923 Intent intent, IBinder service) throws RemoteException {
1924 Parcel data = Parcel.obtain();
1925 Parcel reply = Parcel.obtain();
1926 data.writeInterfaceToken(IActivityManager.descriptor);
1927 data.writeStrongBinder(token);
1928 intent.writeToParcel(data, 0);
1929 data.writeStrongBinder(service);
1930 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
1931 reply.readException();
1932 data.recycle();
1933 reply.recycle();
1934 }
1935
1936 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
1937 throws RemoteException {
1938 Parcel data = Parcel.obtain();
1939 Parcel reply = Parcel.obtain();
1940 data.writeInterfaceToken(IActivityManager.descriptor);
1941 data.writeStrongBinder(token);
1942 intent.writeToParcel(data, 0);
1943 data.writeInt(doRebind ? 1 : 0);
1944 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
1945 reply.readException();
1946 data.recycle();
1947 reply.recycle();
1948 }
1949
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07001950 public void serviceDoneExecuting(IBinder token, int type, int startId,
1951 int res) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001952 Parcel data = Parcel.obtain();
1953 Parcel reply = Parcel.obtain();
1954 data.writeInterfaceToken(IActivityManager.descriptor);
1955 data.writeStrongBinder(token);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07001956 data.writeInt(type);
1957 data.writeInt(startId);
1958 data.writeInt(res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001959 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1960 reply.readException();
1961 data.recycle();
1962 reply.recycle();
1963 }
1964
1965 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
1966 Parcel data = Parcel.obtain();
1967 Parcel reply = Parcel.obtain();
1968 data.writeInterfaceToken(IActivityManager.descriptor);
1969 service.writeToParcel(data, 0);
1970 data.writeString(resolvedType);
1971 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
1972 reply.readException();
1973 IBinder binder = reply.readStrongBinder();
1974 reply.recycle();
1975 data.recycle();
1976 return binder;
1977 }
1978
Christopher Tate181fafa2009-05-14 11:12:14 -07001979 public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
1980 throws RemoteException {
1981 Parcel data = Parcel.obtain();
1982 Parcel reply = Parcel.obtain();
1983 data.writeInterfaceToken(IActivityManager.descriptor);
1984 app.writeToParcel(data, 0);
1985 data.writeInt(backupRestoreMode);
1986 mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
1987 reply.readException();
1988 boolean success = reply.readInt() != 0;
1989 reply.recycle();
1990 data.recycle();
1991 return success;
1992 }
1993
1994 public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException {
1995 Parcel data = Parcel.obtain();
1996 Parcel reply = Parcel.obtain();
1997 data.writeInterfaceToken(IActivityManager.descriptor);
1998 data.writeString(packageName);
1999 data.writeStrongBinder(agent);
2000 mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0);
2001 reply.recycle();
2002 data.recycle();
2003 }
2004
2005 public void unbindBackupAgent(ApplicationInfo app) throws RemoteException {
2006 Parcel data = Parcel.obtain();
2007 Parcel reply = Parcel.obtain();
2008 data.writeInterfaceToken(IActivityManager.descriptor);
2009 app.writeToParcel(data, 0);
2010 mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2011 reply.readException();
2012 reply.recycle();
2013 data.recycle();
2014 }
2015
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002016 public boolean startInstrumentation(ComponentName className, String profileFile,
2017 int flags, Bundle arguments, IInstrumentationWatcher watcher)
2018 throws RemoteException {
2019 Parcel data = Parcel.obtain();
2020 Parcel reply = Parcel.obtain();
2021 data.writeInterfaceToken(IActivityManager.descriptor);
2022 ComponentName.writeToParcel(className, data);
2023 data.writeString(profileFile);
2024 data.writeInt(flags);
2025 data.writeBundle(arguments);
2026 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2027 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2028 reply.readException();
2029 boolean res = reply.readInt() != 0;
2030 reply.recycle();
2031 data.recycle();
2032 return res;
2033 }
2034
2035 public void finishInstrumentation(IApplicationThread target,
2036 int resultCode, Bundle results) throws RemoteException {
2037 Parcel data = Parcel.obtain();
2038 Parcel reply = Parcel.obtain();
2039 data.writeInterfaceToken(IActivityManager.descriptor);
2040 data.writeStrongBinder(target != null ? target.asBinder() : null);
2041 data.writeInt(resultCode);
2042 data.writeBundle(results);
2043 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2044 reply.readException();
2045 data.recycle();
2046 reply.recycle();
2047 }
2048 public Configuration getConfiguration() throws RemoteException
2049 {
2050 Parcel data = Parcel.obtain();
2051 Parcel reply = Parcel.obtain();
2052 data.writeInterfaceToken(IActivityManager.descriptor);
2053 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
2054 reply.readException();
2055 Configuration res = Configuration.CREATOR.createFromParcel(reply);
2056 reply.recycle();
2057 data.recycle();
2058 return res;
2059 }
2060 public void updateConfiguration(Configuration values) throws RemoteException
2061 {
2062 Parcel data = Parcel.obtain();
2063 Parcel reply = Parcel.obtain();
2064 data.writeInterfaceToken(IActivityManager.descriptor);
2065 values.writeToParcel(data, 0);
2066 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
2067 reply.readException();
2068 data.recycle();
2069 reply.recycle();
2070 }
2071 public void setRequestedOrientation(IBinder token, int requestedOrientation)
2072 throws RemoteException {
2073 Parcel data = Parcel.obtain();
2074 Parcel reply = Parcel.obtain();
2075 data.writeInterfaceToken(IActivityManager.descriptor);
2076 data.writeStrongBinder(token);
2077 data.writeInt(requestedOrientation);
2078 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2079 reply.readException();
2080 data.recycle();
2081 reply.recycle();
2082 }
2083 public int getRequestedOrientation(IBinder token) throws RemoteException {
2084 Parcel data = Parcel.obtain();
2085 Parcel reply = Parcel.obtain();
2086 data.writeInterfaceToken(IActivityManager.descriptor);
2087 data.writeStrongBinder(token);
2088 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2089 reply.readException();
2090 int res = reply.readInt();
2091 data.recycle();
2092 reply.recycle();
2093 return res;
2094 }
2095 public ComponentName getActivityClassForToken(IBinder token)
2096 throws RemoteException {
2097 Parcel data = Parcel.obtain();
2098 Parcel reply = Parcel.obtain();
2099 data.writeInterfaceToken(IActivityManager.descriptor);
2100 data.writeStrongBinder(token);
2101 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
2102 reply.readException();
2103 ComponentName res = ComponentName.readFromParcel(reply);
2104 data.recycle();
2105 reply.recycle();
2106 return res;
2107 }
2108 public String getPackageForToken(IBinder token) throws RemoteException
2109 {
2110 Parcel data = Parcel.obtain();
2111 Parcel reply = Parcel.obtain();
2112 data.writeInterfaceToken(IActivityManager.descriptor);
2113 data.writeStrongBinder(token);
2114 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
2115 reply.readException();
2116 String res = reply.readString();
2117 data.recycle();
2118 reply.recycle();
2119 return res;
2120 }
2121 public IIntentSender getIntentSender(int type,
2122 String packageName, IBinder token, String resultWho,
2123 int requestCode, Intent intent, String resolvedType, int flags)
2124 throws RemoteException {
2125 Parcel data = Parcel.obtain();
2126 Parcel reply = Parcel.obtain();
2127 data.writeInterfaceToken(IActivityManager.descriptor);
2128 data.writeInt(type);
2129 data.writeString(packageName);
2130 data.writeStrongBinder(token);
2131 data.writeString(resultWho);
2132 data.writeInt(requestCode);
2133 if (intent != null) {
2134 data.writeInt(1);
2135 intent.writeToParcel(data, 0);
2136 } else {
2137 data.writeInt(0);
2138 }
2139 data.writeString(resolvedType);
2140 data.writeInt(flags);
2141 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
2142 reply.readException();
2143 IIntentSender res = IIntentSender.Stub.asInterface(
2144 reply.readStrongBinder());
2145 data.recycle();
2146 reply.recycle();
2147 return res;
2148 }
2149 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
2150 Parcel data = Parcel.obtain();
2151 Parcel reply = Parcel.obtain();
2152 data.writeInterfaceToken(IActivityManager.descriptor);
2153 data.writeStrongBinder(sender.asBinder());
2154 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
2155 reply.readException();
2156 data.recycle();
2157 reply.recycle();
2158 }
2159 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
2160 Parcel data = Parcel.obtain();
2161 Parcel reply = Parcel.obtain();
2162 data.writeInterfaceToken(IActivityManager.descriptor);
2163 data.writeStrongBinder(sender.asBinder());
2164 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
2165 reply.readException();
2166 String res = reply.readString();
2167 data.recycle();
2168 reply.recycle();
2169 return res;
2170 }
2171 public void setProcessLimit(int max) throws RemoteException
2172 {
2173 Parcel data = Parcel.obtain();
2174 Parcel reply = Parcel.obtain();
2175 data.writeInterfaceToken(IActivityManager.descriptor);
2176 data.writeInt(max);
2177 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2178 reply.readException();
2179 data.recycle();
2180 reply.recycle();
2181 }
2182 public int getProcessLimit() throws RemoteException
2183 {
2184 Parcel data = Parcel.obtain();
2185 Parcel reply = Parcel.obtain();
2186 data.writeInterfaceToken(IActivityManager.descriptor);
2187 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2188 reply.readException();
2189 int res = reply.readInt();
2190 data.recycle();
2191 reply.recycle();
2192 return res;
2193 }
2194 public void setProcessForeground(IBinder token, int pid,
2195 boolean isForeground) throws RemoteException {
2196 Parcel data = Parcel.obtain();
2197 Parcel reply = Parcel.obtain();
2198 data.writeInterfaceToken(IActivityManager.descriptor);
2199 data.writeStrongBinder(token);
2200 data.writeInt(pid);
2201 data.writeInt(isForeground ? 1 : 0);
2202 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
2203 reply.readException();
2204 data.recycle();
2205 reply.recycle();
2206 }
2207 public int checkPermission(String permission, int pid, int uid)
2208 throws RemoteException {
2209 Parcel data = Parcel.obtain();
2210 Parcel reply = Parcel.obtain();
2211 data.writeInterfaceToken(IActivityManager.descriptor);
2212 data.writeString(permission);
2213 data.writeInt(pid);
2214 data.writeInt(uid);
2215 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
2216 reply.readException();
2217 int res = reply.readInt();
2218 data.recycle();
2219 reply.recycle();
2220 return res;
2221 }
2222 public boolean clearApplicationUserData(final String packageName,
2223 final IPackageDataObserver observer) throws RemoteException {
2224 Parcel data = Parcel.obtain();
2225 Parcel reply = Parcel.obtain();
2226 data.writeInterfaceToken(IActivityManager.descriptor);
2227 data.writeString(packageName);
2228 data.writeStrongBinder(observer.asBinder());
2229 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
2230 reply.readException();
2231 boolean res = reply.readInt() != 0;
2232 data.recycle();
2233 reply.recycle();
2234 return res;
2235 }
2236 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
2237 throws RemoteException {
2238 Parcel data = Parcel.obtain();
2239 Parcel reply = Parcel.obtain();
2240 data.writeInterfaceToken(IActivityManager.descriptor);
2241 uri.writeToParcel(data, 0);
2242 data.writeInt(pid);
2243 data.writeInt(uid);
2244 data.writeInt(mode);
2245 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
2246 reply.readException();
2247 int res = reply.readInt();
2248 data.recycle();
2249 reply.recycle();
2250 return res;
2251 }
2252 public void grantUriPermission(IApplicationThread caller, String targetPkg,
2253 Uri uri, int mode) throws RemoteException {
2254 Parcel data = Parcel.obtain();
2255 Parcel reply = Parcel.obtain();
2256 data.writeInterfaceToken(IActivityManager.descriptor);
2257 data.writeStrongBinder(caller.asBinder());
2258 data.writeString(targetPkg);
2259 uri.writeToParcel(data, 0);
2260 data.writeInt(mode);
2261 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2262 reply.readException();
2263 data.recycle();
2264 reply.recycle();
2265 }
2266 public void revokeUriPermission(IApplicationThread caller, Uri uri,
2267 int mode) throws RemoteException {
2268 Parcel data = Parcel.obtain();
2269 Parcel reply = Parcel.obtain();
2270 data.writeInterfaceToken(IActivityManager.descriptor);
2271 data.writeStrongBinder(caller.asBinder());
2272 uri.writeToParcel(data, 0);
2273 data.writeInt(mode);
2274 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2275 reply.readException();
2276 data.recycle();
2277 reply.recycle();
2278 }
2279 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
2280 throws RemoteException {
2281 Parcel data = Parcel.obtain();
2282 Parcel reply = Parcel.obtain();
2283 data.writeInterfaceToken(IActivityManager.descriptor);
2284 data.writeStrongBinder(who.asBinder());
2285 data.writeInt(waiting ? 1 : 0);
2286 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
2287 reply.readException();
2288 data.recycle();
2289 reply.recycle();
2290 }
2291 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
2292 Parcel data = Parcel.obtain();
2293 Parcel reply = Parcel.obtain();
2294 data.writeInterfaceToken(IActivityManager.descriptor);
2295 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
2296 reply.readException();
2297 outInfo.readFromParcel(reply);
2298 data.recycle();
2299 reply.recycle();
2300 }
2301 public void unhandledBack() throws RemoteException
2302 {
2303 Parcel data = Parcel.obtain();
2304 Parcel reply = Parcel.obtain();
2305 data.writeInterfaceToken(IActivityManager.descriptor);
2306 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
2307 reply.readException();
2308 data.recycle();
2309 reply.recycle();
2310 }
2311 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
2312 {
2313 Parcel data = Parcel.obtain();
2314 Parcel reply = Parcel.obtain();
2315 data.writeInterfaceToken(IActivityManager.descriptor);
2316 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
2317 reply.readException();
2318 ParcelFileDescriptor pfd = null;
2319 if (reply.readInt() != 0) {
2320 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
2321 }
2322 data.recycle();
2323 reply.recycle();
2324 return pfd;
2325 }
2326 public void goingToSleep() throws RemoteException
2327 {
2328 Parcel data = Parcel.obtain();
2329 Parcel reply = Parcel.obtain();
2330 data.writeInterfaceToken(IActivityManager.descriptor);
2331 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
2332 reply.readException();
2333 data.recycle();
2334 reply.recycle();
2335 }
2336 public void wakingUp() throws RemoteException
2337 {
2338 Parcel data = Parcel.obtain();
2339 Parcel reply = Parcel.obtain();
2340 data.writeInterfaceToken(IActivityManager.descriptor);
2341 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
2342 reply.readException();
2343 data.recycle();
2344 reply.recycle();
2345 }
2346 public void setDebugApp(
2347 String packageName, boolean waitForDebugger, boolean persistent)
2348 throws RemoteException
2349 {
2350 Parcel data = Parcel.obtain();
2351 Parcel reply = Parcel.obtain();
2352 data.writeInterfaceToken(IActivityManager.descriptor);
2353 data.writeString(packageName);
2354 data.writeInt(waitForDebugger ? 1 : 0);
2355 data.writeInt(persistent ? 1 : 0);
2356 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2357 reply.readException();
2358 data.recycle();
2359 reply.recycle();
2360 }
2361 public void setAlwaysFinish(boolean enabled) throws RemoteException
2362 {
2363 Parcel data = Parcel.obtain();
2364 Parcel reply = Parcel.obtain();
2365 data.writeInterfaceToken(IActivityManager.descriptor);
2366 data.writeInt(enabled ? 1 : 0);
2367 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2368 reply.readException();
2369 data.recycle();
2370 reply.recycle();
2371 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002372 public void setActivityController(IActivityController watcher) 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(watcher != null ? watcher.asBinder() : null);
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002378 mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002379 reply.readException();
2380 data.recycle();
2381 reply.recycle();
2382 }
2383 public void enterSafeMode() throws RemoteException {
2384 Parcel data = Parcel.obtain();
2385 data.writeInterfaceToken(IActivityManager.descriptor);
2386 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2387 data.recycle();
2388 }
2389 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2390 Parcel data = Parcel.obtain();
2391 data.writeStrongBinder(sender.asBinder());
2392 data.writeInterfaceToken(IActivityManager.descriptor);
2393 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2394 data.recycle();
2395 }
2396 public boolean killPidsForMemory(int[] pids) throws RemoteException {
2397 Parcel data = Parcel.obtain();
2398 Parcel reply = Parcel.obtain();
2399 data.writeInterfaceToken(IActivityManager.descriptor);
2400 data.writeIntArray(pids);
2401 mRemote.transact(KILL_PIDS_FOR_MEMORY_TRANSACTION, data, reply, 0);
2402 boolean res = reply.readInt() != 0;
2403 data.recycle();
2404 reply.recycle();
2405 return res;
2406 }
2407 public void reportPss(IApplicationThread caller, int pss) throws RemoteException {
2408 Parcel data = Parcel.obtain();
2409 data.writeInterfaceToken(IActivityManager.descriptor);
2410 data.writeStrongBinder(caller.asBinder());
2411 data.writeInt(pss);
2412 mRemote.transact(REPORT_PSS_TRANSACTION, data, null, 0);
2413 data.recycle();
2414 }
2415 public void startRunning(String pkg, String cls, String action,
2416 String indata) throws RemoteException {
2417 Parcel data = Parcel.obtain();
2418 Parcel reply = Parcel.obtain();
2419 data.writeInterfaceToken(IActivityManager.descriptor);
2420 data.writeString(pkg);
2421 data.writeString(cls);
2422 data.writeString(action);
2423 data.writeString(indata);
2424 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2425 reply.readException();
2426 data.recycle();
2427 reply.recycle();
2428 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002429 public boolean testIsSystemReady()
2430 {
2431 /* this base class version is never called */
2432 return true;
2433 }
Dan Egnor60d87622009-12-16 16:32:58 -08002434 public void handleApplicationCrash(IBinder app,
2435 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
2436 {
2437 Parcel data = Parcel.obtain();
2438 Parcel reply = Parcel.obtain();
2439 data.writeInterfaceToken(IActivityManager.descriptor);
2440 data.writeStrongBinder(app);
2441 crashInfo.writeToParcel(data, 0);
2442 mRemote.transact(HANDLE_APPLICATION_CRASH_TRANSACTION, data, reply, 0);
2443 reply.readException();
2444 reply.recycle();
2445 data.recycle();
2446 }
2447 public boolean handleApplicationWtf(IBinder app, String tag,
Dan Egnorb7f03672009-12-09 16:22:32 -08002448 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002449 {
2450 Parcel data = Parcel.obtain();
2451 Parcel reply = Parcel.obtain();
2452 data.writeInterfaceToken(IActivityManager.descriptor);
2453 data.writeStrongBinder(app);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002454 data.writeString(tag);
Dan Egnorb7f03672009-12-09 16:22:32 -08002455 crashInfo.writeToParcel(data, 0);
Dan Egnor60d87622009-12-16 16:32:58 -08002456 mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002457 reply.readException();
Dan Egnor60d87622009-12-16 16:32:58 -08002458 boolean res = reply.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002459 reply.recycle();
2460 data.recycle();
Dan Egnor60d87622009-12-16 16:32:58 -08002461 return res;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002462 }
Dan Egnorb7f03672009-12-09 16:22:32 -08002463
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002464 public void signalPersistentProcesses(int sig) throws RemoteException {
2465 Parcel data = Parcel.obtain();
2466 Parcel reply = Parcel.obtain();
2467 data.writeInterfaceToken(IActivityManager.descriptor);
2468 data.writeInt(sig);
2469 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2470 reply.readException();
2471 data.recycle();
2472 reply.recycle();
2473 }
2474
Dianne Hackborn03abb812010-01-04 18:43:19 -08002475 public void killBackgroundProcesses(String packageName) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002476 Parcel data = Parcel.obtain();
2477 Parcel reply = Parcel.obtain();
2478 data.writeInterfaceToken(IActivityManager.descriptor);
2479 data.writeString(packageName);
Dianne Hackborn03abb812010-01-04 18:43:19 -08002480 mRemote.transact(KILL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0);
2481 reply.readException();
2482 data.recycle();
2483 reply.recycle();
2484 }
2485
2486 public void forceStopPackage(String packageName) throws RemoteException {
2487 Parcel data = Parcel.obtain();
2488 Parcel reply = Parcel.obtain();
2489 data.writeInterfaceToken(IActivityManager.descriptor);
2490 data.writeString(packageName);
2491 mRemote.transact(FORCE_STOP_PACKAGE_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002492 reply.readException();
2493 data.recycle();
2494 reply.recycle();
2495 }
2496
2497 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2498 {
2499 Parcel data = Parcel.obtain();
2500 Parcel reply = Parcel.obtain();
2501 data.writeInterfaceToken(IActivityManager.descriptor);
2502 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2503 reply.readException();
2504 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2505 reply.recycle();
2506 data.recycle();
2507 return res;
2508 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002509
2510 public boolean profileControl(String process, boolean start,
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002511 String path, ParcelFileDescriptor fd) throws RemoteException
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002512 {
2513 Parcel data = Parcel.obtain();
2514 Parcel reply = Parcel.obtain();
2515 data.writeInterfaceToken(IActivityManager.descriptor);
2516 data.writeString(process);
2517 data.writeInt(start ? 1 : 0);
2518 data.writeString(path);
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002519 if (fd != null) {
2520 data.writeInt(1);
2521 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
2522 } else {
2523 data.writeInt(0);
2524 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002525 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2526 reply.readException();
2527 boolean res = reply.readInt() != 0;
2528 reply.recycle();
2529 data.recycle();
2530 return res;
2531 }
2532
Dianne Hackborn55280a92009-05-07 15:53:46 -07002533 public boolean shutdown(int timeout) throws RemoteException
2534 {
2535 Parcel data = Parcel.obtain();
2536 Parcel reply = Parcel.obtain();
2537 data.writeInterfaceToken(IActivityManager.descriptor);
2538 data.writeInt(timeout);
2539 mRemote.transact(SHUTDOWN_TRANSACTION, data, reply, 0);
2540 reply.readException();
2541 boolean res = reply.readInt() != 0;
2542 reply.recycle();
2543 data.recycle();
2544 return res;
2545 }
2546
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07002547 public void stopAppSwitches() throws RemoteException {
2548 Parcel data = Parcel.obtain();
2549 Parcel reply = Parcel.obtain();
2550 data.writeInterfaceToken(IActivityManager.descriptor);
2551 mRemote.transact(STOP_APP_SWITCHES_TRANSACTION, data, reply, 0);
2552 reply.readException();
2553 reply.recycle();
2554 data.recycle();
2555 }
2556
2557 public void resumeAppSwitches() throws RemoteException {
2558 Parcel data = Parcel.obtain();
2559 Parcel reply = Parcel.obtain();
2560 data.writeInterfaceToken(IActivityManager.descriptor);
2561 mRemote.transact(RESUME_APP_SWITCHES_TRANSACTION, data, reply, 0);
2562 reply.readException();
2563 reply.recycle();
2564 data.recycle();
2565 }
2566
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002567 public void registerActivityWatcher(IActivityWatcher watcher)
2568 throws RemoteException {
2569 Parcel data = Parcel.obtain();
2570 Parcel reply = Parcel.obtain();
2571 data.writeInterfaceToken(IActivityManager.descriptor);
2572 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2573 mRemote.transact(REGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2574 reply.readException();
2575 data.recycle();
2576 reply.recycle();
2577 }
2578
2579 public void unregisterActivityWatcher(IActivityWatcher watcher)
2580 throws RemoteException {
2581 Parcel data = Parcel.obtain();
2582 Parcel reply = Parcel.obtain();
2583 data.writeInterfaceToken(IActivityManager.descriptor);
2584 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2585 mRemote.transact(UNREGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2586 reply.readException();
2587 data.recycle();
2588 reply.recycle();
2589 }
2590
Dianne Hackborn2d91af02009-07-16 13:34:33 -07002591 public int startActivityInPackage(int uid,
2592 Intent intent, String resolvedType, IBinder resultTo,
2593 String resultWho, int requestCode, boolean onlyIfNeeded)
2594 throws RemoteException {
2595 Parcel data = Parcel.obtain();
2596 Parcel reply = Parcel.obtain();
2597 data.writeInterfaceToken(IActivityManager.descriptor);
2598 data.writeInt(uid);
2599 intent.writeToParcel(data, 0);
2600 data.writeString(resolvedType);
2601 data.writeStrongBinder(resultTo);
2602 data.writeString(resultWho);
2603 data.writeInt(requestCode);
2604 data.writeInt(onlyIfNeeded ? 1 : 0);
2605 mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
2606 reply.readException();
2607 int result = reply.readInt();
2608 reply.recycle();
2609 data.recycle();
2610 return result;
2611 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002612
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07002613 public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
2614 Parcel data = Parcel.obtain();
2615 Parcel reply = Parcel.obtain();
2616 data.writeInterfaceToken(IActivityManager.descriptor);
2617 data.writeString(pkg);
2618 data.writeInt(uid);
2619 mRemote.transact(KILL_APPLICATION_WITH_UID_TRANSACTION, data, reply, 0);
2620 reply.readException();
2621 data.recycle();
2622 reply.recycle();
2623 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002624
2625 public void closeSystemDialogs(String reason) throws RemoteException {
2626 Parcel data = Parcel.obtain();
2627 Parcel reply = Parcel.obtain();
2628 data.writeInterfaceToken(IActivityManager.descriptor);
2629 data.writeString(reason);
2630 mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
2631 reply.readException();
2632 data.recycle();
2633 reply.recycle();
2634 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002635
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002636 public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002637 throws RemoteException {
2638 Parcel data = Parcel.obtain();
2639 Parcel reply = Parcel.obtain();
2640 data.writeInterfaceToken(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002641 data.writeIntArray(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002642 mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
2643 reply.readException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002644 Debug.MemoryInfo[] res = reply.createTypedArray(Debug.MemoryInfo.CREATOR);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002645 data.recycle();
2646 reply.recycle();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002647 return res;
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002648 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07002649
2650 public void killApplicationProcess(String processName, int uid) throws RemoteException {
2651 Parcel data = Parcel.obtain();
2652 Parcel reply = Parcel.obtain();
2653 data.writeInterfaceToken(IActivityManager.descriptor);
2654 data.writeString(processName);
2655 data.writeInt(uid);
2656 mRemote.transact(KILL_APPLICATION_PROCESS_TRANSACTION, data, reply, 0);
2657 reply.readException();
2658 data.recycle();
2659 reply.recycle();
2660 }
2661
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07002662 public void overridePendingTransition(IBinder token, String packageName,
2663 int enterAnim, int exitAnim) throws RemoteException {
2664 Parcel data = Parcel.obtain();
2665 Parcel reply = Parcel.obtain();
2666 data.writeInterfaceToken(IActivityManager.descriptor);
2667 data.writeStrongBinder(token);
2668 data.writeString(packageName);
2669 data.writeInt(enterAnim);
2670 data.writeInt(exitAnim);
2671 mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
2672 reply.readException();
2673 data.recycle();
2674 reply.recycle();
2675 }
2676
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08002677 public boolean isUserAMonkey() throws RemoteException {
2678 Parcel data = Parcel.obtain();
2679 Parcel reply = Parcel.obtain();
2680 data.writeInterfaceToken(IActivityManager.descriptor);
2681 mRemote.transact(IS_USER_A_MONKEY_TRANSACTION, data, reply, 0);
2682 reply.readException();
2683 boolean res = reply.readInt() != 0;
2684 data.recycle();
2685 reply.recycle();
2686 return res;
2687 }
2688
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002689 private IBinder mRemote;
2690}