blob: b558318a0c25d8c39052c36999b6ec2e383a1f30 [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;
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -070040import android.os.StrictMode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import android.text.TextUtils;
42import android.util.Config;
43import android.util.Log;
44
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045import java.util.ArrayList;
46import java.util.List;
47
48/** {@hide} */
49public abstract class ActivityManagerNative extends Binder implements IActivityManager
50{
51 /**
52 * Cast a Binder object into an activity manager interface, generating
53 * a proxy if needed.
54 */
55 static public IActivityManager asInterface(IBinder obj)
56 {
57 if (obj == null) {
58 return null;
59 }
60 IActivityManager in =
61 (IActivityManager)obj.queryLocalInterface(descriptor);
62 if (in != null) {
63 return in;
64 }
65
66 return new ActivityManagerProxy(obj);
67 }
68
69 /**
70 * Retrieve the system's default/global activity manager.
71 */
72 static public IActivityManager getDefault()
73 {
74 if (gDefault != null) {
75 //if (Config.LOGV) Log.v(
76 // "ActivityManager", "returning cur default = " + gDefault);
77 return gDefault;
78 }
79 IBinder b = ServiceManager.getService("activity");
80 if (Config.LOGV) Log.v(
81 "ActivityManager", "default service binder = " + b);
82 gDefault = asInterface(b);
83 if (Config.LOGV) Log.v(
84 "ActivityManager", "default service = " + gDefault);
85 return gDefault;
86 }
87
88 /**
89 * Convenience for checking whether the system is ready. For internal use only.
90 */
91 static public boolean isSystemReady() {
92 if (!sSystemReady) {
93 sSystemReady = getDefault().testIsSystemReady();
94 }
95 return sSystemReady;
96 }
97 static boolean sSystemReady = false;
98
99 /**
100 * Convenience for sending a sticky broadcast. For internal use only.
101 * If you don't care about permission, use null.
102 */
103 static public void broadcastStickyIntent(Intent intent, String permission)
104 {
105 try {
106 getDefault().broadcastIntent(
107 null, intent, null, null, Activity.RESULT_OK, null, null,
108 null /*permission*/, false, true);
109 } catch (RemoteException ex) {
110 }
111 }
112
113 static public void noteWakeupAlarm(PendingIntent ps) {
114 try {
115 getDefault().noteWakeupAlarm(ps.getTarget());
116 } catch (RemoteException ex) {
117 }
118 }
119
120 public ActivityManagerNative()
121 {
122 attachInterface(this, descriptor);
123 }
124
125 public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
126 throws RemoteException {
127 switch (code) {
128 case START_ACTIVITY_TRANSACTION:
129 {
130 data.enforceInterface(IActivityManager.descriptor);
131 IBinder b = data.readStrongBinder();
132 IApplicationThread app = ApplicationThreadNative.asInterface(b);
133 Intent intent = Intent.CREATOR.createFromParcel(data);
134 String resolvedType = data.readString();
135 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
136 int grantedMode = data.readInt();
137 IBinder resultTo = data.readStrongBinder();
138 String resultWho = data.readString();
139 int requestCode = data.readInt();
140 boolean onlyIfNeeded = data.readInt() != 0;
141 boolean debug = data.readInt() != 0;
142 int result = startActivity(app, intent, resolvedType,
143 grantedUriPermissions, grantedMode, resultTo, resultWho,
144 requestCode, onlyIfNeeded, debug);
145 reply.writeNoException();
146 reply.writeInt(result);
147 return true;
148 }
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700149
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -0800150 case START_ACTIVITY_AND_WAIT_TRANSACTION:
151 {
152 data.enforceInterface(IActivityManager.descriptor);
153 IBinder b = data.readStrongBinder();
154 IApplicationThread app = ApplicationThreadNative.asInterface(b);
155 Intent intent = Intent.CREATOR.createFromParcel(data);
156 String resolvedType = data.readString();
157 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
158 int grantedMode = data.readInt();
159 IBinder resultTo = data.readStrongBinder();
160 String resultWho = data.readString();
161 int requestCode = data.readInt();
162 boolean onlyIfNeeded = data.readInt() != 0;
163 boolean debug = data.readInt() != 0;
164 WaitResult result = startActivityAndWait(app, intent, resolvedType,
165 grantedUriPermissions, grantedMode, resultTo, resultWho,
166 requestCode, onlyIfNeeded, debug);
167 reply.writeNoException();
168 result.writeToParcel(reply, 0);
169 return true;
170 }
171
Dianne Hackborn2ccda4d2010-03-22 21:49:15 -0700172 case START_ACTIVITY_WITH_CONFIG_TRANSACTION:
173 {
174 data.enforceInterface(IActivityManager.descriptor);
175 IBinder b = data.readStrongBinder();
176 IApplicationThread app = ApplicationThreadNative.asInterface(b);
177 Intent intent = Intent.CREATOR.createFromParcel(data);
178 String resolvedType = data.readString();
179 Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
180 int grantedMode = data.readInt();
181 IBinder resultTo = data.readStrongBinder();
182 String resultWho = data.readString();
183 int requestCode = data.readInt();
184 boolean onlyIfNeeded = data.readInt() != 0;
185 boolean debug = data.readInt() != 0;
186 Configuration config = Configuration.CREATOR.createFromParcel(data);
187 int result = startActivityWithConfig(app, intent, resolvedType,
188 grantedUriPermissions, grantedMode, resultTo, resultWho,
189 requestCode, onlyIfNeeded, debug, config);
190 reply.writeNoException();
191 reply.writeInt(result);
192 return true;
193 }
194
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700195 case START_ACTIVITY_INTENT_SENDER_TRANSACTION:
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700196 {
197 data.enforceInterface(IActivityManager.descriptor);
198 IBinder b = data.readStrongBinder();
199 IApplicationThread app = ApplicationThreadNative.asInterface(b);
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700200 IntentSender intent = IntentSender.CREATOR.createFromParcel(data);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700201 Intent fillInIntent = null;
202 if (data.readInt() != 0) {
203 fillInIntent = Intent.CREATOR.createFromParcel(data);
204 }
205 String resolvedType = data.readString();
206 IBinder resultTo = data.readStrongBinder();
207 String resultWho = data.readString();
208 int requestCode = data.readInt();
209 int flagsMask = data.readInt();
210 int flagsValues = data.readInt();
Dianne Hackbornfa82f222009-09-17 15:14:12 -0700211 int result = startActivityIntentSender(app, intent,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -0700212 fillInIntent, resolvedType, resultTo, resultWho,
213 requestCode, flagsMask, flagsValues);
214 reply.writeNoException();
215 reply.writeInt(result);
216 return true;
217 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800218
219 case START_NEXT_MATCHING_ACTIVITY_TRANSACTION:
220 {
221 data.enforceInterface(IActivityManager.descriptor);
222 IBinder callingActivity = data.readStrongBinder();
223 Intent intent = Intent.CREATOR.createFromParcel(data);
224 boolean result = startNextMatchingActivity(callingActivity, intent);
225 reply.writeNoException();
226 reply.writeInt(result ? 1 : 0);
227 return true;
228 }
229
230 case FINISH_ACTIVITY_TRANSACTION: {
231 data.enforceInterface(IActivityManager.descriptor);
232 IBinder token = data.readStrongBinder();
233 Intent resultData = null;
234 int resultCode = data.readInt();
235 if (data.readInt() != 0) {
236 resultData = Intent.CREATOR.createFromParcel(data);
237 }
238 boolean res = finishActivity(token, resultCode, resultData);
239 reply.writeNoException();
240 reply.writeInt(res ? 1 : 0);
241 return true;
242 }
243
244 case FINISH_SUB_ACTIVITY_TRANSACTION: {
245 data.enforceInterface(IActivityManager.descriptor);
246 IBinder token = data.readStrongBinder();
247 String resultWho = data.readString();
248 int requestCode = data.readInt();
249 finishSubActivity(token, resultWho, requestCode);
250 reply.writeNoException();
251 return true;
252 }
253
Dianne Hackborn061d58a2010-03-12 15:07:06 -0800254 case WILL_ACTIVITY_BE_VISIBLE_TRANSACTION: {
255 data.enforceInterface(IActivityManager.descriptor);
256 IBinder token = data.readStrongBinder();
257 boolean res = willActivityBeVisible(token);
258 reply.writeNoException();
259 reply.writeInt(res ? 1 : 0);
260 return true;
261 }
262
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263 case REGISTER_RECEIVER_TRANSACTION:
264 {
265 data.enforceInterface(IActivityManager.descriptor);
266 IBinder b = data.readStrongBinder();
267 IApplicationThread app =
268 b != null ? ApplicationThreadNative.asInterface(b) : null;
269 b = data.readStrongBinder();
270 IIntentReceiver rec
271 = b != null ? IIntentReceiver.Stub.asInterface(b) : null;
272 IntentFilter filter = IntentFilter.CREATOR.createFromParcel(data);
273 String perm = data.readString();
274 Intent intent = registerReceiver(app, rec, filter, perm);
275 reply.writeNoException();
276 if (intent != null) {
277 reply.writeInt(1);
278 intent.writeToParcel(reply, 0);
279 } else {
280 reply.writeInt(0);
281 }
282 return true;
283 }
284
285 case UNREGISTER_RECEIVER_TRANSACTION:
286 {
287 data.enforceInterface(IActivityManager.descriptor);
288 IBinder b = data.readStrongBinder();
289 if (b == null) {
290 return true;
291 }
292 IIntentReceiver rec = IIntentReceiver.Stub.asInterface(b);
293 unregisterReceiver(rec);
294 reply.writeNoException();
295 return true;
296 }
297
298 case BROADCAST_INTENT_TRANSACTION:
299 {
300 data.enforceInterface(IActivityManager.descriptor);
301 IBinder b = data.readStrongBinder();
302 IApplicationThread app =
303 b != null ? ApplicationThreadNative.asInterface(b) : null;
304 Intent intent = Intent.CREATOR.createFromParcel(data);
305 String resolvedType = data.readString();
306 b = data.readStrongBinder();
307 IIntentReceiver resultTo =
308 b != null ? IIntentReceiver.Stub.asInterface(b) : null;
309 int resultCode = data.readInt();
310 String resultData = data.readString();
311 Bundle resultExtras = data.readBundle();
312 String perm = data.readString();
313 boolean serialized = data.readInt() != 0;
314 boolean sticky = data.readInt() != 0;
315 int res = broadcastIntent(app, intent, resolvedType, resultTo,
316 resultCode, resultData, resultExtras, perm,
317 serialized, sticky);
318 reply.writeNoException();
319 reply.writeInt(res);
320 return true;
321 }
322
323 case UNBROADCAST_INTENT_TRANSACTION:
324 {
325 data.enforceInterface(IActivityManager.descriptor);
326 IBinder b = data.readStrongBinder();
327 IApplicationThread app = b != null ? ApplicationThreadNative.asInterface(b) : null;
328 Intent intent = Intent.CREATOR.createFromParcel(data);
329 unbroadcastIntent(app, intent);
330 reply.writeNoException();
331 return true;
332 }
333
334 case FINISH_RECEIVER_TRANSACTION: {
335 data.enforceInterface(IActivityManager.descriptor);
336 IBinder who = data.readStrongBinder();
337 int resultCode = data.readInt();
338 String resultData = data.readString();
339 Bundle resultExtras = data.readBundle();
340 boolean resultAbort = data.readInt() != 0;
341 if (who != null) {
342 finishReceiver(who, resultCode, resultData, resultExtras, resultAbort);
343 }
344 reply.writeNoException();
345 return true;
346 }
347
348 case SET_PERSISTENT_TRANSACTION: {
349 data.enforceInterface(IActivityManager.descriptor);
350 IBinder token = data.readStrongBinder();
351 boolean isPersistent = data.readInt() != 0;
352 if (token != null) {
353 setPersistent(token, isPersistent);
354 }
355 reply.writeNoException();
356 return true;
357 }
358
359 case ATTACH_APPLICATION_TRANSACTION: {
360 data.enforceInterface(IActivityManager.descriptor);
361 IApplicationThread app = ApplicationThreadNative.asInterface(
362 data.readStrongBinder());
363 if (app != null) {
364 attachApplication(app);
365 }
366 reply.writeNoException();
367 return true;
368 }
369
370 case ACTIVITY_IDLE_TRANSACTION: {
371 data.enforceInterface(IActivityManager.descriptor);
372 IBinder token = data.readStrongBinder();
Dianne Hackborne88846e2009-09-30 21:34:25 -0700373 Configuration config = null;
374 if (data.readInt() != 0) {
375 config = Configuration.CREATOR.createFromParcel(data);
376 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377 if (token != null) {
Dianne Hackborne88846e2009-09-30 21:34:25 -0700378 activityIdle(token, config);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379 }
380 reply.writeNoException();
381 return true;
382 }
383
384 case ACTIVITY_PAUSED_TRANSACTION: {
385 data.enforceInterface(IActivityManager.descriptor);
386 IBinder token = data.readStrongBinder();
387 Bundle map = data.readBundle();
388 activityPaused(token, map);
389 reply.writeNoException();
390 return true;
391 }
392
393 case ACTIVITY_STOPPED_TRANSACTION: {
394 data.enforceInterface(IActivityManager.descriptor);
395 IBinder token = data.readStrongBinder();
396 Bitmap thumbnail = data.readInt() != 0
397 ? Bitmap.CREATOR.createFromParcel(data) : null;
398 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
399 activityStopped(token, thumbnail, description);
400 reply.writeNoException();
401 return true;
402 }
403
404 case ACTIVITY_DESTROYED_TRANSACTION: {
405 data.enforceInterface(IActivityManager.descriptor);
406 IBinder token = data.readStrongBinder();
407 activityDestroyed(token);
408 reply.writeNoException();
409 return true;
410 }
411
412 case GET_CALLING_PACKAGE_TRANSACTION: {
413 data.enforceInterface(IActivityManager.descriptor);
414 IBinder token = data.readStrongBinder();
415 String res = token != null ? getCallingPackage(token) : null;
416 reply.writeNoException();
417 reply.writeString(res);
418 return true;
419 }
420
421 case GET_CALLING_ACTIVITY_TRANSACTION: {
422 data.enforceInterface(IActivityManager.descriptor);
423 IBinder token = data.readStrongBinder();
424 ComponentName cn = getCallingActivity(token);
425 reply.writeNoException();
426 ComponentName.writeToParcel(cn, reply);
427 return true;
428 }
429
430 case GET_TASKS_TRANSACTION: {
431 data.enforceInterface(IActivityManager.descriptor);
432 int maxNum = data.readInt();
433 int fl = data.readInt();
434 IBinder receiverBinder = data.readStrongBinder();
435 IThumbnailReceiver receiver = receiverBinder != null
436 ? IThumbnailReceiver.Stub.asInterface(receiverBinder)
437 : null;
438 List list = getTasks(maxNum, fl, receiver);
439 reply.writeNoException();
440 int N = list != null ? list.size() : -1;
441 reply.writeInt(N);
442 int i;
443 for (i=0; i<N; i++) {
444 ActivityManager.RunningTaskInfo info =
445 (ActivityManager.RunningTaskInfo)list.get(i);
446 info.writeToParcel(reply, 0);
447 }
448 return true;
449 }
450
451 case GET_RECENT_TASKS_TRANSACTION: {
452 data.enforceInterface(IActivityManager.descriptor);
453 int maxNum = data.readInt();
454 int fl = data.readInt();
455 List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
456 fl);
457 reply.writeNoException();
458 reply.writeTypedList(list);
459 return true;
460 }
461
462 case GET_SERVICES_TRANSACTION: {
463 data.enforceInterface(IActivityManager.descriptor);
464 int maxNum = data.readInt();
465 int fl = data.readInt();
466 List list = getServices(maxNum, fl);
467 reply.writeNoException();
468 int N = list != null ? list.size() : -1;
469 reply.writeInt(N);
470 int i;
471 for (i=0; i<N; i++) {
472 ActivityManager.RunningServiceInfo info =
473 (ActivityManager.RunningServiceInfo)list.get(i);
474 info.writeToParcel(reply, 0);
475 }
476 return true;
477 }
478
479 case GET_PROCESSES_IN_ERROR_STATE_TRANSACTION: {
480 data.enforceInterface(IActivityManager.descriptor);
481 List<ActivityManager.ProcessErrorStateInfo> list = getProcessesInErrorState();
482 reply.writeNoException();
483 reply.writeTypedList(list);
484 return true;
485 }
486
487 case GET_RUNNING_APP_PROCESSES_TRANSACTION: {
488 data.enforceInterface(IActivityManager.descriptor);
489 List<ActivityManager.RunningAppProcessInfo> list = getRunningAppProcesses();
490 reply.writeNoException();
491 reply.writeTypedList(list);
492 return true;
493 }
494
Suchi Amalapurapuf7f5dda2010-03-23 10:34:28 -0700495 case GET_RUNNING_EXTERNAL_APPLICATIONS_TRANSACTION: {
496 data.enforceInterface(IActivityManager.descriptor);
497 List<ApplicationInfo> list = getRunningExternalApplications();
498 reply.writeNoException();
499 reply.writeTypedList(list);
500 return true;
501 }
502
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 case MOVE_TASK_TO_FRONT_TRANSACTION: {
504 data.enforceInterface(IActivityManager.descriptor);
505 int task = data.readInt();
506 moveTaskToFront(task);
507 reply.writeNoException();
508 return true;
509 }
510
511 case MOVE_TASK_TO_BACK_TRANSACTION: {
512 data.enforceInterface(IActivityManager.descriptor);
513 int task = data.readInt();
514 moveTaskToBack(task);
515 reply.writeNoException();
516 return true;
517 }
518
519 case MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION: {
520 data.enforceInterface(IActivityManager.descriptor);
521 IBinder token = data.readStrongBinder();
522 boolean nonRoot = data.readInt() != 0;
523 boolean res = moveActivityTaskToBack(token, nonRoot);
524 reply.writeNoException();
525 reply.writeInt(res ? 1 : 0);
526 return true;
527 }
528
529 case MOVE_TASK_BACKWARDS_TRANSACTION: {
530 data.enforceInterface(IActivityManager.descriptor);
531 int task = data.readInt();
532 moveTaskBackwards(task);
533 reply.writeNoException();
534 return true;
535 }
536
537 case GET_TASK_FOR_ACTIVITY_TRANSACTION: {
538 data.enforceInterface(IActivityManager.descriptor);
539 IBinder token = data.readStrongBinder();
540 boolean onlyRoot = data.readInt() != 0;
541 int res = token != null
542 ? getTaskForActivity(token, onlyRoot) : -1;
543 reply.writeNoException();
544 reply.writeInt(res);
545 return true;
546 }
547
548 case FINISH_OTHER_INSTANCES_TRANSACTION: {
549 data.enforceInterface(IActivityManager.descriptor);
550 IBinder token = data.readStrongBinder();
551 ComponentName className = ComponentName.readFromParcel(data);
552 finishOtherInstances(token, className);
553 reply.writeNoException();
554 return true;
555 }
556
557 case REPORT_THUMBNAIL_TRANSACTION: {
558 data.enforceInterface(IActivityManager.descriptor);
559 IBinder token = data.readStrongBinder();
560 Bitmap thumbnail = data.readInt() != 0
561 ? Bitmap.CREATOR.createFromParcel(data) : null;
562 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
563 reportThumbnail(token, thumbnail, description);
564 reply.writeNoException();
565 return true;
566 }
567
568 case GET_CONTENT_PROVIDER_TRANSACTION: {
569 data.enforceInterface(IActivityManager.descriptor);
570 IBinder b = data.readStrongBinder();
571 IApplicationThread app = ApplicationThreadNative.asInterface(b);
572 String name = data.readString();
573 ContentProviderHolder cph = getContentProvider(app, name);
574 reply.writeNoException();
575 if (cph != null) {
576 reply.writeInt(1);
577 cph.writeToParcel(reply, 0);
578 } else {
579 reply.writeInt(0);
580 }
581 return true;
582 }
583
584 case PUBLISH_CONTENT_PROVIDERS_TRANSACTION: {
585 data.enforceInterface(IActivityManager.descriptor);
586 IBinder b = data.readStrongBinder();
587 IApplicationThread app = ApplicationThreadNative.asInterface(b);
588 ArrayList<ContentProviderHolder> providers =
589 data.createTypedArrayList(ContentProviderHolder.CREATOR);
590 publishContentProviders(app, providers);
591 reply.writeNoException();
592 return true;
593 }
594
595 case REMOVE_CONTENT_PROVIDER_TRANSACTION: {
596 data.enforceInterface(IActivityManager.descriptor);
597 IBinder b = data.readStrongBinder();
598 IApplicationThread app = ApplicationThreadNative.asInterface(b);
599 String name = data.readString();
600 removeContentProvider(app, name);
601 reply.writeNoException();
602 return true;
603 }
604
Dianne Hackborndd9b82c2009-09-03 00:18:47 -0700605 case GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION: {
606 data.enforceInterface(IActivityManager.descriptor);
607 ComponentName comp = ComponentName.CREATOR.createFromParcel(data);
608 PendingIntent pi = getRunningServiceControlPanel(comp);
609 reply.writeNoException();
610 PendingIntent.writePendingIntentOrNullToParcel(pi, reply);
611 return true;
612 }
613
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800614 case START_SERVICE_TRANSACTION: {
615 data.enforceInterface(IActivityManager.descriptor);
616 IBinder b = data.readStrongBinder();
617 IApplicationThread app = ApplicationThreadNative.asInterface(b);
618 Intent service = Intent.CREATOR.createFromParcel(data);
619 String resolvedType = data.readString();
620 ComponentName cn = startService(app, service, resolvedType);
621 reply.writeNoException();
622 ComponentName.writeToParcel(cn, reply);
623 return true;
624 }
625
626 case STOP_SERVICE_TRANSACTION: {
627 data.enforceInterface(IActivityManager.descriptor);
628 IBinder b = data.readStrongBinder();
629 IApplicationThread app = ApplicationThreadNative.asInterface(b);
630 Intent service = Intent.CREATOR.createFromParcel(data);
631 String resolvedType = data.readString();
632 int res = stopService(app, service, resolvedType);
633 reply.writeNoException();
634 reply.writeInt(res);
635 return true;
636 }
637
638 case STOP_SERVICE_TOKEN_TRANSACTION: {
639 data.enforceInterface(IActivityManager.descriptor);
640 ComponentName className = ComponentName.readFromParcel(data);
641 IBinder token = data.readStrongBinder();
642 int startId = data.readInt();
643 boolean res = stopServiceToken(className, token, startId);
644 reply.writeNoException();
645 reply.writeInt(res ? 1 : 0);
646 return true;
647 }
648
649 case SET_SERVICE_FOREGROUND_TRANSACTION: {
650 data.enforceInterface(IActivityManager.descriptor);
651 ComponentName className = ComponentName.readFromParcel(data);
652 IBinder token = data.readStrongBinder();
Dianne Hackbornd8a43f62009-08-17 23:33:56 -0700653 int id = data.readInt();
654 Notification notification = null;
655 if (data.readInt() != 0) {
656 notification = Notification.CREATOR.createFromParcel(data);
657 }
658 boolean removeNotification = data.readInt() != 0;
659 setServiceForeground(className, token, id, notification, removeNotification);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800660 reply.writeNoException();
661 return true;
662 }
663
664 case BIND_SERVICE_TRANSACTION: {
665 data.enforceInterface(IActivityManager.descriptor);
666 IBinder b = data.readStrongBinder();
667 IApplicationThread app = ApplicationThreadNative.asInterface(b);
668 IBinder token = data.readStrongBinder();
669 Intent service = Intent.CREATOR.createFromParcel(data);
670 String resolvedType = data.readString();
671 b = data.readStrongBinder();
672 int fl = data.readInt();
673 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
674 int res = bindService(app, token, service, resolvedType, conn, fl);
675 reply.writeNoException();
676 reply.writeInt(res);
677 return true;
678 }
679
680 case UNBIND_SERVICE_TRANSACTION: {
681 data.enforceInterface(IActivityManager.descriptor);
682 IBinder b = data.readStrongBinder();
683 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
684 boolean res = unbindService(conn);
685 reply.writeNoException();
686 reply.writeInt(res ? 1 : 0);
687 return true;
688 }
689
690 case PUBLISH_SERVICE_TRANSACTION: {
691 data.enforceInterface(IActivityManager.descriptor);
692 IBinder token = data.readStrongBinder();
693 Intent intent = Intent.CREATOR.createFromParcel(data);
694 IBinder service = data.readStrongBinder();
695 publishService(token, intent, service);
696 reply.writeNoException();
697 return true;
698 }
699
700 case UNBIND_FINISHED_TRANSACTION: {
701 data.enforceInterface(IActivityManager.descriptor);
702 IBinder token = data.readStrongBinder();
703 Intent intent = Intent.CREATOR.createFromParcel(data);
704 boolean doRebind = data.readInt() != 0;
705 unbindFinished(token, intent, doRebind);
706 reply.writeNoException();
707 return true;
708 }
709
710 case SERVICE_DONE_EXECUTING_TRANSACTION: {
711 data.enforceInterface(IActivityManager.descriptor);
712 IBinder token = data.readStrongBinder();
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -0700713 int type = data.readInt();
714 int startId = data.readInt();
715 int res = data.readInt();
716 serviceDoneExecuting(token, type, startId, res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800717 reply.writeNoException();
718 return true;
719 }
720
721 case START_INSTRUMENTATION_TRANSACTION: {
722 data.enforceInterface(IActivityManager.descriptor);
723 ComponentName className = ComponentName.readFromParcel(data);
724 String profileFile = data.readString();
725 int fl = data.readInt();
726 Bundle arguments = data.readBundle();
727 IBinder b = data.readStrongBinder();
728 IInstrumentationWatcher w = IInstrumentationWatcher.Stub.asInterface(b);
729 boolean res = startInstrumentation(className, profileFile, fl, arguments, w);
730 reply.writeNoException();
731 reply.writeInt(res ? 1 : 0);
732 return true;
733 }
734
735
736 case FINISH_INSTRUMENTATION_TRANSACTION: {
737 data.enforceInterface(IActivityManager.descriptor);
738 IBinder b = data.readStrongBinder();
739 IApplicationThread app = ApplicationThreadNative.asInterface(b);
740 int resultCode = data.readInt();
741 Bundle results = data.readBundle();
742 finishInstrumentation(app, resultCode, results);
743 reply.writeNoException();
744 return true;
745 }
746
747 case GET_CONFIGURATION_TRANSACTION: {
748 data.enforceInterface(IActivityManager.descriptor);
749 Configuration config = getConfiguration();
750 reply.writeNoException();
751 config.writeToParcel(reply, 0);
752 return true;
753 }
754
755 case UPDATE_CONFIGURATION_TRANSACTION: {
756 data.enforceInterface(IActivityManager.descriptor);
757 Configuration config = Configuration.CREATOR.createFromParcel(data);
758 updateConfiguration(config);
759 reply.writeNoException();
760 return true;
761 }
762
763 case SET_REQUESTED_ORIENTATION_TRANSACTION: {
764 data.enforceInterface(IActivityManager.descriptor);
765 IBinder token = data.readStrongBinder();
766 int requestedOrientation = data.readInt();
767 setRequestedOrientation(token, requestedOrientation);
768 reply.writeNoException();
769 return true;
770 }
771
772 case GET_REQUESTED_ORIENTATION_TRANSACTION: {
773 data.enforceInterface(IActivityManager.descriptor);
774 IBinder token = data.readStrongBinder();
775 int req = getRequestedOrientation(token);
776 reply.writeNoException();
777 reply.writeInt(req);
778 return true;
779 }
780
781 case GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION: {
782 data.enforceInterface(IActivityManager.descriptor);
783 IBinder token = data.readStrongBinder();
784 ComponentName cn = getActivityClassForToken(token);
785 reply.writeNoException();
786 ComponentName.writeToParcel(cn, reply);
787 return true;
788 }
789
790 case GET_PACKAGE_FOR_TOKEN_TRANSACTION: {
791 data.enforceInterface(IActivityManager.descriptor);
792 IBinder token = data.readStrongBinder();
793 reply.writeNoException();
794 reply.writeString(getPackageForToken(token));
795 return true;
796 }
797
798 case GET_INTENT_SENDER_TRANSACTION: {
799 data.enforceInterface(IActivityManager.descriptor);
800 int type = data.readInt();
801 String packageName = data.readString();
802 IBinder token = data.readStrongBinder();
803 String resultWho = data.readString();
804 int requestCode = data.readInt();
805 Intent requestIntent = data.readInt() != 0
806 ? Intent.CREATOR.createFromParcel(data) : null;
807 String requestResolvedType = data.readString();
808 int fl = data.readInt();
809 IIntentSender res = getIntentSender(type, packageName, token,
810 resultWho, requestCode, requestIntent,
811 requestResolvedType, fl);
812 reply.writeNoException();
813 reply.writeStrongBinder(res != null ? res.asBinder() : null);
814 return true;
815 }
816
817 case CANCEL_INTENT_SENDER_TRANSACTION: {
818 data.enforceInterface(IActivityManager.descriptor);
819 IIntentSender r = IIntentSender.Stub.asInterface(
820 data.readStrongBinder());
821 cancelIntentSender(r);
822 reply.writeNoException();
823 return true;
824 }
825
826 case GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION: {
827 data.enforceInterface(IActivityManager.descriptor);
828 IIntentSender r = IIntentSender.Stub.asInterface(
829 data.readStrongBinder());
830 String res = getPackageForIntentSender(r);
831 reply.writeNoException();
832 reply.writeString(res);
833 return true;
834 }
835
836 case SET_PROCESS_LIMIT_TRANSACTION: {
837 data.enforceInterface(IActivityManager.descriptor);
838 int max = data.readInt();
839 setProcessLimit(max);
840 reply.writeNoException();
841 return true;
842 }
843
844 case GET_PROCESS_LIMIT_TRANSACTION: {
845 data.enforceInterface(IActivityManager.descriptor);
846 int limit = getProcessLimit();
847 reply.writeNoException();
848 reply.writeInt(limit);
849 return true;
850 }
851
852 case SET_PROCESS_FOREGROUND_TRANSACTION: {
853 data.enforceInterface(IActivityManager.descriptor);
854 IBinder token = data.readStrongBinder();
855 int pid = data.readInt();
856 boolean isForeground = data.readInt() != 0;
857 setProcessForeground(token, pid, isForeground);
858 reply.writeNoException();
859 return true;
860 }
861
862 case CHECK_PERMISSION_TRANSACTION: {
863 data.enforceInterface(IActivityManager.descriptor);
864 String perm = data.readString();
865 int pid = data.readInt();
866 int uid = data.readInt();
867 int res = checkPermission(perm, pid, uid);
868 reply.writeNoException();
869 reply.writeInt(res);
870 return true;
871 }
872
873 case CHECK_URI_PERMISSION_TRANSACTION: {
874 data.enforceInterface(IActivityManager.descriptor);
875 Uri uri = Uri.CREATOR.createFromParcel(data);
876 int pid = data.readInt();
877 int uid = data.readInt();
878 int mode = data.readInt();
879 int res = checkUriPermission(uri, pid, uid, mode);
880 reply.writeNoException();
881 reply.writeInt(res);
882 return true;
883 }
884
885 case CLEAR_APP_DATA_TRANSACTION: {
886 data.enforceInterface(IActivityManager.descriptor);
887 String packageName = data.readString();
888 IPackageDataObserver observer = IPackageDataObserver.Stub.asInterface(
889 data.readStrongBinder());
890 boolean res = clearApplicationUserData(packageName, observer);
891 reply.writeNoException();
892 reply.writeInt(res ? 1 : 0);
893 return true;
894 }
895
896 case GRANT_URI_PERMISSION_TRANSACTION: {
897 data.enforceInterface(IActivityManager.descriptor);
898 IBinder b = data.readStrongBinder();
899 IApplicationThread app = ApplicationThreadNative.asInterface(b);
900 String targetPkg = data.readString();
901 Uri uri = Uri.CREATOR.createFromParcel(data);
902 int mode = data.readInt();
903 grantUriPermission(app, targetPkg, uri, mode);
904 reply.writeNoException();
905 return true;
906 }
907
908 case REVOKE_URI_PERMISSION_TRANSACTION: {
909 data.enforceInterface(IActivityManager.descriptor);
910 IBinder b = data.readStrongBinder();
911 IApplicationThread app = ApplicationThreadNative.asInterface(b);
912 Uri uri = Uri.CREATOR.createFromParcel(data);
913 int mode = data.readInt();
914 revokeUriPermission(app, uri, mode);
915 reply.writeNoException();
916 return true;
917 }
918
919 case SHOW_WAITING_FOR_DEBUGGER_TRANSACTION: {
920 data.enforceInterface(IActivityManager.descriptor);
921 IBinder b = data.readStrongBinder();
922 IApplicationThread app = ApplicationThreadNative.asInterface(b);
923 boolean waiting = data.readInt() != 0;
924 showWaitingForDebugger(app, waiting);
925 reply.writeNoException();
926 return true;
927 }
928
929 case GET_MEMORY_INFO_TRANSACTION: {
930 data.enforceInterface(IActivityManager.descriptor);
931 ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
932 getMemoryInfo(mi);
933 reply.writeNoException();
934 mi.writeToParcel(reply, 0);
935 return true;
936 }
937
938 case UNHANDLED_BACK_TRANSACTION: {
939 data.enforceInterface(IActivityManager.descriptor);
940 unhandledBack();
941 reply.writeNoException();
942 return true;
943 }
944
945 case OPEN_CONTENT_URI_TRANSACTION: {
946 data.enforceInterface(IActivityManager.descriptor);
947 Uri uri = Uri.parse(data.readString());
948 ParcelFileDescriptor pfd = openContentUri(uri);
949 reply.writeNoException();
950 if (pfd != null) {
951 reply.writeInt(1);
952 pfd.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
953 } else {
954 reply.writeInt(0);
955 }
956 return true;
957 }
958
959 case GOING_TO_SLEEP_TRANSACTION: {
960 data.enforceInterface(IActivityManager.descriptor);
961 goingToSleep();
962 reply.writeNoException();
963 return true;
964 }
965
966 case WAKING_UP_TRANSACTION: {
967 data.enforceInterface(IActivityManager.descriptor);
968 wakingUp();
969 reply.writeNoException();
970 return true;
971 }
972
973 case SET_DEBUG_APP_TRANSACTION: {
974 data.enforceInterface(IActivityManager.descriptor);
975 String pn = data.readString();
976 boolean wfd = data.readInt() != 0;
977 boolean per = data.readInt() != 0;
978 setDebugApp(pn, wfd, per);
979 reply.writeNoException();
980 return true;
981 }
982
983 case SET_ALWAYS_FINISH_TRANSACTION: {
984 data.enforceInterface(IActivityManager.descriptor);
985 boolean enabled = data.readInt() != 0;
986 setAlwaysFinish(enabled);
987 reply.writeNoException();
988 return true;
989 }
990
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700991 case SET_ACTIVITY_CONTROLLER_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800992 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700993 IActivityController watcher = IActivityController.Stub.asInterface(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800994 data.readStrongBinder());
Dianne Hackbornb06ea702009-07-13 13:07:51 -0700995 setActivityController(watcher);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800996 return true;
997 }
998
999 case ENTER_SAFE_MODE_TRANSACTION: {
1000 data.enforceInterface(IActivityManager.descriptor);
1001 enterSafeMode();
1002 reply.writeNoException();
1003 return true;
1004 }
1005
1006 case NOTE_WAKEUP_ALARM_TRANSACTION: {
1007 data.enforceInterface(IActivityManager.descriptor);
1008 IIntentSender is = IIntentSender.Stub.asInterface(
1009 data.readStrongBinder());
1010 noteWakeupAlarm(is);
1011 reply.writeNoException();
1012 return true;
1013 }
1014
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07001015 case KILL_PIDS_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001016 data.enforceInterface(IActivityManager.descriptor);
1017 int[] pids = data.createIntArray();
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07001018 String reason = data.readString();
1019 boolean res = killPids(pids, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001020 reply.writeNoException();
1021 reply.writeInt(res ? 1 : 0);
1022 return true;
1023 }
1024
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001025 case START_RUNNING_TRANSACTION: {
1026 data.enforceInterface(IActivityManager.descriptor);
1027 String pkg = data.readString();
1028 String cls = data.readString();
1029 String action = data.readString();
1030 String indata = data.readString();
1031 startRunning(pkg, cls, action, indata);
1032 reply.writeNoException();
1033 return true;
1034 }
1035
Dan Egnor60d87622009-12-16 16:32:58 -08001036 case HANDLE_APPLICATION_CRASH_TRANSACTION: {
1037 data.enforceInterface(IActivityManager.descriptor);
1038 IBinder app = data.readStrongBinder();
1039 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
1040 handleApplicationCrash(app, ci);
1041 reply.writeNoException();
1042 return true;
1043 }
1044
1045 case HANDLE_APPLICATION_WTF_TRANSACTION: {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001046 data.enforceInterface(IActivityManager.descriptor);
1047 IBinder app = data.readStrongBinder();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001048 String tag = data.readString();
Dan Egnorb7f03672009-12-09 16:22:32 -08001049 ApplicationErrorReport.CrashInfo ci = new ApplicationErrorReport.CrashInfo(data);
Dan Egnor60d87622009-12-16 16:32:58 -08001050 boolean res = handleApplicationWtf(app, tag, ci);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001051 reply.writeNoException();
Dan Egnor60d87622009-12-16 16:32:58 -08001052 reply.writeInt(res ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001053 return true;
1054 }
Dan Egnorb7f03672009-12-09 16:22:32 -08001055
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07001056 case HANDLE_APPLICATION_STRICT_MODE_VIOLATION_TRANSACTION: {
1057 data.enforceInterface(IActivityManager.descriptor);
1058 IBinder app = data.readStrongBinder();
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07001059 int violationMask = data.readInt();
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07001060 StrictMode.ViolationInfo info = new StrictMode.ViolationInfo(data);
1061 handleApplicationStrictModeViolation(app, violationMask, info);
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07001062 reply.writeNoException();
1063 return true;
1064 }
1065
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001066 case SIGNAL_PERSISTENT_PROCESSES_TRANSACTION: {
1067 data.enforceInterface(IActivityManager.descriptor);
1068 int sig = data.readInt();
1069 signalPersistentProcesses(sig);
1070 reply.writeNoException();
1071 return true;
1072 }
1073
Dianne Hackborn03abb812010-01-04 18:43:19 -08001074 case KILL_BACKGROUND_PROCESSES_TRANSACTION: {
1075 data.enforceInterface(IActivityManager.descriptor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001076 String packageName = data.readString();
Dianne Hackborn03abb812010-01-04 18:43:19 -08001077 killBackgroundProcesses(packageName);
1078 reply.writeNoException();
1079 return true;
1080 }
1081
1082 case FORCE_STOP_PACKAGE_TRANSACTION: {
1083 data.enforceInterface(IActivityManager.descriptor);
1084 String packageName = data.readString();
1085 forceStopPackage(packageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001086 reply.writeNoException();
1087 return true;
1088 }
1089
1090 case GET_DEVICE_CONFIGURATION_TRANSACTION: {
1091 data.enforceInterface(IActivityManager.descriptor);
1092 ConfigurationInfo config = getDeviceConfigurationInfo();
1093 reply.writeNoException();
1094 config.writeToParcel(reply, 0);
1095 return true;
1096 }
1097
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001098 case PROFILE_CONTROL_TRANSACTION: {
1099 data.enforceInterface(IActivityManager.descriptor);
1100 String process = data.readString();
1101 boolean start = data.readInt() != 0;
1102 String path = data.readString();
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07001103 ParcelFileDescriptor fd = data.readInt() != 0
1104 ? data.readFileDescriptor() : null;
1105 boolean res = profileControl(process, start, path, fd);
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08001106 reply.writeNoException();
1107 reply.writeInt(res ? 1 : 0);
1108 return true;
1109 }
1110
Dianne Hackborn55280a92009-05-07 15:53:46 -07001111 case SHUTDOWN_TRANSACTION: {
1112 data.enforceInterface(IActivityManager.descriptor);
1113 boolean res = shutdown(data.readInt());
1114 reply.writeNoException();
1115 reply.writeInt(res ? 1 : 0);
1116 return true;
1117 }
1118
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07001119 case STOP_APP_SWITCHES_TRANSACTION: {
1120 data.enforceInterface(IActivityManager.descriptor);
1121 stopAppSwitches();
1122 reply.writeNoException();
1123 return true;
1124 }
1125
1126 case RESUME_APP_SWITCHES_TRANSACTION: {
1127 data.enforceInterface(IActivityManager.descriptor);
1128 resumeAppSwitches();
1129 reply.writeNoException();
1130 return true;
1131 }
1132
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001133 case PEEK_SERVICE_TRANSACTION: {
1134 data.enforceInterface(IActivityManager.descriptor);
1135 Intent service = Intent.CREATOR.createFromParcel(data);
1136 String resolvedType = data.readString();
1137 IBinder binder = peekService(service, resolvedType);
1138 reply.writeNoException();
1139 reply.writeStrongBinder(binder);
1140 return true;
1141 }
Christopher Tate181fafa2009-05-14 11:12:14 -07001142
1143 case START_BACKUP_AGENT_TRANSACTION: {
1144 data.enforceInterface(IActivityManager.descriptor);
1145 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1146 int backupRestoreMode = data.readInt();
1147 boolean success = bindBackupAgent(info, backupRestoreMode);
1148 reply.writeNoException();
1149 reply.writeInt(success ? 1 : 0);
1150 return true;
1151 }
1152
1153 case BACKUP_AGENT_CREATED_TRANSACTION: {
1154 data.enforceInterface(IActivityManager.descriptor);
1155 String packageName = data.readString();
1156 IBinder agent = data.readStrongBinder();
1157 backupAgentCreated(packageName, agent);
1158 reply.writeNoException();
1159 return true;
1160 }
1161
1162 case UNBIND_BACKUP_AGENT_TRANSACTION: {
1163 data.enforceInterface(IActivityManager.descriptor);
1164 ApplicationInfo info = ApplicationInfo.CREATOR.createFromParcel(data);
1165 unbindBackupAgent(info);
1166 reply.writeNoException();
1167 return true;
1168 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07001169
1170 case REGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1171 data.enforceInterface(IActivityManager.descriptor);
1172 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1173 data.readStrongBinder());
1174 registerActivityWatcher(watcher);
1175 return true;
1176 }
1177
1178 case UNREGISTER_ACTIVITY_WATCHER_TRANSACTION: {
1179 data.enforceInterface(IActivityManager.descriptor);
1180 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
1181 data.readStrongBinder());
1182 unregisterActivityWatcher(watcher);
1183 return true;
1184 }
Dianne Hackborn2d91af02009-07-16 13:34:33 -07001185
1186 case START_ACTIVITY_IN_PACKAGE_TRANSACTION:
1187 {
1188 data.enforceInterface(IActivityManager.descriptor);
1189 int uid = data.readInt();
1190 Intent intent = Intent.CREATOR.createFromParcel(data);
1191 String resolvedType = data.readString();
1192 IBinder resultTo = data.readStrongBinder();
1193 String resultWho = data.readString();
1194 int requestCode = data.readInt();
1195 boolean onlyIfNeeded = data.readInt() != 0;
1196 int result = startActivityInPackage(uid, intent, resolvedType,
1197 resultTo, resultWho, requestCode, onlyIfNeeded);
1198 reply.writeNoException();
1199 reply.writeInt(result);
1200 return true;
1201 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001202
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07001203 case KILL_APPLICATION_WITH_UID_TRANSACTION: {
1204 data.enforceInterface(IActivityManager.descriptor);
1205 String pkg = data.readString();
1206 int uid = data.readInt();
1207 killApplicationWithUid(pkg, uid);
1208 reply.writeNoException();
1209 return true;
1210 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07001211
1212 case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
1213 data.enforceInterface(IActivityManager.descriptor);
1214 String reason = data.readString();
1215 closeSystemDialogs(reason);
1216 reply.writeNoException();
1217 return true;
1218 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001219
1220 case GET_PROCESS_MEMORY_INFO_TRANSACTION: {
1221 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001222 int[] pids = data.createIntArray();
1223 Debug.MemoryInfo[] res = getProcessMemoryInfo(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001224 reply.writeNoException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07001225 reply.writeTypedArray(res, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07001226 return true;
1227 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07001228
1229 case KILL_APPLICATION_PROCESS_TRANSACTION: {
1230 data.enforceInterface(IActivityManager.descriptor);
1231 String processName = data.readString();
1232 int uid = data.readInt();
1233 killApplicationProcess(processName, uid);
1234 reply.writeNoException();
1235 return true;
1236 }
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001237
1238 case OVERRIDE_PENDING_TRANSITION_TRANSACTION: {
1239 data.enforceInterface(IActivityManager.descriptor);
1240 IBinder token = data.readStrongBinder();
1241 String packageName = data.readString();
1242 int enterAnim = data.readInt();
1243 int exitAnim = data.readInt();
1244 overridePendingTransition(token, packageName, enterAnim, exitAnim);
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08001245 reply.writeNoException();
1246 return true;
1247 }
1248
1249 case IS_USER_A_MONKEY_TRANSACTION: {
1250 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn7e269642010-08-25 19:50:20 -07001251 boolean areThey = isUserAMonkey();
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08001252 reply.writeNoException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001253 reply.writeInt(areThey ? 1 : 0);
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001254 return true;
1255 }
Dianne Hackborn860755f2010-06-03 18:47:52 -07001256
1257 case FINISH_HEAVY_WEIGHT_APP_TRANSACTION: {
1258 data.enforceInterface(IActivityManager.descriptor);
1259 finishHeavyWeightApp();
1260 reply.writeNoException();
1261 return true;
1262 }
Daniel Sandler69a48172010-06-23 16:29:36 -04001263
1264 case IS_IMMERSIVE_TRANSACTION: {
1265 data.enforceInterface(IActivityManager.descriptor);
1266 IBinder token = data.readStrongBinder();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001267 boolean isit = isImmersive(token);
Daniel Sandler69a48172010-06-23 16:29:36 -04001268 reply.writeNoException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001269 reply.writeInt(isit ? 1 : 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04001270 return true;
1271 }
1272
1273 case SET_IMMERSIVE_TRANSACTION: {
1274 data.enforceInterface(IActivityManager.descriptor);
1275 IBinder token = data.readStrongBinder();
1276 boolean imm = data.readInt() == 1;
1277 setImmersive(token, imm);
1278 reply.writeNoException();
1279 return true;
1280 }
1281
1282 case IS_TOP_ACTIVITY_IMMERSIVE_TRANSACTION: {
1283 data.enforceInterface(IActivityManager.descriptor);
Dianne Hackborn7e269642010-08-25 19:50:20 -07001284 boolean isit = isTopActivityImmersive();
Daniel Sandler69a48172010-06-23 16:29:36 -04001285 reply.writeNoException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07001286 reply.writeInt(isit ? 1 : 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04001287 return true;
1288 }
1289
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07001290 case CRASH_APPLICATION_TRANSACTION: {
1291 data.enforceInterface(IActivityManager.descriptor);
1292 int uid = data.readInt();
1293 int initialPid = data.readInt();
1294 String packageName = data.readString();
1295 String message = data.readString();
1296 crashApplication(uid, initialPid, packageName, message);
1297 reply.writeNoException();
1298 return true;
1299 }
Dianne Hackborncca1f0e2010-09-26 18:34:53 -07001300
1301 case GET_PROVIDER_MIME_TYPE_TRANSACTION: {
1302 data.enforceInterface(IActivityManager.descriptor);
1303 Uri uri = Uri.CREATOR.createFromParcel(data);
1304 String type = getProviderMimeType(uri);
1305 reply.writeNoException();
1306 reply.writeString(type);
1307 return true;
1308 }
1309
Dianne Hackborn7e269642010-08-25 19:50:20 -07001310 case NEW_URI_PERMISSION_OWNER_TRANSACTION: {
1311 data.enforceInterface(IActivityManager.descriptor);
1312 String name = data.readString();
1313 IBinder perm = newUriPermissionOwner(name);
1314 reply.writeNoException();
1315 reply.writeStrongBinder(perm);
1316 return true;
1317 }
1318
1319 case GRANT_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1320 data.enforceInterface(IActivityManager.descriptor);
1321 IBinder owner = data.readStrongBinder();
1322 int fromUid = data.readInt();
1323 String targetPkg = data.readString();
1324 Uri uri = Uri.CREATOR.createFromParcel(data);
1325 int mode = data.readInt();
1326 grantUriPermissionFromOwner(owner, fromUid, targetPkg, uri, mode);
1327 reply.writeNoException();
1328 return true;
1329 }
1330
1331 case REVOKE_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1332 data.enforceInterface(IActivityManager.descriptor);
1333 IBinder owner = data.readStrongBinder();
1334 Uri uri = null;
1335 if (data.readInt() != 0) {
1336 Uri.CREATOR.createFromParcel(data);
1337 }
1338 int mode = data.readInt();
1339 revokeUriPermissionFromOwner(owner, uri, mode);
1340 reply.writeNoException();
1341 return true;
1342 }
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07001343
Andy McFadden824c5102010-07-09 16:26:57 -07001344 case DUMP_HEAP_TRANSACTION: {
1345 data.enforceInterface(IActivityManager.descriptor);
1346 String process = data.readString();
1347 boolean managed = data.readInt() != 0;
1348 String path = data.readString();
1349 ParcelFileDescriptor fd = data.readInt() != 0
1350 ? data.readFileDescriptor() : null;
1351 boolean res = dumpHeap(process, managed, path, fd);
1352 reply.writeNoException();
1353 reply.writeInt(res ? 1 : 0);
1354 return true;
1355 }
1356
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001357 }
1358
1359 return super.onTransact(code, data, reply, flags);
1360 }
1361
1362 public IBinder asBinder()
1363 {
1364 return this;
1365 }
1366
1367 private static IActivityManager gDefault;
1368}
1369
1370class ActivityManagerProxy implements IActivityManager
1371{
1372 public ActivityManagerProxy(IBinder remote)
1373 {
1374 mRemote = remote;
1375 }
1376
1377 public IBinder asBinder()
1378 {
1379 return mRemote;
1380 }
1381
1382 public int startActivity(IApplicationThread caller, Intent intent,
1383 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1384 IBinder resultTo, String resultWho,
1385 int requestCode, boolean onlyIfNeeded,
1386 boolean debug) throws RemoteException {
1387 Parcel data = Parcel.obtain();
1388 Parcel reply = Parcel.obtain();
1389 data.writeInterfaceToken(IActivityManager.descriptor);
1390 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1391 intent.writeToParcel(data, 0);
1392 data.writeString(resolvedType);
1393 data.writeTypedArray(grantedUriPermissions, 0);
1394 data.writeInt(grantedMode);
1395 data.writeStrongBinder(resultTo);
1396 data.writeString(resultWho);
1397 data.writeInt(requestCode);
1398 data.writeInt(onlyIfNeeded ? 1 : 0);
1399 data.writeInt(debug ? 1 : 0);
1400 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1401 reply.readException();
1402 int result = reply.readInt();
1403 reply.recycle();
1404 data.recycle();
1405 return result;
1406 }
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -08001407 public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
1408 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1409 IBinder resultTo, String resultWho,
1410 int requestCode, boolean onlyIfNeeded,
1411 boolean debug) throws RemoteException {
1412 Parcel data = Parcel.obtain();
1413 Parcel reply = Parcel.obtain();
1414 data.writeInterfaceToken(IActivityManager.descriptor);
1415 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1416 intent.writeToParcel(data, 0);
1417 data.writeString(resolvedType);
1418 data.writeTypedArray(grantedUriPermissions, 0);
1419 data.writeInt(grantedMode);
1420 data.writeStrongBinder(resultTo);
1421 data.writeString(resultWho);
1422 data.writeInt(requestCode);
1423 data.writeInt(onlyIfNeeded ? 1 : 0);
1424 data.writeInt(debug ? 1 : 0);
1425 mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
1426 reply.readException();
1427 WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
1428 reply.recycle();
1429 data.recycle();
1430 return result;
1431 }
Dianne Hackborn2ccda4d2010-03-22 21:49:15 -07001432 public int startActivityWithConfig(IApplicationThread caller, Intent intent,
1433 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1434 IBinder resultTo, String resultWho,
1435 int requestCode, boolean onlyIfNeeded,
1436 boolean debug, Configuration config) throws RemoteException {
1437 Parcel data = Parcel.obtain();
1438 Parcel reply = Parcel.obtain();
1439 data.writeInterfaceToken(IActivityManager.descriptor);
1440 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1441 intent.writeToParcel(data, 0);
1442 data.writeString(resolvedType);
1443 data.writeTypedArray(grantedUriPermissions, 0);
1444 data.writeInt(grantedMode);
1445 data.writeStrongBinder(resultTo);
1446 data.writeString(resultWho);
1447 data.writeInt(requestCode);
1448 data.writeInt(onlyIfNeeded ? 1 : 0);
1449 data.writeInt(debug ? 1 : 0);
1450 config.writeToParcel(data, 0);
1451 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1452 reply.readException();
1453 int result = reply.readInt();
1454 reply.recycle();
1455 data.recycle();
1456 return result;
1457 }
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001458 public int startActivityIntentSender(IApplicationThread caller,
1459 IntentSender intent, Intent fillInIntent, String resolvedType,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001460 IBinder resultTo, String resultWho, int requestCode,
1461 int flagsMask, int flagsValues) throws RemoteException {
1462 Parcel data = Parcel.obtain();
1463 Parcel reply = Parcel.obtain();
1464 data.writeInterfaceToken(IActivityManager.descriptor);
1465 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1466 intent.writeToParcel(data, 0);
1467 if (fillInIntent != null) {
1468 data.writeInt(1);
1469 fillInIntent.writeToParcel(data, 0);
1470 } else {
1471 data.writeInt(0);
1472 }
1473 data.writeString(resolvedType);
1474 data.writeStrongBinder(resultTo);
1475 data.writeString(resultWho);
1476 data.writeInt(requestCode);
1477 data.writeInt(flagsMask);
1478 data.writeInt(flagsValues);
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001479 mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001480 reply.readException();
1481 int result = reply.readInt();
1482 reply.recycle();
1483 data.recycle();
1484 return result;
1485 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001486 public boolean startNextMatchingActivity(IBinder callingActivity,
1487 Intent intent) throws RemoteException {
1488 Parcel data = Parcel.obtain();
1489 Parcel reply = Parcel.obtain();
1490 data.writeInterfaceToken(IActivityManager.descriptor);
1491 data.writeStrongBinder(callingActivity);
1492 intent.writeToParcel(data, 0);
1493 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1494 reply.readException();
1495 int result = reply.readInt();
1496 reply.recycle();
1497 data.recycle();
1498 return result != 0;
1499 }
1500 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1501 throws RemoteException {
1502 Parcel data = Parcel.obtain();
1503 Parcel reply = Parcel.obtain();
1504 data.writeInterfaceToken(IActivityManager.descriptor);
1505 data.writeStrongBinder(token);
1506 data.writeInt(resultCode);
1507 if (resultData != null) {
1508 data.writeInt(1);
1509 resultData.writeToParcel(data, 0);
1510 } else {
1511 data.writeInt(0);
1512 }
1513 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1514 reply.readException();
1515 boolean res = reply.readInt() != 0;
1516 data.recycle();
1517 reply.recycle();
1518 return res;
1519 }
1520 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1521 {
1522 Parcel data = Parcel.obtain();
1523 Parcel reply = Parcel.obtain();
1524 data.writeInterfaceToken(IActivityManager.descriptor);
1525 data.writeStrongBinder(token);
1526 data.writeString(resultWho);
1527 data.writeInt(requestCode);
1528 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1529 reply.readException();
1530 data.recycle();
1531 reply.recycle();
1532 }
Dianne Hackborn061d58a2010-03-12 15:07:06 -08001533 public boolean willActivityBeVisible(IBinder token) throws RemoteException {
1534 Parcel data = Parcel.obtain();
1535 Parcel reply = Parcel.obtain();
1536 data.writeInterfaceToken(IActivityManager.descriptor);
1537 data.writeStrongBinder(token);
1538 mRemote.transact(WILL_ACTIVITY_BE_VISIBLE_TRANSACTION, data, reply, 0);
1539 reply.readException();
1540 boolean res = reply.readInt() != 0;
1541 data.recycle();
1542 reply.recycle();
1543 return res;
1544 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001545 public Intent registerReceiver(IApplicationThread caller,
1546 IIntentReceiver receiver,
1547 IntentFilter filter, String perm) throws RemoteException
1548 {
1549 Parcel data = Parcel.obtain();
1550 Parcel reply = Parcel.obtain();
1551 data.writeInterfaceToken(IActivityManager.descriptor);
1552 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1553 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1554 filter.writeToParcel(data, 0);
1555 data.writeString(perm);
1556 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1557 reply.readException();
1558 Intent intent = null;
1559 int haveIntent = reply.readInt();
1560 if (haveIntent != 0) {
1561 intent = Intent.CREATOR.createFromParcel(reply);
1562 }
1563 reply.recycle();
1564 data.recycle();
1565 return intent;
1566 }
1567 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1568 {
1569 Parcel data = Parcel.obtain();
1570 Parcel reply = Parcel.obtain();
1571 data.writeInterfaceToken(IActivityManager.descriptor);
1572 data.writeStrongBinder(receiver.asBinder());
1573 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1574 reply.readException();
1575 data.recycle();
1576 reply.recycle();
1577 }
1578 public int broadcastIntent(IApplicationThread caller,
1579 Intent intent, String resolvedType, IIntentReceiver resultTo,
1580 int resultCode, String resultData, Bundle map,
1581 String requiredPermission, boolean serialized,
1582 boolean sticky) throws RemoteException
1583 {
1584 Parcel data = Parcel.obtain();
1585 Parcel reply = Parcel.obtain();
1586 data.writeInterfaceToken(IActivityManager.descriptor);
1587 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1588 intent.writeToParcel(data, 0);
1589 data.writeString(resolvedType);
1590 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1591 data.writeInt(resultCode);
1592 data.writeString(resultData);
1593 data.writeBundle(map);
1594 data.writeString(requiredPermission);
1595 data.writeInt(serialized ? 1 : 0);
1596 data.writeInt(sticky ? 1 : 0);
1597 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1598 reply.readException();
1599 int res = reply.readInt();
1600 reply.recycle();
1601 data.recycle();
1602 return res;
1603 }
1604 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1605 {
1606 Parcel data = Parcel.obtain();
1607 Parcel reply = Parcel.obtain();
1608 data.writeInterfaceToken(IActivityManager.descriptor);
1609 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1610 intent.writeToParcel(data, 0);
1611 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1612 reply.readException();
1613 data.recycle();
1614 reply.recycle();
1615 }
1616 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1617 {
1618 Parcel data = Parcel.obtain();
1619 Parcel reply = Parcel.obtain();
1620 data.writeInterfaceToken(IActivityManager.descriptor);
1621 data.writeStrongBinder(who);
1622 data.writeInt(resultCode);
1623 data.writeString(resultData);
1624 data.writeBundle(map);
1625 data.writeInt(abortBroadcast ? 1 : 0);
1626 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1627 reply.readException();
1628 data.recycle();
1629 reply.recycle();
1630 }
1631 public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
1632 {
1633 Parcel data = Parcel.obtain();
1634 Parcel reply = Parcel.obtain();
1635 data.writeInterfaceToken(IActivityManager.descriptor);
1636 data.writeStrongBinder(token);
1637 data.writeInt(isPersistent ? 1 : 0);
1638 mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
1639 reply.readException();
1640 data.recycle();
1641 reply.recycle();
1642 }
1643 public void attachApplication(IApplicationThread app) throws RemoteException
1644 {
1645 Parcel data = Parcel.obtain();
1646 Parcel reply = Parcel.obtain();
1647 data.writeInterfaceToken(IActivityManager.descriptor);
1648 data.writeStrongBinder(app.asBinder());
1649 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1650 reply.readException();
1651 data.recycle();
1652 reply.recycle();
1653 }
Dianne Hackborne88846e2009-09-30 21:34:25 -07001654 public void activityIdle(IBinder token, Configuration config) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001655 {
1656 Parcel data = Parcel.obtain();
1657 Parcel reply = Parcel.obtain();
1658 data.writeInterfaceToken(IActivityManager.descriptor);
1659 data.writeStrongBinder(token);
Dianne Hackborne88846e2009-09-30 21:34:25 -07001660 if (config != null) {
1661 data.writeInt(1);
1662 config.writeToParcel(data, 0);
1663 } else {
1664 data.writeInt(0);
1665 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001666 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1667 reply.readException();
1668 data.recycle();
1669 reply.recycle();
1670 }
1671 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1672 {
1673 Parcel data = Parcel.obtain();
1674 Parcel reply = Parcel.obtain();
1675 data.writeInterfaceToken(IActivityManager.descriptor);
1676 data.writeStrongBinder(token);
1677 data.writeBundle(state);
1678 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1679 reply.readException();
1680 data.recycle();
1681 reply.recycle();
1682 }
1683 public void activityStopped(IBinder token,
1684 Bitmap thumbnail, CharSequence description) throws RemoteException
1685 {
1686 Parcel data = Parcel.obtain();
1687 Parcel reply = Parcel.obtain();
1688 data.writeInterfaceToken(IActivityManager.descriptor);
1689 data.writeStrongBinder(token);
1690 if (thumbnail != null) {
1691 data.writeInt(1);
1692 thumbnail.writeToParcel(data, 0);
1693 } else {
1694 data.writeInt(0);
1695 }
1696 TextUtils.writeToParcel(description, data, 0);
1697 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1698 reply.readException();
1699 data.recycle();
1700 reply.recycle();
1701 }
1702 public void activityDestroyed(IBinder token) throws RemoteException
1703 {
1704 Parcel data = Parcel.obtain();
1705 Parcel reply = Parcel.obtain();
1706 data.writeInterfaceToken(IActivityManager.descriptor);
1707 data.writeStrongBinder(token);
1708 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1709 reply.readException();
1710 data.recycle();
1711 reply.recycle();
1712 }
1713 public String getCallingPackage(IBinder token) throws RemoteException
1714 {
1715 Parcel data = Parcel.obtain();
1716 Parcel reply = Parcel.obtain();
1717 data.writeInterfaceToken(IActivityManager.descriptor);
1718 data.writeStrongBinder(token);
1719 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1720 reply.readException();
1721 String res = reply.readString();
1722 data.recycle();
1723 reply.recycle();
1724 return res;
1725 }
1726 public ComponentName getCallingActivity(IBinder token)
1727 throws RemoteException {
1728 Parcel data = Parcel.obtain();
1729 Parcel reply = Parcel.obtain();
1730 data.writeInterfaceToken(IActivityManager.descriptor);
1731 data.writeStrongBinder(token);
1732 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1733 reply.readException();
1734 ComponentName res = ComponentName.readFromParcel(reply);
1735 data.recycle();
1736 reply.recycle();
1737 return res;
1738 }
1739 public List getTasks(int maxNum, int flags,
1740 IThumbnailReceiver receiver) throws RemoteException {
1741 Parcel data = Parcel.obtain();
1742 Parcel reply = Parcel.obtain();
1743 data.writeInterfaceToken(IActivityManager.descriptor);
1744 data.writeInt(maxNum);
1745 data.writeInt(flags);
1746 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1747 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1748 reply.readException();
1749 ArrayList list = null;
1750 int N = reply.readInt();
1751 if (N >= 0) {
1752 list = new ArrayList();
1753 while (N > 0) {
1754 ActivityManager.RunningTaskInfo info =
1755 ActivityManager.RunningTaskInfo.CREATOR
1756 .createFromParcel(reply);
1757 list.add(info);
1758 N--;
1759 }
1760 }
1761 data.recycle();
1762 reply.recycle();
1763 return list;
1764 }
1765 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1766 int flags) throws RemoteException {
1767 Parcel data = Parcel.obtain();
1768 Parcel reply = Parcel.obtain();
1769 data.writeInterfaceToken(IActivityManager.descriptor);
1770 data.writeInt(maxNum);
1771 data.writeInt(flags);
1772 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1773 reply.readException();
1774 ArrayList<ActivityManager.RecentTaskInfo> list
1775 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1776 data.recycle();
1777 reply.recycle();
1778 return list;
1779 }
1780 public List getServices(int maxNum, int flags) throws RemoteException {
1781 Parcel data = Parcel.obtain();
1782 Parcel reply = Parcel.obtain();
1783 data.writeInterfaceToken(IActivityManager.descriptor);
1784 data.writeInt(maxNum);
1785 data.writeInt(flags);
1786 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1787 reply.readException();
1788 ArrayList list = null;
1789 int N = reply.readInt();
1790 if (N >= 0) {
1791 list = new ArrayList();
1792 while (N > 0) {
1793 ActivityManager.RunningServiceInfo info =
1794 ActivityManager.RunningServiceInfo.CREATOR
1795 .createFromParcel(reply);
1796 list.add(info);
1797 N--;
1798 }
1799 }
1800 data.recycle();
1801 reply.recycle();
1802 return list;
1803 }
1804 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1805 throws RemoteException {
1806 Parcel data = Parcel.obtain();
1807 Parcel reply = Parcel.obtain();
1808 data.writeInterfaceToken(IActivityManager.descriptor);
1809 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1810 reply.readException();
1811 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1812 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1813 data.recycle();
1814 reply.recycle();
1815 return list;
1816 }
1817 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1818 throws RemoteException {
1819 Parcel data = Parcel.obtain();
1820 Parcel reply = Parcel.obtain();
1821 data.writeInterfaceToken(IActivityManager.descriptor);
1822 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1823 reply.readException();
1824 ArrayList<ActivityManager.RunningAppProcessInfo> list
1825 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1826 data.recycle();
1827 reply.recycle();
1828 return list;
1829 }
Suchi Amalapurapuf7f5dda2010-03-23 10:34:28 -07001830 public List<ApplicationInfo> getRunningExternalApplications()
1831 throws RemoteException {
1832 Parcel data = Parcel.obtain();
1833 Parcel reply = Parcel.obtain();
1834 data.writeInterfaceToken(IActivityManager.descriptor);
1835 mRemote.transact(GET_RUNNING_EXTERNAL_APPLICATIONS_TRANSACTION, data, reply, 0);
1836 reply.readException();
1837 ArrayList<ApplicationInfo> list
1838 = reply.createTypedArrayList(ApplicationInfo.CREATOR);
1839 data.recycle();
1840 reply.recycle();
1841 return list;
1842 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001843 public void moveTaskToFront(int task) throws RemoteException
1844 {
1845 Parcel data = Parcel.obtain();
1846 Parcel reply = Parcel.obtain();
1847 data.writeInterfaceToken(IActivityManager.descriptor);
1848 data.writeInt(task);
1849 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1850 reply.readException();
1851 data.recycle();
1852 reply.recycle();
1853 }
1854 public void moveTaskToBack(int task) throws RemoteException
1855 {
1856 Parcel data = Parcel.obtain();
1857 Parcel reply = Parcel.obtain();
1858 data.writeInterfaceToken(IActivityManager.descriptor);
1859 data.writeInt(task);
1860 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1861 reply.readException();
1862 data.recycle();
1863 reply.recycle();
1864 }
1865 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1866 throws RemoteException {
1867 Parcel data = Parcel.obtain();
1868 Parcel reply = Parcel.obtain();
1869 data.writeInterfaceToken(IActivityManager.descriptor);
1870 data.writeStrongBinder(token);
1871 data.writeInt(nonRoot ? 1 : 0);
1872 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1873 reply.readException();
1874 boolean res = reply.readInt() != 0;
1875 data.recycle();
1876 reply.recycle();
1877 return res;
1878 }
1879 public void moveTaskBackwards(int task) throws RemoteException
1880 {
1881 Parcel data = Parcel.obtain();
1882 Parcel reply = Parcel.obtain();
1883 data.writeInterfaceToken(IActivityManager.descriptor);
1884 data.writeInt(task);
1885 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1886 reply.readException();
1887 data.recycle();
1888 reply.recycle();
1889 }
1890 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1891 {
1892 Parcel data = Parcel.obtain();
1893 Parcel reply = Parcel.obtain();
1894 data.writeInterfaceToken(IActivityManager.descriptor);
1895 data.writeStrongBinder(token);
1896 data.writeInt(onlyRoot ? 1 : 0);
1897 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1898 reply.readException();
1899 int res = reply.readInt();
1900 data.recycle();
1901 reply.recycle();
1902 return res;
1903 }
1904 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1905 {
1906 Parcel data = Parcel.obtain();
1907 Parcel reply = Parcel.obtain();
1908 data.writeInterfaceToken(IActivityManager.descriptor);
1909 data.writeStrongBinder(token);
1910 ComponentName.writeToParcel(className, data);
1911 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1912 reply.readException();
1913 data.recycle();
1914 reply.recycle();
1915 }
1916 public void reportThumbnail(IBinder token,
1917 Bitmap thumbnail, CharSequence description) throws RemoteException
1918 {
1919 Parcel data = Parcel.obtain();
1920 Parcel reply = Parcel.obtain();
1921 data.writeInterfaceToken(IActivityManager.descriptor);
1922 data.writeStrongBinder(token);
1923 if (thumbnail != null) {
1924 data.writeInt(1);
1925 thumbnail.writeToParcel(data, 0);
1926 } else {
1927 data.writeInt(0);
1928 }
1929 TextUtils.writeToParcel(description, data, 0);
1930 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1931 reply.readException();
1932 data.recycle();
1933 reply.recycle();
1934 }
1935 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1936 String name) throws RemoteException
1937 {
1938 Parcel data = Parcel.obtain();
1939 Parcel reply = Parcel.obtain();
1940 data.writeInterfaceToken(IActivityManager.descriptor);
1941 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1942 data.writeString(name);
1943 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1944 reply.readException();
1945 int res = reply.readInt();
1946 ContentProviderHolder cph = null;
1947 if (res != 0) {
1948 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1949 }
1950 data.recycle();
1951 reply.recycle();
1952 return cph;
1953 }
1954 public void publishContentProviders(IApplicationThread caller,
1955 List<ContentProviderHolder> providers) throws RemoteException
1956 {
1957 Parcel data = Parcel.obtain();
1958 Parcel reply = Parcel.obtain();
1959 data.writeInterfaceToken(IActivityManager.descriptor);
1960 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1961 data.writeTypedList(providers);
1962 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1963 reply.readException();
1964 data.recycle();
1965 reply.recycle();
1966 }
1967
1968 public void removeContentProvider(IApplicationThread caller,
1969 String name) throws RemoteException {
1970 Parcel data = Parcel.obtain();
1971 Parcel reply = Parcel.obtain();
1972 data.writeInterfaceToken(IActivityManager.descriptor);
1973 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1974 data.writeString(name);
1975 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1976 reply.readException();
1977 data.recycle();
1978 reply.recycle();
1979 }
1980
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07001981 public PendingIntent getRunningServiceControlPanel(ComponentName service)
1982 throws RemoteException
1983 {
1984 Parcel data = Parcel.obtain();
1985 Parcel reply = Parcel.obtain();
1986 data.writeInterfaceToken(IActivityManager.descriptor);
1987 service.writeToParcel(data, 0);
1988 mRemote.transact(GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION, data, reply, 0);
1989 reply.readException();
1990 PendingIntent res = PendingIntent.readPendingIntentOrNullFromParcel(reply);
1991 data.recycle();
1992 reply.recycle();
1993 return res;
1994 }
1995
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001996 public ComponentName startService(IApplicationThread caller, Intent service,
1997 String resolvedType) throws RemoteException
1998 {
1999 Parcel data = Parcel.obtain();
2000 Parcel reply = Parcel.obtain();
2001 data.writeInterfaceToken(IActivityManager.descriptor);
2002 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2003 service.writeToParcel(data, 0);
2004 data.writeString(resolvedType);
2005 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
2006 reply.readException();
2007 ComponentName res = ComponentName.readFromParcel(reply);
2008 data.recycle();
2009 reply.recycle();
2010 return res;
2011 }
2012 public int stopService(IApplicationThread caller, Intent service,
2013 String resolvedType) throws RemoteException
2014 {
2015 Parcel data = Parcel.obtain();
2016 Parcel reply = Parcel.obtain();
2017 data.writeInterfaceToken(IActivityManager.descriptor);
2018 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2019 service.writeToParcel(data, 0);
2020 data.writeString(resolvedType);
2021 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
2022 reply.readException();
2023 int res = reply.readInt();
2024 reply.recycle();
2025 data.recycle();
2026 return res;
2027 }
2028 public boolean stopServiceToken(ComponentName className, IBinder token,
2029 int startId) throws RemoteException {
2030 Parcel data = Parcel.obtain();
2031 Parcel reply = Parcel.obtain();
2032 data.writeInterfaceToken(IActivityManager.descriptor);
2033 ComponentName.writeToParcel(className, data);
2034 data.writeStrongBinder(token);
2035 data.writeInt(startId);
2036 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
2037 reply.readException();
2038 boolean res = reply.readInt() != 0;
2039 data.recycle();
2040 reply.recycle();
2041 return res;
2042 }
2043 public void setServiceForeground(ComponentName className, IBinder token,
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07002044 int id, Notification notification, boolean removeNotification) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002045 Parcel data = Parcel.obtain();
2046 Parcel reply = Parcel.obtain();
2047 data.writeInterfaceToken(IActivityManager.descriptor);
2048 ComponentName.writeToParcel(className, data);
2049 data.writeStrongBinder(token);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07002050 data.writeInt(id);
2051 if (notification != null) {
2052 data.writeInt(1);
2053 notification.writeToParcel(data, 0);
2054 } else {
2055 data.writeInt(0);
2056 }
2057 data.writeInt(removeNotification ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002058 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
2059 reply.readException();
2060 data.recycle();
2061 reply.recycle();
2062 }
2063 public int bindService(IApplicationThread caller, IBinder token,
2064 Intent service, String resolvedType, IServiceConnection connection,
2065 int flags) throws RemoteException {
2066 Parcel data = Parcel.obtain();
2067 Parcel reply = Parcel.obtain();
2068 data.writeInterfaceToken(IActivityManager.descriptor);
2069 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2070 data.writeStrongBinder(token);
2071 service.writeToParcel(data, 0);
2072 data.writeString(resolvedType);
2073 data.writeStrongBinder(connection.asBinder());
2074 data.writeInt(flags);
2075 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
2076 reply.readException();
2077 int res = reply.readInt();
2078 data.recycle();
2079 reply.recycle();
2080 return res;
2081 }
2082 public boolean unbindService(IServiceConnection connection) throws RemoteException
2083 {
2084 Parcel data = Parcel.obtain();
2085 Parcel reply = Parcel.obtain();
2086 data.writeInterfaceToken(IActivityManager.descriptor);
2087 data.writeStrongBinder(connection.asBinder());
2088 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
2089 reply.readException();
2090 boolean res = reply.readInt() != 0;
2091 data.recycle();
2092 reply.recycle();
2093 return res;
2094 }
2095
2096 public void publishService(IBinder token,
2097 Intent intent, IBinder service) throws RemoteException {
2098 Parcel data = Parcel.obtain();
2099 Parcel reply = Parcel.obtain();
2100 data.writeInterfaceToken(IActivityManager.descriptor);
2101 data.writeStrongBinder(token);
2102 intent.writeToParcel(data, 0);
2103 data.writeStrongBinder(service);
2104 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
2105 reply.readException();
2106 data.recycle();
2107 reply.recycle();
2108 }
2109
2110 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
2111 throws RemoteException {
2112 Parcel data = Parcel.obtain();
2113 Parcel reply = Parcel.obtain();
2114 data.writeInterfaceToken(IActivityManager.descriptor);
2115 data.writeStrongBinder(token);
2116 intent.writeToParcel(data, 0);
2117 data.writeInt(doRebind ? 1 : 0);
2118 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
2119 reply.readException();
2120 data.recycle();
2121 reply.recycle();
2122 }
2123
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07002124 public void serviceDoneExecuting(IBinder token, int type, int startId,
2125 int res) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002126 Parcel data = Parcel.obtain();
2127 Parcel reply = Parcel.obtain();
2128 data.writeInterfaceToken(IActivityManager.descriptor);
2129 data.writeStrongBinder(token);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07002130 data.writeInt(type);
2131 data.writeInt(startId);
2132 data.writeInt(res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002133 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2134 reply.readException();
2135 data.recycle();
2136 reply.recycle();
2137 }
2138
2139 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
2140 Parcel data = Parcel.obtain();
2141 Parcel reply = Parcel.obtain();
2142 data.writeInterfaceToken(IActivityManager.descriptor);
2143 service.writeToParcel(data, 0);
2144 data.writeString(resolvedType);
2145 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
2146 reply.readException();
2147 IBinder binder = reply.readStrongBinder();
2148 reply.recycle();
2149 data.recycle();
2150 return binder;
2151 }
2152
Christopher Tate181fafa2009-05-14 11:12:14 -07002153 public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
2154 throws RemoteException {
2155 Parcel data = Parcel.obtain();
2156 Parcel reply = Parcel.obtain();
2157 data.writeInterfaceToken(IActivityManager.descriptor);
2158 app.writeToParcel(data, 0);
2159 data.writeInt(backupRestoreMode);
2160 mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2161 reply.readException();
2162 boolean success = reply.readInt() != 0;
2163 reply.recycle();
2164 data.recycle();
2165 return success;
2166 }
2167
2168 public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException {
2169 Parcel data = Parcel.obtain();
2170 Parcel reply = Parcel.obtain();
2171 data.writeInterfaceToken(IActivityManager.descriptor);
2172 data.writeString(packageName);
2173 data.writeStrongBinder(agent);
2174 mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0);
2175 reply.recycle();
2176 data.recycle();
2177 }
2178
2179 public void unbindBackupAgent(ApplicationInfo app) throws RemoteException {
2180 Parcel data = Parcel.obtain();
2181 Parcel reply = Parcel.obtain();
2182 data.writeInterfaceToken(IActivityManager.descriptor);
2183 app.writeToParcel(data, 0);
2184 mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2185 reply.readException();
2186 reply.recycle();
2187 data.recycle();
2188 }
2189
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002190 public boolean startInstrumentation(ComponentName className, String profileFile,
2191 int flags, Bundle arguments, IInstrumentationWatcher watcher)
2192 throws RemoteException {
2193 Parcel data = Parcel.obtain();
2194 Parcel reply = Parcel.obtain();
2195 data.writeInterfaceToken(IActivityManager.descriptor);
2196 ComponentName.writeToParcel(className, data);
2197 data.writeString(profileFile);
2198 data.writeInt(flags);
2199 data.writeBundle(arguments);
2200 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2201 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2202 reply.readException();
2203 boolean res = reply.readInt() != 0;
2204 reply.recycle();
2205 data.recycle();
2206 return res;
2207 }
2208
2209 public void finishInstrumentation(IApplicationThread target,
2210 int resultCode, Bundle results) throws RemoteException {
2211 Parcel data = Parcel.obtain();
2212 Parcel reply = Parcel.obtain();
2213 data.writeInterfaceToken(IActivityManager.descriptor);
2214 data.writeStrongBinder(target != null ? target.asBinder() : null);
2215 data.writeInt(resultCode);
2216 data.writeBundle(results);
2217 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2218 reply.readException();
2219 data.recycle();
2220 reply.recycle();
2221 }
2222 public Configuration getConfiguration() throws RemoteException
2223 {
2224 Parcel data = Parcel.obtain();
2225 Parcel reply = Parcel.obtain();
2226 data.writeInterfaceToken(IActivityManager.descriptor);
2227 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
2228 reply.readException();
2229 Configuration res = Configuration.CREATOR.createFromParcel(reply);
2230 reply.recycle();
2231 data.recycle();
2232 return res;
2233 }
2234 public void updateConfiguration(Configuration values) throws RemoteException
2235 {
2236 Parcel data = Parcel.obtain();
2237 Parcel reply = Parcel.obtain();
2238 data.writeInterfaceToken(IActivityManager.descriptor);
2239 values.writeToParcel(data, 0);
2240 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
2241 reply.readException();
2242 data.recycle();
2243 reply.recycle();
2244 }
2245 public void setRequestedOrientation(IBinder token, int requestedOrientation)
2246 throws RemoteException {
2247 Parcel data = Parcel.obtain();
2248 Parcel reply = Parcel.obtain();
2249 data.writeInterfaceToken(IActivityManager.descriptor);
2250 data.writeStrongBinder(token);
2251 data.writeInt(requestedOrientation);
2252 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2253 reply.readException();
2254 data.recycle();
2255 reply.recycle();
2256 }
2257 public int getRequestedOrientation(IBinder token) throws RemoteException {
2258 Parcel data = Parcel.obtain();
2259 Parcel reply = Parcel.obtain();
2260 data.writeInterfaceToken(IActivityManager.descriptor);
2261 data.writeStrongBinder(token);
2262 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2263 reply.readException();
2264 int res = reply.readInt();
2265 data.recycle();
2266 reply.recycle();
2267 return res;
2268 }
2269 public ComponentName getActivityClassForToken(IBinder token)
2270 throws RemoteException {
2271 Parcel data = Parcel.obtain();
2272 Parcel reply = Parcel.obtain();
2273 data.writeInterfaceToken(IActivityManager.descriptor);
2274 data.writeStrongBinder(token);
2275 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
2276 reply.readException();
2277 ComponentName res = ComponentName.readFromParcel(reply);
2278 data.recycle();
2279 reply.recycle();
2280 return res;
2281 }
2282 public String getPackageForToken(IBinder token) throws RemoteException
2283 {
2284 Parcel data = Parcel.obtain();
2285 Parcel reply = Parcel.obtain();
2286 data.writeInterfaceToken(IActivityManager.descriptor);
2287 data.writeStrongBinder(token);
2288 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
2289 reply.readException();
2290 String res = reply.readString();
2291 data.recycle();
2292 reply.recycle();
2293 return res;
2294 }
2295 public IIntentSender getIntentSender(int type,
2296 String packageName, IBinder token, String resultWho,
2297 int requestCode, Intent intent, String resolvedType, int flags)
2298 throws RemoteException {
2299 Parcel data = Parcel.obtain();
2300 Parcel reply = Parcel.obtain();
2301 data.writeInterfaceToken(IActivityManager.descriptor);
2302 data.writeInt(type);
2303 data.writeString(packageName);
2304 data.writeStrongBinder(token);
2305 data.writeString(resultWho);
2306 data.writeInt(requestCode);
2307 if (intent != null) {
2308 data.writeInt(1);
2309 intent.writeToParcel(data, 0);
2310 } else {
2311 data.writeInt(0);
2312 }
2313 data.writeString(resolvedType);
2314 data.writeInt(flags);
2315 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
2316 reply.readException();
2317 IIntentSender res = IIntentSender.Stub.asInterface(
2318 reply.readStrongBinder());
2319 data.recycle();
2320 reply.recycle();
2321 return res;
2322 }
2323 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
2324 Parcel data = Parcel.obtain();
2325 Parcel reply = Parcel.obtain();
2326 data.writeInterfaceToken(IActivityManager.descriptor);
2327 data.writeStrongBinder(sender.asBinder());
2328 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
2329 reply.readException();
2330 data.recycle();
2331 reply.recycle();
2332 }
2333 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
2334 Parcel data = Parcel.obtain();
2335 Parcel reply = Parcel.obtain();
2336 data.writeInterfaceToken(IActivityManager.descriptor);
2337 data.writeStrongBinder(sender.asBinder());
2338 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
2339 reply.readException();
2340 String res = reply.readString();
2341 data.recycle();
2342 reply.recycle();
2343 return res;
2344 }
2345 public void setProcessLimit(int max) throws RemoteException
2346 {
2347 Parcel data = Parcel.obtain();
2348 Parcel reply = Parcel.obtain();
2349 data.writeInterfaceToken(IActivityManager.descriptor);
2350 data.writeInt(max);
2351 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2352 reply.readException();
2353 data.recycle();
2354 reply.recycle();
2355 }
2356 public int getProcessLimit() throws RemoteException
2357 {
2358 Parcel data = Parcel.obtain();
2359 Parcel reply = Parcel.obtain();
2360 data.writeInterfaceToken(IActivityManager.descriptor);
2361 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2362 reply.readException();
2363 int res = reply.readInt();
2364 data.recycle();
2365 reply.recycle();
2366 return res;
2367 }
2368 public void setProcessForeground(IBinder token, int pid,
2369 boolean isForeground) throws RemoteException {
2370 Parcel data = Parcel.obtain();
2371 Parcel reply = Parcel.obtain();
2372 data.writeInterfaceToken(IActivityManager.descriptor);
2373 data.writeStrongBinder(token);
2374 data.writeInt(pid);
2375 data.writeInt(isForeground ? 1 : 0);
2376 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
2377 reply.readException();
2378 data.recycle();
2379 reply.recycle();
2380 }
2381 public int checkPermission(String permission, int pid, int uid)
2382 throws RemoteException {
2383 Parcel data = Parcel.obtain();
2384 Parcel reply = Parcel.obtain();
2385 data.writeInterfaceToken(IActivityManager.descriptor);
2386 data.writeString(permission);
2387 data.writeInt(pid);
2388 data.writeInt(uid);
2389 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
2390 reply.readException();
2391 int res = reply.readInt();
2392 data.recycle();
2393 reply.recycle();
2394 return res;
2395 }
2396 public boolean clearApplicationUserData(final String packageName,
2397 final IPackageDataObserver observer) throws RemoteException {
2398 Parcel data = Parcel.obtain();
2399 Parcel reply = Parcel.obtain();
2400 data.writeInterfaceToken(IActivityManager.descriptor);
2401 data.writeString(packageName);
2402 data.writeStrongBinder(observer.asBinder());
2403 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
2404 reply.readException();
2405 boolean res = reply.readInt() != 0;
2406 data.recycle();
2407 reply.recycle();
2408 return res;
2409 }
2410 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
2411 throws RemoteException {
2412 Parcel data = Parcel.obtain();
2413 Parcel reply = Parcel.obtain();
2414 data.writeInterfaceToken(IActivityManager.descriptor);
2415 uri.writeToParcel(data, 0);
2416 data.writeInt(pid);
2417 data.writeInt(uid);
2418 data.writeInt(mode);
2419 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
2420 reply.readException();
2421 int res = reply.readInt();
2422 data.recycle();
2423 reply.recycle();
2424 return res;
2425 }
2426 public void grantUriPermission(IApplicationThread caller, String targetPkg,
2427 Uri uri, int mode) throws RemoteException {
2428 Parcel data = Parcel.obtain();
2429 Parcel reply = Parcel.obtain();
2430 data.writeInterfaceToken(IActivityManager.descriptor);
2431 data.writeStrongBinder(caller.asBinder());
2432 data.writeString(targetPkg);
2433 uri.writeToParcel(data, 0);
2434 data.writeInt(mode);
2435 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2436 reply.readException();
2437 data.recycle();
2438 reply.recycle();
2439 }
2440 public void revokeUriPermission(IApplicationThread caller, Uri uri,
2441 int mode) throws RemoteException {
2442 Parcel data = Parcel.obtain();
2443 Parcel reply = Parcel.obtain();
2444 data.writeInterfaceToken(IActivityManager.descriptor);
2445 data.writeStrongBinder(caller.asBinder());
2446 uri.writeToParcel(data, 0);
2447 data.writeInt(mode);
2448 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2449 reply.readException();
2450 data.recycle();
2451 reply.recycle();
2452 }
2453 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
2454 throws RemoteException {
2455 Parcel data = Parcel.obtain();
2456 Parcel reply = Parcel.obtain();
2457 data.writeInterfaceToken(IActivityManager.descriptor);
2458 data.writeStrongBinder(who.asBinder());
2459 data.writeInt(waiting ? 1 : 0);
2460 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
2461 reply.readException();
2462 data.recycle();
2463 reply.recycle();
2464 }
2465 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
2466 Parcel data = Parcel.obtain();
2467 Parcel reply = Parcel.obtain();
2468 data.writeInterfaceToken(IActivityManager.descriptor);
2469 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
2470 reply.readException();
2471 outInfo.readFromParcel(reply);
2472 data.recycle();
2473 reply.recycle();
2474 }
2475 public void unhandledBack() throws RemoteException
2476 {
2477 Parcel data = Parcel.obtain();
2478 Parcel reply = Parcel.obtain();
2479 data.writeInterfaceToken(IActivityManager.descriptor);
2480 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
2481 reply.readException();
2482 data.recycle();
2483 reply.recycle();
2484 }
2485 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
2486 {
2487 Parcel data = Parcel.obtain();
2488 Parcel reply = Parcel.obtain();
2489 data.writeInterfaceToken(IActivityManager.descriptor);
2490 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
2491 reply.readException();
2492 ParcelFileDescriptor pfd = null;
2493 if (reply.readInt() != 0) {
2494 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
2495 }
2496 data.recycle();
2497 reply.recycle();
2498 return pfd;
2499 }
2500 public void goingToSleep() throws RemoteException
2501 {
2502 Parcel data = Parcel.obtain();
2503 Parcel reply = Parcel.obtain();
2504 data.writeInterfaceToken(IActivityManager.descriptor);
2505 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
2506 reply.readException();
2507 data.recycle();
2508 reply.recycle();
2509 }
2510 public void wakingUp() throws RemoteException
2511 {
2512 Parcel data = Parcel.obtain();
2513 Parcel reply = Parcel.obtain();
2514 data.writeInterfaceToken(IActivityManager.descriptor);
2515 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
2516 reply.readException();
2517 data.recycle();
2518 reply.recycle();
2519 }
2520 public void setDebugApp(
2521 String packageName, boolean waitForDebugger, boolean persistent)
2522 throws RemoteException
2523 {
2524 Parcel data = Parcel.obtain();
2525 Parcel reply = Parcel.obtain();
2526 data.writeInterfaceToken(IActivityManager.descriptor);
2527 data.writeString(packageName);
2528 data.writeInt(waitForDebugger ? 1 : 0);
2529 data.writeInt(persistent ? 1 : 0);
2530 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2531 reply.readException();
2532 data.recycle();
2533 reply.recycle();
2534 }
2535 public void setAlwaysFinish(boolean enabled) throws RemoteException
2536 {
2537 Parcel data = Parcel.obtain();
2538 Parcel reply = Parcel.obtain();
2539 data.writeInterfaceToken(IActivityManager.descriptor);
2540 data.writeInt(enabled ? 1 : 0);
2541 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2542 reply.readException();
2543 data.recycle();
2544 reply.recycle();
2545 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002546 public void setActivityController(IActivityController watcher) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002547 {
2548 Parcel data = Parcel.obtain();
2549 Parcel reply = Parcel.obtain();
2550 data.writeInterfaceToken(IActivityManager.descriptor);
2551 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002552 mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002553 reply.readException();
2554 data.recycle();
2555 reply.recycle();
2556 }
2557 public void enterSafeMode() throws RemoteException {
2558 Parcel data = Parcel.obtain();
2559 data.writeInterfaceToken(IActivityManager.descriptor);
2560 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2561 data.recycle();
2562 }
2563 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2564 Parcel data = Parcel.obtain();
2565 data.writeStrongBinder(sender.asBinder());
2566 data.writeInterfaceToken(IActivityManager.descriptor);
2567 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2568 data.recycle();
2569 }
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07002570 public boolean killPids(int[] pids, String reason) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002571 Parcel data = Parcel.obtain();
2572 Parcel reply = Parcel.obtain();
2573 data.writeInterfaceToken(IActivityManager.descriptor);
2574 data.writeIntArray(pids);
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07002575 data.writeString(reason);
2576 mRemote.transact(KILL_PIDS_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002577 boolean res = reply.readInt() != 0;
2578 data.recycle();
2579 reply.recycle();
2580 return res;
2581 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002582 public void startRunning(String pkg, String cls, String action,
2583 String indata) throws RemoteException {
2584 Parcel data = Parcel.obtain();
2585 Parcel reply = Parcel.obtain();
2586 data.writeInterfaceToken(IActivityManager.descriptor);
2587 data.writeString(pkg);
2588 data.writeString(cls);
2589 data.writeString(action);
2590 data.writeString(indata);
2591 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2592 reply.readException();
2593 data.recycle();
2594 reply.recycle();
2595 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002596 public boolean testIsSystemReady()
2597 {
2598 /* this base class version is never called */
2599 return true;
2600 }
Dan Egnor60d87622009-12-16 16:32:58 -08002601 public void handleApplicationCrash(IBinder app,
2602 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
2603 {
2604 Parcel data = Parcel.obtain();
2605 Parcel reply = Parcel.obtain();
2606 data.writeInterfaceToken(IActivityManager.descriptor);
2607 data.writeStrongBinder(app);
2608 crashInfo.writeToParcel(data, 0);
2609 mRemote.transact(HANDLE_APPLICATION_CRASH_TRANSACTION, data, reply, 0);
2610 reply.readException();
2611 reply.recycle();
2612 data.recycle();
2613 }
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002614
Dan Egnor60d87622009-12-16 16:32:58 -08002615 public boolean handleApplicationWtf(IBinder app, String tag,
Dan Egnorb7f03672009-12-09 16:22:32 -08002616 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002617 {
2618 Parcel data = Parcel.obtain();
2619 Parcel reply = Parcel.obtain();
2620 data.writeInterfaceToken(IActivityManager.descriptor);
2621 data.writeStrongBinder(app);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002622 data.writeString(tag);
Dan Egnorb7f03672009-12-09 16:22:32 -08002623 crashInfo.writeToParcel(data, 0);
Dan Egnor60d87622009-12-16 16:32:58 -08002624 mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002625 reply.readException();
Dan Egnor60d87622009-12-16 16:32:58 -08002626 boolean res = reply.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002627 reply.recycle();
2628 data.recycle();
Dan Egnor60d87622009-12-16 16:32:58 -08002629 return res;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002630 }
Dan Egnorb7f03672009-12-09 16:22:32 -08002631
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002632 public void handleApplicationStrictModeViolation(IBinder app,
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07002633 int violationMask,
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07002634 StrictMode.ViolationInfo info) throws RemoteException
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002635 {
2636 Parcel data = Parcel.obtain();
2637 Parcel reply = Parcel.obtain();
2638 data.writeInterfaceToken(IActivityManager.descriptor);
2639 data.writeStrongBinder(app);
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07002640 data.writeInt(violationMask);
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07002641 info.writeToParcel(data, 0);
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002642 mRemote.transact(HANDLE_APPLICATION_STRICT_MODE_VIOLATION_TRANSACTION, data, reply, 0);
2643 reply.readException();
2644 reply.recycle();
2645 data.recycle();
2646 }
2647
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002648 public void signalPersistentProcesses(int sig) throws RemoteException {
2649 Parcel data = Parcel.obtain();
2650 Parcel reply = Parcel.obtain();
2651 data.writeInterfaceToken(IActivityManager.descriptor);
2652 data.writeInt(sig);
2653 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2654 reply.readException();
2655 data.recycle();
2656 reply.recycle();
2657 }
2658
Dianne Hackborn03abb812010-01-04 18:43:19 -08002659 public void killBackgroundProcesses(String packageName) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002660 Parcel data = Parcel.obtain();
2661 Parcel reply = Parcel.obtain();
2662 data.writeInterfaceToken(IActivityManager.descriptor);
2663 data.writeString(packageName);
Dianne Hackborn03abb812010-01-04 18:43:19 -08002664 mRemote.transact(KILL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0);
2665 reply.readException();
2666 data.recycle();
2667 reply.recycle();
2668 }
2669
2670 public void forceStopPackage(String packageName) throws RemoteException {
2671 Parcel data = Parcel.obtain();
2672 Parcel reply = Parcel.obtain();
2673 data.writeInterfaceToken(IActivityManager.descriptor);
2674 data.writeString(packageName);
2675 mRemote.transact(FORCE_STOP_PACKAGE_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002676 reply.readException();
2677 data.recycle();
2678 reply.recycle();
2679 }
2680
2681 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2682 {
2683 Parcel data = Parcel.obtain();
2684 Parcel reply = Parcel.obtain();
2685 data.writeInterfaceToken(IActivityManager.descriptor);
2686 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2687 reply.readException();
2688 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2689 reply.recycle();
2690 data.recycle();
2691 return res;
2692 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002693
2694 public boolean profileControl(String process, boolean start,
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002695 String path, ParcelFileDescriptor fd) throws RemoteException
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002696 {
2697 Parcel data = Parcel.obtain();
2698 Parcel reply = Parcel.obtain();
2699 data.writeInterfaceToken(IActivityManager.descriptor);
2700 data.writeString(process);
2701 data.writeInt(start ? 1 : 0);
2702 data.writeString(path);
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002703 if (fd != null) {
2704 data.writeInt(1);
2705 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
2706 } else {
2707 data.writeInt(0);
2708 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002709 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2710 reply.readException();
2711 boolean res = reply.readInt() != 0;
2712 reply.recycle();
2713 data.recycle();
2714 return res;
2715 }
2716
Dianne Hackborn55280a92009-05-07 15:53:46 -07002717 public boolean shutdown(int timeout) throws RemoteException
2718 {
2719 Parcel data = Parcel.obtain();
2720 Parcel reply = Parcel.obtain();
2721 data.writeInterfaceToken(IActivityManager.descriptor);
2722 data.writeInt(timeout);
2723 mRemote.transact(SHUTDOWN_TRANSACTION, data, reply, 0);
2724 reply.readException();
2725 boolean res = reply.readInt() != 0;
2726 reply.recycle();
2727 data.recycle();
2728 return res;
2729 }
2730
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07002731 public void stopAppSwitches() throws RemoteException {
2732 Parcel data = Parcel.obtain();
2733 Parcel reply = Parcel.obtain();
2734 data.writeInterfaceToken(IActivityManager.descriptor);
2735 mRemote.transact(STOP_APP_SWITCHES_TRANSACTION, data, reply, 0);
2736 reply.readException();
2737 reply.recycle();
2738 data.recycle();
2739 }
2740
2741 public void resumeAppSwitches() throws RemoteException {
2742 Parcel data = Parcel.obtain();
2743 Parcel reply = Parcel.obtain();
2744 data.writeInterfaceToken(IActivityManager.descriptor);
2745 mRemote.transact(RESUME_APP_SWITCHES_TRANSACTION, data, reply, 0);
2746 reply.readException();
2747 reply.recycle();
2748 data.recycle();
2749 }
2750
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002751 public void registerActivityWatcher(IActivityWatcher watcher)
2752 throws RemoteException {
2753 Parcel data = Parcel.obtain();
2754 Parcel reply = Parcel.obtain();
2755 data.writeInterfaceToken(IActivityManager.descriptor);
2756 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2757 mRemote.transact(REGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2758 reply.readException();
2759 data.recycle();
2760 reply.recycle();
2761 }
2762
2763 public void unregisterActivityWatcher(IActivityWatcher watcher)
2764 throws RemoteException {
2765 Parcel data = Parcel.obtain();
2766 Parcel reply = Parcel.obtain();
2767 data.writeInterfaceToken(IActivityManager.descriptor);
2768 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2769 mRemote.transact(UNREGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2770 reply.readException();
2771 data.recycle();
2772 reply.recycle();
2773 }
2774
Dianne Hackborn2d91af02009-07-16 13:34:33 -07002775 public int startActivityInPackage(int uid,
2776 Intent intent, String resolvedType, IBinder resultTo,
2777 String resultWho, int requestCode, boolean onlyIfNeeded)
2778 throws RemoteException {
2779 Parcel data = Parcel.obtain();
2780 Parcel reply = Parcel.obtain();
2781 data.writeInterfaceToken(IActivityManager.descriptor);
2782 data.writeInt(uid);
2783 intent.writeToParcel(data, 0);
2784 data.writeString(resolvedType);
2785 data.writeStrongBinder(resultTo);
2786 data.writeString(resultWho);
2787 data.writeInt(requestCode);
2788 data.writeInt(onlyIfNeeded ? 1 : 0);
2789 mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
2790 reply.readException();
2791 int result = reply.readInt();
2792 reply.recycle();
2793 data.recycle();
2794 return result;
2795 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002796
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07002797 public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
2798 Parcel data = Parcel.obtain();
2799 Parcel reply = Parcel.obtain();
2800 data.writeInterfaceToken(IActivityManager.descriptor);
2801 data.writeString(pkg);
2802 data.writeInt(uid);
2803 mRemote.transact(KILL_APPLICATION_WITH_UID_TRANSACTION, data, reply, 0);
2804 reply.readException();
2805 data.recycle();
2806 reply.recycle();
2807 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002808
2809 public void closeSystemDialogs(String reason) throws RemoteException {
2810 Parcel data = Parcel.obtain();
2811 Parcel reply = Parcel.obtain();
2812 data.writeInterfaceToken(IActivityManager.descriptor);
2813 data.writeString(reason);
2814 mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
2815 reply.readException();
2816 data.recycle();
2817 reply.recycle();
2818 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002819
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002820 public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002821 throws RemoteException {
2822 Parcel data = Parcel.obtain();
2823 Parcel reply = Parcel.obtain();
2824 data.writeInterfaceToken(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002825 data.writeIntArray(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002826 mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
2827 reply.readException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002828 Debug.MemoryInfo[] res = reply.createTypedArray(Debug.MemoryInfo.CREATOR);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002829 data.recycle();
2830 reply.recycle();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002831 return res;
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002832 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07002833
2834 public void killApplicationProcess(String processName, int uid) throws RemoteException {
2835 Parcel data = Parcel.obtain();
2836 Parcel reply = Parcel.obtain();
2837 data.writeInterfaceToken(IActivityManager.descriptor);
2838 data.writeString(processName);
2839 data.writeInt(uid);
2840 mRemote.transact(KILL_APPLICATION_PROCESS_TRANSACTION, data, reply, 0);
2841 reply.readException();
2842 data.recycle();
2843 reply.recycle();
2844 }
2845
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07002846 public void overridePendingTransition(IBinder token, String packageName,
2847 int enterAnim, int exitAnim) throws RemoteException {
2848 Parcel data = Parcel.obtain();
2849 Parcel reply = Parcel.obtain();
2850 data.writeInterfaceToken(IActivityManager.descriptor);
2851 data.writeStrongBinder(token);
2852 data.writeString(packageName);
2853 data.writeInt(enterAnim);
2854 data.writeInt(exitAnim);
2855 mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
2856 reply.readException();
2857 data.recycle();
2858 reply.recycle();
2859 }
2860
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08002861 public boolean isUserAMonkey() throws RemoteException {
2862 Parcel data = Parcel.obtain();
2863 Parcel reply = Parcel.obtain();
2864 data.writeInterfaceToken(IActivityManager.descriptor);
2865 mRemote.transact(IS_USER_A_MONKEY_TRANSACTION, data, reply, 0);
2866 reply.readException();
2867 boolean res = reply.readInt() != 0;
2868 data.recycle();
2869 reply.recycle();
2870 return res;
2871 }
2872
Dianne Hackborn860755f2010-06-03 18:47:52 -07002873 public void finishHeavyWeightApp() throws RemoteException {
2874 Parcel data = Parcel.obtain();
2875 Parcel reply = Parcel.obtain();
2876 data.writeInterfaceToken(IActivityManager.descriptor);
2877 mRemote.transact(FINISH_HEAVY_WEIGHT_APP_TRANSACTION, data, reply, 0);
2878 reply.readException();
2879 data.recycle();
2880 reply.recycle();
2881 }
2882
Daniel Sandler69a48172010-06-23 16:29:36 -04002883 public void setImmersive(IBinder token, boolean immersive)
2884 throws RemoteException {
2885 Parcel data = Parcel.obtain();
2886 Parcel reply = Parcel.obtain();
2887 data.writeInterfaceToken(IActivityManager.descriptor);
2888 data.writeStrongBinder(token);
2889 data.writeInt(immersive ? 1 : 0);
2890 mRemote.transact(SET_IMMERSIVE_TRANSACTION, data, reply, 0);
2891 reply.readException();
2892 data.recycle();
2893 reply.recycle();
2894 }
2895
2896 public boolean isImmersive(IBinder token)
2897 throws RemoteException {
2898 Parcel data = Parcel.obtain();
2899 Parcel reply = Parcel.obtain();
2900 data.writeInterfaceToken(IActivityManager.descriptor);
2901 data.writeStrongBinder(token);
2902 mRemote.transact(IS_IMMERSIVE_TRANSACTION, data, reply, 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04002903 reply.readException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07002904 boolean res = reply.readInt() == 1;
Daniel Sandler69a48172010-06-23 16:29:36 -04002905 data.recycle();
2906 reply.recycle();
2907 return res;
2908 }
2909
2910 public boolean isTopActivityImmersive()
2911 throws RemoteException {
2912 Parcel data = Parcel.obtain();
2913 Parcel reply = Parcel.obtain();
2914 data.writeInterfaceToken(IActivityManager.descriptor);
2915 mRemote.transact(IS_TOP_ACTIVITY_IMMERSIVE_TRANSACTION, data, reply, 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04002916 reply.readException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07002917 boolean res = reply.readInt() == 1;
Daniel Sandler69a48172010-06-23 16:29:36 -04002918 data.recycle();
2919 reply.recycle();
2920 return res;
2921 }
2922
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07002923 public void crashApplication(int uid, int initialPid, String packageName,
2924 String message) throws RemoteException {
2925 Parcel data = Parcel.obtain();
2926 Parcel reply = Parcel.obtain();
2927 data.writeInterfaceToken(IActivityManager.descriptor);
2928 data.writeInt(uid);
2929 data.writeInt(initialPid);
2930 data.writeString(packageName);
2931 data.writeString(message);
2932 mRemote.transact(CRASH_APPLICATION_TRANSACTION, data, reply, 0);
2933 reply.readException();
2934 data.recycle();
2935 reply.recycle();
2936 }
Andy McFadden824c5102010-07-09 16:26:57 -07002937
Dianne Hackborncca1f0e2010-09-26 18:34:53 -07002938 public String getProviderMimeType(Uri uri)
2939 throws RemoteException {
2940 Parcel data = Parcel.obtain();
2941 Parcel reply = Parcel.obtain();
2942 data.writeInterfaceToken(IActivityManager.descriptor);
2943 uri.writeToParcel(data, 0);
2944 mRemote.transact(GET_PROVIDER_MIME_TYPE_TRANSACTION, data, reply, 0);
2945 reply.readException();
2946 String res = reply.readString();
2947 data.recycle();
2948 reply.recycle();
2949 return res;
2950 }
2951
Dianne Hackborn7e269642010-08-25 19:50:20 -07002952 public IBinder newUriPermissionOwner(String name)
2953 throws RemoteException {
2954 Parcel data = Parcel.obtain();
2955 Parcel reply = Parcel.obtain();
2956 data.writeInterfaceToken(IActivityManager.descriptor);
2957 data.writeString(name);
2958 mRemote.transact(NEW_URI_PERMISSION_OWNER_TRANSACTION, data, reply, 0);
2959 reply.readException();
2960 IBinder res = reply.readStrongBinder();
2961 data.recycle();
2962 reply.recycle();
2963 return res;
2964 }
2965
2966 public void grantUriPermissionFromOwner(IBinder owner, int fromUid, String targetPkg,
2967 Uri uri, int mode) throws RemoteException {
2968 Parcel data = Parcel.obtain();
2969 Parcel reply = Parcel.obtain();
2970 data.writeInterfaceToken(IActivityManager.descriptor);
2971 data.writeStrongBinder(owner);
2972 data.writeInt(fromUid);
2973 data.writeString(targetPkg);
2974 uri.writeToParcel(data, 0);
2975 data.writeInt(mode);
2976 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2977 reply.readException();
2978 data.recycle();
2979 reply.recycle();
2980 }
2981
2982 public void revokeUriPermissionFromOwner(IBinder owner, Uri uri,
2983 int mode) throws RemoteException {
2984 Parcel data = Parcel.obtain();
2985 Parcel reply = Parcel.obtain();
2986 data.writeInterfaceToken(IActivityManager.descriptor);
2987 data.writeStrongBinder(owner);
2988 if (uri != null) {
2989 data.writeInt(1);
2990 uri.writeToParcel(data, 0);
2991 } else {
2992 data.writeInt(0);
2993 }
2994 data.writeInt(mode);
2995 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2996 reply.readException();
2997 data.recycle();
2998 reply.recycle();
2999 }
Dianne Hackbornc8f84972010-08-25 23:14:44 -07003000
Andy McFadden824c5102010-07-09 16:26:57 -07003001 public boolean dumpHeap(String process, boolean managed,
3002 String path, ParcelFileDescriptor fd) throws RemoteException {
3003 Parcel data = Parcel.obtain();
3004 Parcel reply = Parcel.obtain();
3005 data.writeInterfaceToken(IActivityManager.descriptor);
3006 data.writeString(process);
3007 data.writeInt(managed ? 1 : 0);
3008 data.writeString(path);
3009 if (fd != null) {
3010 data.writeInt(1);
3011 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
3012 } else {
3013 data.writeInt(0);
3014 }
3015 mRemote.transact(DUMP_HEAP_TRANSACTION, data, reply, 0);
3016 reply.readException();
3017 boolean res = reply.readInt() != 0;
3018 reply.recycle();
3019 data.recycle();
3020 return res;
3021 }
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07003022
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003023 private IBinder mRemote;
3024}