blob: 73e8d315dda06f8d9e915146612ffc42a2f7afd9 [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 Hackbornc8f84972010-08-25 23:14:44 -07001300
Dianne Hackborn7e269642010-08-25 19:50:20 -07001301 case NEW_URI_PERMISSION_OWNER_TRANSACTION: {
1302 data.enforceInterface(IActivityManager.descriptor);
1303 String name = data.readString();
1304 IBinder perm = newUriPermissionOwner(name);
1305 reply.writeNoException();
1306 reply.writeStrongBinder(perm);
1307 return true;
1308 }
1309
1310 case GRANT_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1311 data.enforceInterface(IActivityManager.descriptor);
1312 IBinder owner = data.readStrongBinder();
1313 int fromUid = data.readInt();
1314 String targetPkg = data.readString();
1315 Uri uri = Uri.CREATOR.createFromParcel(data);
1316 int mode = data.readInt();
1317 grantUriPermissionFromOwner(owner, fromUid, targetPkg, uri, mode);
1318 reply.writeNoException();
1319 return true;
1320 }
1321
1322 case REVOKE_URI_PERMISSION_FROM_OWNER_TRANSACTION: {
1323 data.enforceInterface(IActivityManager.descriptor);
1324 IBinder owner = data.readStrongBinder();
1325 Uri uri = null;
1326 if (data.readInt() != 0) {
1327 Uri.CREATOR.createFromParcel(data);
1328 }
1329 int mode = data.readInt();
1330 revokeUriPermissionFromOwner(owner, uri, mode);
1331 reply.writeNoException();
1332 return true;
1333 }
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07001334
Andy McFadden824c5102010-07-09 16:26:57 -07001335 case DUMP_HEAP_TRANSACTION: {
1336 data.enforceInterface(IActivityManager.descriptor);
1337 String process = data.readString();
1338 boolean managed = data.readInt() != 0;
1339 String path = data.readString();
1340 ParcelFileDescriptor fd = data.readInt() != 0
1341 ? data.readFileDescriptor() : null;
1342 boolean res = dumpHeap(process, managed, path, fd);
1343 reply.writeNoException();
1344 reply.writeInt(res ? 1 : 0);
1345 return true;
1346 }
1347
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001348 }
1349
1350 return super.onTransact(code, data, reply, flags);
1351 }
1352
1353 public IBinder asBinder()
1354 {
1355 return this;
1356 }
1357
1358 private static IActivityManager gDefault;
1359}
1360
1361class ActivityManagerProxy implements IActivityManager
1362{
1363 public ActivityManagerProxy(IBinder remote)
1364 {
1365 mRemote = remote;
1366 }
1367
1368 public IBinder asBinder()
1369 {
1370 return mRemote;
1371 }
1372
1373 public int startActivity(IApplicationThread caller, Intent intent,
1374 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1375 IBinder resultTo, String resultWho,
1376 int requestCode, boolean onlyIfNeeded,
1377 boolean debug) throws RemoteException {
1378 Parcel data = Parcel.obtain();
1379 Parcel reply = Parcel.obtain();
1380 data.writeInterfaceToken(IActivityManager.descriptor);
1381 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1382 intent.writeToParcel(data, 0);
1383 data.writeString(resolvedType);
1384 data.writeTypedArray(grantedUriPermissions, 0);
1385 data.writeInt(grantedMode);
1386 data.writeStrongBinder(resultTo);
1387 data.writeString(resultWho);
1388 data.writeInt(requestCode);
1389 data.writeInt(onlyIfNeeded ? 1 : 0);
1390 data.writeInt(debug ? 1 : 0);
1391 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1392 reply.readException();
1393 int result = reply.readInt();
1394 reply.recycle();
1395 data.recycle();
1396 return result;
1397 }
Dianne Hackborn8f7f35e2010-02-25 18:48:12 -08001398 public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
1399 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1400 IBinder resultTo, String resultWho,
1401 int requestCode, boolean onlyIfNeeded,
1402 boolean debug) throws RemoteException {
1403 Parcel data = Parcel.obtain();
1404 Parcel reply = Parcel.obtain();
1405 data.writeInterfaceToken(IActivityManager.descriptor);
1406 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1407 intent.writeToParcel(data, 0);
1408 data.writeString(resolvedType);
1409 data.writeTypedArray(grantedUriPermissions, 0);
1410 data.writeInt(grantedMode);
1411 data.writeStrongBinder(resultTo);
1412 data.writeString(resultWho);
1413 data.writeInt(requestCode);
1414 data.writeInt(onlyIfNeeded ? 1 : 0);
1415 data.writeInt(debug ? 1 : 0);
1416 mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
1417 reply.readException();
1418 WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
1419 reply.recycle();
1420 data.recycle();
1421 return result;
1422 }
Dianne Hackborn2ccda4d2010-03-22 21:49:15 -07001423 public int startActivityWithConfig(IApplicationThread caller, Intent intent,
1424 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1425 IBinder resultTo, String resultWho,
1426 int requestCode, boolean onlyIfNeeded,
1427 boolean debug, Configuration config) throws RemoteException {
1428 Parcel data = Parcel.obtain();
1429 Parcel reply = Parcel.obtain();
1430 data.writeInterfaceToken(IActivityManager.descriptor);
1431 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1432 intent.writeToParcel(data, 0);
1433 data.writeString(resolvedType);
1434 data.writeTypedArray(grantedUriPermissions, 0);
1435 data.writeInt(grantedMode);
1436 data.writeStrongBinder(resultTo);
1437 data.writeString(resultWho);
1438 data.writeInt(requestCode);
1439 data.writeInt(onlyIfNeeded ? 1 : 0);
1440 data.writeInt(debug ? 1 : 0);
1441 config.writeToParcel(data, 0);
1442 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1443 reply.readException();
1444 int result = reply.readInt();
1445 reply.recycle();
1446 data.recycle();
1447 return result;
1448 }
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001449 public int startActivityIntentSender(IApplicationThread caller,
1450 IntentSender intent, Intent fillInIntent, String resolvedType,
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001451 IBinder resultTo, String resultWho, int requestCode,
1452 int flagsMask, int flagsValues) throws RemoteException {
1453 Parcel data = Parcel.obtain();
1454 Parcel reply = Parcel.obtain();
1455 data.writeInterfaceToken(IActivityManager.descriptor);
1456 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1457 intent.writeToParcel(data, 0);
1458 if (fillInIntent != null) {
1459 data.writeInt(1);
1460 fillInIntent.writeToParcel(data, 0);
1461 } else {
1462 data.writeInt(0);
1463 }
1464 data.writeString(resolvedType);
1465 data.writeStrongBinder(resultTo);
1466 data.writeString(resultWho);
1467 data.writeInt(requestCode);
1468 data.writeInt(flagsMask);
1469 data.writeInt(flagsValues);
Dianne Hackbornfa82f222009-09-17 15:14:12 -07001470 mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
Dianne Hackbornbcbcaa72009-09-10 10:54:46 -07001471 reply.readException();
1472 int result = reply.readInt();
1473 reply.recycle();
1474 data.recycle();
1475 return result;
1476 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001477 public boolean startNextMatchingActivity(IBinder callingActivity,
1478 Intent intent) throws RemoteException {
1479 Parcel data = Parcel.obtain();
1480 Parcel reply = Parcel.obtain();
1481 data.writeInterfaceToken(IActivityManager.descriptor);
1482 data.writeStrongBinder(callingActivity);
1483 intent.writeToParcel(data, 0);
1484 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1485 reply.readException();
1486 int result = reply.readInt();
1487 reply.recycle();
1488 data.recycle();
1489 return result != 0;
1490 }
1491 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1492 throws RemoteException {
1493 Parcel data = Parcel.obtain();
1494 Parcel reply = Parcel.obtain();
1495 data.writeInterfaceToken(IActivityManager.descriptor);
1496 data.writeStrongBinder(token);
1497 data.writeInt(resultCode);
1498 if (resultData != null) {
1499 data.writeInt(1);
1500 resultData.writeToParcel(data, 0);
1501 } else {
1502 data.writeInt(0);
1503 }
1504 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1505 reply.readException();
1506 boolean res = reply.readInt() != 0;
1507 data.recycle();
1508 reply.recycle();
1509 return res;
1510 }
1511 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1512 {
1513 Parcel data = Parcel.obtain();
1514 Parcel reply = Parcel.obtain();
1515 data.writeInterfaceToken(IActivityManager.descriptor);
1516 data.writeStrongBinder(token);
1517 data.writeString(resultWho);
1518 data.writeInt(requestCode);
1519 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1520 reply.readException();
1521 data.recycle();
1522 reply.recycle();
1523 }
Dianne Hackborn061d58a2010-03-12 15:07:06 -08001524 public boolean willActivityBeVisible(IBinder token) throws RemoteException {
1525 Parcel data = Parcel.obtain();
1526 Parcel reply = Parcel.obtain();
1527 data.writeInterfaceToken(IActivityManager.descriptor);
1528 data.writeStrongBinder(token);
1529 mRemote.transact(WILL_ACTIVITY_BE_VISIBLE_TRANSACTION, data, reply, 0);
1530 reply.readException();
1531 boolean res = reply.readInt() != 0;
1532 data.recycle();
1533 reply.recycle();
1534 return res;
1535 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001536 public Intent registerReceiver(IApplicationThread caller,
1537 IIntentReceiver receiver,
1538 IntentFilter filter, String perm) throws RemoteException
1539 {
1540 Parcel data = Parcel.obtain();
1541 Parcel reply = Parcel.obtain();
1542 data.writeInterfaceToken(IActivityManager.descriptor);
1543 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1544 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1545 filter.writeToParcel(data, 0);
1546 data.writeString(perm);
1547 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1548 reply.readException();
1549 Intent intent = null;
1550 int haveIntent = reply.readInt();
1551 if (haveIntent != 0) {
1552 intent = Intent.CREATOR.createFromParcel(reply);
1553 }
1554 reply.recycle();
1555 data.recycle();
1556 return intent;
1557 }
1558 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1559 {
1560 Parcel data = Parcel.obtain();
1561 Parcel reply = Parcel.obtain();
1562 data.writeInterfaceToken(IActivityManager.descriptor);
1563 data.writeStrongBinder(receiver.asBinder());
1564 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1565 reply.readException();
1566 data.recycle();
1567 reply.recycle();
1568 }
1569 public int broadcastIntent(IApplicationThread caller,
1570 Intent intent, String resolvedType, IIntentReceiver resultTo,
1571 int resultCode, String resultData, Bundle map,
1572 String requiredPermission, boolean serialized,
1573 boolean sticky) throws RemoteException
1574 {
1575 Parcel data = Parcel.obtain();
1576 Parcel reply = Parcel.obtain();
1577 data.writeInterfaceToken(IActivityManager.descriptor);
1578 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1579 intent.writeToParcel(data, 0);
1580 data.writeString(resolvedType);
1581 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1582 data.writeInt(resultCode);
1583 data.writeString(resultData);
1584 data.writeBundle(map);
1585 data.writeString(requiredPermission);
1586 data.writeInt(serialized ? 1 : 0);
1587 data.writeInt(sticky ? 1 : 0);
1588 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1589 reply.readException();
1590 int res = reply.readInt();
1591 reply.recycle();
1592 data.recycle();
1593 return res;
1594 }
1595 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1596 {
1597 Parcel data = Parcel.obtain();
1598 Parcel reply = Parcel.obtain();
1599 data.writeInterfaceToken(IActivityManager.descriptor);
1600 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1601 intent.writeToParcel(data, 0);
1602 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1603 reply.readException();
1604 data.recycle();
1605 reply.recycle();
1606 }
1607 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1608 {
1609 Parcel data = Parcel.obtain();
1610 Parcel reply = Parcel.obtain();
1611 data.writeInterfaceToken(IActivityManager.descriptor);
1612 data.writeStrongBinder(who);
1613 data.writeInt(resultCode);
1614 data.writeString(resultData);
1615 data.writeBundle(map);
1616 data.writeInt(abortBroadcast ? 1 : 0);
1617 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1618 reply.readException();
1619 data.recycle();
1620 reply.recycle();
1621 }
1622 public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
1623 {
1624 Parcel data = Parcel.obtain();
1625 Parcel reply = Parcel.obtain();
1626 data.writeInterfaceToken(IActivityManager.descriptor);
1627 data.writeStrongBinder(token);
1628 data.writeInt(isPersistent ? 1 : 0);
1629 mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
1630 reply.readException();
1631 data.recycle();
1632 reply.recycle();
1633 }
1634 public void attachApplication(IApplicationThread app) throws RemoteException
1635 {
1636 Parcel data = Parcel.obtain();
1637 Parcel reply = Parcel.obtain();
1638 data.writeInterfaceToken(IActivityManager.descriptor);
1639 data.writeStrongBinder(app.asBinder());
1640 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1641 reply.readException();
1642 data.recycle();
1643 reply.recycle();
1644 }
Dianne Hackborne88846e2009-09-30 21:34:25 -07001645 public void activityIdle(IBinder token, Configuration config) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001646 {
1647 Parcel data = Parcel.obtain();
1648 Parcel reply = Parcel.obtain();
1649 data.writeInterfaceToken(IActivityManager.descriptor);
1650 data.writeStrongBinder(token);
Dianne Hackborne88846e2009-09-30 21:34:25 -07001651 if (config != null) {
1652 data.writeInt(1);
1653 config.writeToParcel(data, 0);
1654 } else {
1655 data.writeInt(0);
1656 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001657 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1658 reply.readException();
1659 data.recycle();
1660 reply.recycle();
1661 }
1662 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1663 {
1664 Parcel data = Parcel.obtain();
1665 Parcel reply = Parcel.obtain();
1666 data.writeInterfaceToken(IActivityManager.descriptor);
1667 data.writeStrongBinder(token);
1668 data.writeBundle(state);
1669 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1670 reply.readException();
1671 data.recycle();
1672 reply.recycle();
1673 }
1674 public void activityStopped(IBinder token,
1675 Bitmap thumbnail, CharSequence description) throws RemoteException
1676 {
1677 Parcel data = Parcel.obtain();
1678 Parcel reply = Parcel.obtain();
1679 data.writeInterfaceToken(IActivityManager.descriptor);
1680 data.writeStrongBinder(token);
1681 if (thumbnail != null) {
1682 data.writeInt(1);
1683 thumbnail.writeToParcel(data, 0);
1684 } else {
1685 data.writeInt(0);
1686 }
1687 TextUtils.writeToParcel(description, data, 0);
1688 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1689 reply.readException();
1690 data.recycle();
1691 reply.recycle();
1692 }
1693 public void activityDestroyed(IBinder token) throws RemoteException
1694 {
1695 Parcel data = Parcel.obtain();
1696 Parcel reply = Parcel.obtain();
1697 data.writeInterfaceToken(IActivityManager.descriptor);
1698 data.writeStrongBinder(token);
1699 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1700 reply.readException();
1701 data.recycle();
1702 reply.recycle();
1703 }
1704 public String getCallingPackage(IBinder token) throws RemoteException
1705 {
1706 Parcel data = Parcel.obtain();
1707 Parcel reply = Parcel.obtain();
1708 data.writeInterfaceToken(IActivityManager.descriptor);
1709 data.writeStrongBinder(token);
1710 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1711 reply.readException();
1712 String res = reply.readString();
1713 data.recycle();
1714 reply.recycle();
1715 return res;
1716 }
1717 public ComponentName getCallingActivity(IBinder token)
1718 throws RemoteException {
1719 Parcel data = Parcel.obtain();
1720 Parcel reply = Parcel.obtain();
1721 data.writeInterfaceToken(IActivityManager.descriptor);
1722 data.writeStrongBinder(token);
1723 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1724 reply.readException();
1725 ComponentName res = ComponentName.readFromParcel(reply);
1726 data.recycle();
1727 reply.recycle();
1728 return res;
1729 }
1730 public List getTasks(int maxNum, int flags,
1731 IThumbnailReceiver receiver) throws RemoteException {
1732 Parcel data = Parcel.obtain();
1733 Parcel reply = Parcel.obtain();
1734 data.writeInterfaceToken(IActivityManager.descriptor);
1735 data.writeInt(maxNum);
1736 data.writeInt(flags);
1737 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1738 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1739 reply.readException();
1740 ArrayList list = null;
1741 int N = reply.readInt();
1742 if (N >= 0) {
1743 list = new ArrayList();
1744 while (N > 0) {
1745 ActivityManager.RunningTaskInfo info =
1746 ActivityManager.RunningTaskInfo.CREATOR
1747 .createFromParcel(reply);
1748 list.add(info);
1749 N--;
1750 }
1751 }
1752 data.recycle();
1753 reply.recycle();
1754 return list;
1755 }
1756 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1757 int flags) throws RemoteException {
1758 Parcel data = Parcel.obtain();
1759 Parcel reply = Parcel.obtain();
1760 data.writeInterfaceToken(IActivityManager.descriptor);
1761 data.writeInt(maxNum);
1762 data.writeInt(flags);
1763 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1764 reply.readException();
1765 ArrayList<ActivityManager.RecentTaskInfo> list
1766 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1767 data.recycle();
1768 reply.recycle();
1769 return list;
1770 }
1771 public List getServices(int maxNum, int flags) throws RemoteException {
1772 Parcel data = Parcel.obtain();
1773 Parcel reply = Parcel.obtain();
1774 data.writeInterfaceToken(IActivityManager.descriptor);
1775 data.writeInt(maxNum);
1776 data.writeInt(flags);
1777 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1778 reply.readException();
1779 ArrayList list = null;
1780 int N = reply.readInt();
1781 if (N >= 0) {
1782 list = new ArrayList();
1783 while (N > 0) {
1784 ActivityManager.RunningServiceInfo info =
1785 ActivityManager.RunningServiceInfo.CREATOR
1786 .createFromParcel(reply);
1787 list.add(info);
1788 N--;
1789 }
1790 }
1791 data.recycle();
1792 reply.recycle();
1793 return list;
1794 }
1795 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1796 throws RemoteException {
1797 Parcel data = Parcel.obtain();
1798 Parcel reply = Parcel.obtain();
1799 data.writeInterfaceToken(IActivityManager.descriptor);
1800 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1801 reply.readException();
1802 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1803 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1804 data.recycle();
1805 reply.recycle();
1806 return list;
1807 }
1808 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1809 throws RemoteException {
1810 Parcel data = Parcel.obtain();
1811 Parcel reply = Parcel.obtain();
1812 data.writeInterfaceToken(IActivityManager.descriptor);
1813 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1814 reply.readException();
1815 ArrayList<ActivityManager.RunningAppProcessInfo> list
1816 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1817 data.recycle();
1818 reply.recycle();
1819 return list;
1820 }
Suchi Amalapurapuf7f5dda2010-03-23 10:34:28 -07001821 public List<ApplicationInfo> getRunningExternalApplications()
1822 throws RemoteException {
1823 Parcel data = Parcel.obtain();
1824 Parcel reply = Parcel.obtain();
1825 data.writeInterfaceToken(IActivityManager.descriptor);
1826 mRemote.transact(GET_RUNNING_EXTERNAL_APPLICATIONS_TRANSACTION, data, reply, 0);
1827 reply.readException();
1828 ArrayList<ApplicationInfo> list
1829 = reply.createTypedArrayList(ApplicationInfo.CREATOR);
1830 data.recycle();
1831 reply.recycle();
1832 return list;
1833 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001834 public void moveTaskToFront(int task) throws RemoteException
1835 {
1836 Parcel data = Parcel.obtain();
1837 Parcel reply = Parcel.obtain();
1838 data.writeInterfaceToken(IActivityManager.descriptor);
1839 data.writeInt(task);
1840 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1841 reply.readException();
1842 data.recycle();
1843 reply.recycle();
1844 }
1845 public void moveTaskToBack(int task) throws RemoteException
1846 {
1847 Parcel data = Parcel.obtain();
1848 Parcel reply = Parcel.obtain();
1849 data.writeInterfaceToken(IActivityManager.descriptor);
1850 data.writeInt(task);
1851 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1852 reply.readException();
1853 data.recycle();
1854 reply.recycle();
1855 }
1856 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1857 throws RemoteException {
1858 Parcel data = Parcel.obtain();
1859 Parcel reply = Parcel.obtain();
1860 data.writeInterfaceToken(IActivityManager.descriptor);
1861 data.writeStrongBinder(token);
1862 data.writeInt(nonRoot ? 1 : 0);
1863 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1864 reply.readException();
1865 boolean res = reply.readInt() != 0;
1866 data.recycle();
1867 reply.recycle();
1868 return res;
1869 }
1870 public void moveTaskBackwards(int task) throws RemoteException
1871 {
1872 Parcel data = Parcel.obtain();
1873 Parcel reply = Parcel.obtain();
1874 data.writeInterfaceToken(IActivityManager.descriptor);
1875 data.writeInt(task);
1876 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1877 reply.readException();
1878 data.recycle();
1879 reply.recycle();
1880 }
1881 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1882 {
1883 Parcel data = Parcel.obtain();
1884 Parcel reply = Parcel.obtain();
1885 data.writeInterfaceToken(IActivityManager.descriptor);
1886 data.writeStrongBinder(token);
1887 data.writeInt(onlyRoot ? 1 : 0);
1888 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1889 reply.readException();
1890 int res = reply.readInt();
1891 data.recycle();
1892 reply.recycle();
1893 return res;
1894 }
1895 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1896 {
1897 Parcel data = Parcel.obtain();
1898 Parcel reply = Parcel.obtain();
1899 data.writeInterfaceToken(IActivityManager.descriptor);
1900 data.writeStrongBinder(token);
1901 ComponentName.writeToParcel(className, data);
1902 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1903 reply.readException();
1904 data.recycle();
1905 reply.recycle();
1906 }
1907 public void reportThumbnail(IBinder token,
1908 Bitmap thumbnail, CharSequence description) throws RemoteException
1909 {
1910 Parcel data = Parcel.obtain();
1911 Parcel reply = Parcel.obtain();
1912 data.writeInterfaceToken(IActivityManager.descriptor);
1913 data.writeStrongBinder(token);
1914 if (thumbnail != null) {
1915 data.writeInt(1);
1916 thumbnail.writeToParcel(data, 0);
1917 } else {
1918 data.writeInt(0);
1919 }
1920 TextUtils.writeToParcel(description, data, 0);
1921 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1922 reply.readException();
1923 data.recycle();
1924 reply.recycle();
1925 }
1926 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1927 String name) throws RemoteException
1928 {
1929 Parcel data = Parcel.obtain();
1930 Parcel reply = Parcel.obtain();
1931 data.writeInterfaceToken(IActivityManager.descriptor);
1932 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1933 data.writeString(name);
1934 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1935 reply.readException();
1936 int res = reply.readInt();
1937 ContentProviderHolder cph = null;
1938 if (res != 0) {
1939 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1940 }
1941 data.recycle();
1942 reply.recycle();
1943 return cph;
1944 }
1945 public void publishContentProviders(IApplicationThread caller,
1946 List<ContentProviderHolder> providers) throws RemoteException
1947 {
1948 Parcel data = Parcel.obtain();
1949 Parcel reply = Parcel.obtain();
1950 data.writeInterfaceToken(IActivityManager.descriptor);
1951 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1952 data.writeTypedList(providers);
1953 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1954 reply.readException();
1955 data.recycle();
1956 reply.recycle();
1957 }
1958
1959 public void removeContentProvider(IApplicationThread caller,
1960 String name) throws RemoteException {
1961 Parcel data = Parcel.obtain();
1962 Parcel reply = Parcel.obtain();
1963 data.writeInterfaceToken(IActivityManager.descriptor);
1964 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1965 data.writeString(name);
1966 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1967 reply.readException();
1968 data.recycle();
1969 reply.recycle();
1970 }
1971
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07001972 public PendingIntent getRunningServiceControlPanel(ComponentName service)
1973 throws RemoteException
1974 {
1975 Parcel data = Parcel.obtain();
1976 Parcel reply = Parcel.obtain();
1977 data.writeInterfaceToken(IActivityManager.descriptor);
1978 service.writeToParcel(data, 0);
1979 mRemote.transact(GET_RUNNING_SERVICE_CONTROL_PANEL_TRANSACTION, data, reply, 0);
1980 reply.readException();
1981 PendingIntent res = PendingIntent.readPendingIntentOrNullFromParcel(reply);
1982 data.recycle();
1983 reply.recycle();
1984 return res;
1985 }
1986
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001987 public ComponentName startService(IApplicationThread caller, Intent service,
1988 String resolvedType) throws RemoteException
1989 {
1990 Parcel data = Parcel.obtain();
1991 Parcel reply = Parcel.obtain();
1992 data.writeInterfaceToken(IActivityManager.descriptor);
1993 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1994 service.writeToParcel(data, 0);
1995 data.writeString(resolvedType);
1996 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
1997 reply.readException();
1998 ComponentName res = ComponentName.readFromParcel(reply);
1999 data.recycle();
2000 reply.recycle();
2001 return res;
2002 }
2003 public int stopService(IApplicationThread caller, Intent service,
2004 String resolvedType) throws RemoteException
2005 {
2006 Parcel data = Parcel.obtain();
2007 Parcel reply = Parcel.obtain();
2008 data.writeInterfaceToken(IActivityManager.descriptor);
2009 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2010 service.writeToParcel(data, 0);
2011 data.writeString(resolvedType);
2012 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
2013 reply.readException();
2014 int res = reply.readInt();
2015 reply.recycle();
2016 data.recycle();
2017 return res;
2018 }
2019 public boolean stopServiceToken(ComponentName className, IBinder token,
2020 int startId) throws RemoteException {
2021 Parcel data = Parcel.obtain();
2022 Parcel reply = Parcel.obtain();
2023 data.writeInterfaceToken(IActivityManager.descriptor);
2024 ComponentName.writeToParcel(className, data);
2025 data.writeStrongBinder(token);
2026 data.writeInt(startId);
2027 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
2028 reply.readException();
2029 boolean res = reply.readInt() != 0;
2030 data.recycle();
2031 reply.recycle();
2032 return res;
2033 }
2034 public void setServiceForeground(ComponentName className, IBinder token,
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07002035 int id, Notification notification, boolean removeNotification) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002036 Parcel data = Parcel.obtain();
2037 Parcel reply = Parcel.obtain();
2038 data.writeInterfaceToken(IActivityManager.descriptor);
2039 ComponentName.writeToParcel(className, data);
2040 data.writeStrongBinder(token);
Dianne Hackbornd8a43f62009-08-17 23:33:56 -07002041 data.writeInt(id);
2042 if (notification != null) {
2043 data.writeInt(1);
2044 notification.writeToParcel(data, 0);
2045 } else {
2046 data.writeInt(0);
2047 }
2048 data.writeInt(removeNotification ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002049 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
2050 reply.readException();
2051 data.recycle();
2052 reply.recycle();
2053 }
2054 public int bindService(IApplicationThread caller, IBinder token,
2055 Intent service, String resolvedType, IServiceConnection connection,
2056 int flags) throws RemoteException {
2057 Parcel data = Parcel.obtain();
2058 Parcel reply = Parcel.obtain();
2059 data.writeInterfaceToken(IActivityManager.descriptor);
2060 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
2061 data.writeStrongBinder(token);
2062 service.writeToParcel(data, 0);
2063 data.writeString(resolvedType);
2064 data.writeStrongBinder(connection.asBinder());
2065 data.writeInt(flags);
2066 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
2067 reply.readException();
2068 int res = reply.readInt();
2069 data.recycle();
2070 reply.recycle();
2071 return res;
2072 }
2073 public boolean unbindService(IServiceConnection connection) throws RemoteException
2074 {
2075 Parcel data = Parcel.obtain();
2076 Parcel reply = Parcel.obtain();
2077 data.writeInterfaceToken(IActivityManager.descriptor);
2078 data.writeStrongBinder(connection.asBinder());
2079 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
2080 reply.readException();
2081 boolean res = reply.readInt() != 0;
2082 data.recycle();
2083 reply.recycle();
2084 return res;
2085 }
2086
2087 public void publishService(IBinder token,
2088 Intent intent, IBinder service) throws RemoteException {
2089 Parcel data = Parcel.obtain();
2090 Parcel reply = Parcel.obtain();
2091 data.writeInterfaceToken(IActivityManager.descriptor);
2092 data.writeStrongBinder(token);
2093 intent.writeToParcel(data, 0);
2094 data.writeStrongBinder(service);
2095 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
2096 reply.readException();
2097 data.recycle();
2098 reply.recycle();
2099 }
2100
2101 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
2102 throws RemoteException {
2103 Parcel data = Parcel.obtain();
2104 Parcel reply = Parcel.obtain();
2105 data.writeInterfaceToken(IActivityManager.descriptor);
2106 data.writeStrongBinder(token);
2107 intent.writeToParcel(data, 0);
2108 data.writeInt(doRebind ? 1 : 0);
2109 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
2110 reply.readException();
2111 data.recycle();
2112 reply.recycle();
2113 }
2114
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07002115 public void serviceDoneExecuting(IBinder token, int type, int startId,
2116 int res) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002117 Parcel data = Parcel.obtain();
2118 Parcel reply = Parcel.obtain();
2119 data.writeInterfaceToken(IActivityManager.descriptor);
2120 data.writeStrongBinder(token);
Dianne Hackbornf6f9f2d2009-08-21 16:26:03 -07002121 data.writeInt(type);
2122 data.writeInt(startId);
2123 data.writeInt(res);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002124 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
2125 reply.readException();
2126 data.recycle();
2127 reply.recycle();
2128 }
2129
2130 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
2131 Parcel data = Parcel.obtain();
2132 Parcel reply = Parcel.obtain();
2133 data.writeInterfaceToken(IActivityManager.descriptor);
2134 service.writeToParcel(data, 0);
2135 data.writeString(resolvedType);
2136 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
2137 reply.readException();
2138 IBinder binder = reply.readStrongBinder();
2139 reply.recycle();
2140 data.recycle();
2141 return binder;
2142 }
2143
Christopher Tate181fafa2009-05-14 11:12:14 -07002144 public boolean bindBackupAgent(ApplicationInfo app, int backupRestoreMode)
2145 throws RemoteException {
2146 Parcel data = Parcel.obtain();
2147 Parcel reply = Parcel.obtain();
2148 data.writeInterfaceToken(IActivityManager.descriptor);
2149 app.writeToParcel(data, 0);
2150 data.writeInt(backupRestoreMode);
2151 mRemote.transact(START_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2152 reply.readException();
2153 boolean success = reply.readInt() != 0;
2154 reply.recycle();
2155 data.recycle();
2156 return success;
2157 }
2158
2159 public void backupAgentCreated(String packageName, IBinder agent) throws RemoteException {
2160 Parcel data = Parcel.obtain();
2161 Parcel reply = Parcel.obtain();
2162 data.writeInterfaceToken(IActivityManager.descriptor);
2163 data.writeString(packageName);
2164 data.writeStrongBinder(agent);
2165 mRemote.transact(BACKUP_AGENT_CREATED_TRANSACTION, data, reply, 0);
2166 reply.recycle();
2167 data.recycle();
2168 }
2169
2170 public void unbindBackupAgent(ApplicationInfo app) throws RemoteException {
2171 Parcel data = Parcel.obtain();
2172 Parcel reply = Parcel.obtain();
2173 data.writeInterfaceToken(IActivityManager.descriptor);
2174 app.writeToParcel(data, 0);
2175 mRemote.transact(UNBIND_BACKUP_AGENT_TRANSACTION, data, reply, 0);
2176 reply.readException();
2177 reply.recycle();
2178 data.recycle();
2179 }
2180
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002181 public boolean startInstrumentation(ComponentName className, String profileFile,
2182 int flags, Bundle arguments, IInstrumentationWatcher watcher)
2183 throws RemoteException {
2184 Parcel data = Parcel.obtain();
2185 Parcel reply = Parcel.obtain();
2186 data.writeInterfaceToken(IActivityManager.descriptor);
2187 ComponentName.writeToParcel(className, data);
2188 data.writeString(profileFile);
2189 data.writeInt(flags);
2190 data.writeBundle(arguments);
2191 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2192 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2193 reply.readException();
2194 boolean res = reply.readInt() != 0;
2195 reply.recycle();
2196 data.recycle();
2197 return res;
2198 }
2199
2200 public void finishInstrumentation(IApplicationThread target,
2201 int resultCode, Bundle results) throws RemoteException {
2202 Parcel data = Parcel.obtain();
2203 Parcel reply = Parcel.obtain();
2204 data.writeInterfaceToken(IActivityManager.descriptor);
2205 data.writeStrongBinder(target != null ? target.asBinder() : null);
2206 data.writeInt(resultCode);
2207 data.writeBundle(results);
2208 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
2209 reply.readException();
2210 data.recycle();
2211 reply.recycle();
2212 }
2213 public Configuration getConfiguration() throws RemoteException
2214 {
2215 Parcel data = Parcel.obtain();
2216 Parcel reply = Parcel.obtain();
2217 data.writeInterfaceToken(IActivityManager.descriptor);
2218 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
2219 reply.readException();
2220 Configuration res = Configuration.CREATOR.createFromParcel(reply);
2221 reply.recycle();
2222 data.recycle();
2223 return res;
2224 }
2225 public void updateConfiguration(Configuration values) throws RemoteException
2226 {
2227 Parcel data = Parcel.obtain();
2228 Parcel reply = Parcel.obtain();
2229 data.writeInterfaceToken(IActivityManager.descriptor);
2230 values.writeToParcel(data, 0);
2231 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
2232 reply.readException();
2233 data.recycle();
2234 reply.recycle();
2235 }
2236 public void setRequestedOrientation(IBinder token, int requestedOrientation)
2237 throws RemoteException {
2238 Parcel data = Parcel.obtain();
2239 Parcel reply = Parcel.obtain();
2240 data.writeInterfaceToken(IActivityManager.descriptor);
2241 data.writeStrongBinder(token);
2242 data.writeInt(requestedOrientation);
2243 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2244 reply.readException();
2245 data.recycle();
2246 reply.recycle();
2247 }
2248 public int getRequestedOrientation(IBinder token) throws RemoteException {
2249 Parcel data = Parcel.obtain();
2250 Parcel reply = Parcel.obtain();
2251 data.writeInterfaceToken(IActivityManager.descriptor);
2252 data.writeStrongBinder(token);
2253 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
2254 reply.readException();
2255 int res = reply.readInt();
2256 data.recycle();
2257 reply.recycle();
2258 return res;
2259 }
2260 public ComponentName getActivityClassForToken(IBinder token)
2261 throws RemoteException {
2262 Parcel data = Parcel.obtain();
2263 Parcel reply = Parcel.obtain();
2264 data.writeInterfaceToken(IActivityManager.descriptor);
2265 data.writeStrongBinder(token);
2266 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
2267 reply.readException();
2268 ComponentName res = ComponentName.readFromParcel(reply);
2269 data.recycle();
2270 reply.recycle();
2271 return res;
2272 }
2273 public String getPackageForToken(IBinder token) throws RemoteException
2274 {
2275 Parcel data = Parcel.obtain();
2276 Parcel reply = Parcel.obtain();
2277 data.writeInterfaceToken(IActivityManager.descriptor);
2278 data.writeStrongBinder(token);
2279 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
2280 reply.readException();
2281 String res = reply.readString();
2282 data.recycle();
2283 reply.recycle();
2284 return res;
2285 }
2286 public IIntentSender getIntentSender(int type,
2287 String packageName, IBinder token, String resultWho,
2288 int requestCode, Intent intent, String resolvedType, int flags)
2289 throws RemoteException {
2290 Parcel data = Parcel.obtain();
2291 Parcel reply = Parcel.obtain();
2292 data.writeInterfaceToken(IActivityManager.descriptor);
2293 data.writeInt(type);
2294 data.writeString(packageName);
2295 data.writeStrongBinder(token);
2296 data.writeString(resultWho);
2297 data.writeInt(requestCode);
2298 if (intent != null) {
2299 data.writeInt(1);
2300 intent.writeToParcel(data, 0);
2301 } else {
2302 data.writeInt(0);
2303 }
2304 data.writeString(resolvedType);
2305 data.writeInt(flags);
2306 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
2307 reply.readException();
2308 IIntentSender res = IIntentSender.Stub.asInterface(
2309 reply.readStrongBinder());
2310 data.recycle();
2311 reply.recycle();
2312 return res;
2313 }
2314 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
2315 Parcel data = Parcel.obtain();
2316 Parcel reply = Parcel.obtain();
2317 data.writeInterfaceToken(IActivityManager.descriptor);
2318 data.writeStrongBinder(sender.asBinder());
2319 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
2320 reply.readException();
2321 data.recycle();
2322 reply.recycle();
2323 }
2324 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
2325 Parcel data = Parcel.obtain();
2326 Parcel reply = Parcel.obtain();
2327 data.writeInterfaceToken(IActivityManager.descriptor);
2328 data.writeStrongBinder(sender.asBinder());
2329 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
2330 reply.readException();
2331 String res = reply.readString();
2332 data.recycle();
2333 reply.recycle();
2334 return res;
2335 }
2336 public void setProcessLimit(int max) throws RemoteException
2337 {
2338 Parcel data = Parcel.obtain();
2339 Parcel reply = Parcel.obtain();
2340 data.writeInterfaceToken(IActivityManager.descriptor);
2341 data.writeInt(max);
2342 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2343 reply.readException();
2344 data.recycle();
2345 reply.recycle();
2346 }
2347 public int getProcessLimit() throws RemoteException
2348 {
2349 Parcel data = Parcel.obtain();
2350 Parcel reply = Parcel.obtain();
2351 data.writeInterfaceToken(IActivityManager.descriptor);
2352 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
2353 reply.readException();
2354 int res = reply.readInt();
2355 data.recycle();
2356 reply.recycle();
2357 return res;
2358 }
2359 public void setProcessForeground(IBinder token, int pid,
2360 boolean isForeground) throws RemoteException {
2361 Parcel data = Parcel.obtain();
2362 Parcel reply = Parcel.obtain();
2363 data.writeInterfaceToken(IActivityManager.descriptor);
2364 data.writeStrongBinder(token);
2365 data.writeInt(pid);
2366 data.writeInt(isForeground ? 1 : 0);
2367 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
2368 reply.readException();
2369 data.recycle();
2370 reply.recycle();
2371 }
2372 public int checkPermission(String permission, int pid, int uid)
2373 throws RemoteException {
2374 Parcel data = Parcel.obtain();
2375 Parcel reply = Parcel.obtain();
2376 data.writeInterfaceToken(IActivityManager.descriptor);
2377 data.writeString(permission);
2378 data.writeInt(pid);
2379 data.writeInt(uid);
2380 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
2381 reply.readException();
2382 int res = reply.readInt();
2383 data.recycle();
2384 reply.recycle();
2385 return res;
2386 }
2387 public boolean clearApplicationUserData(final String packageName,
2388 final IPackageDataObserver observer) throws RemoteException {
2389 Parcel data = Parcel.obtain();
2390 Parcel reply = Parcel.obtain();
2391 data.writeInterfaceToken(IActivityManager.descriptor);
2392 data.writeString(packageName);
2393 data.writeStrongBinder(observer.asBinder());
2394 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
2395 reply.readException();
2396 boolean res = reply.readInt() != 0;
2397 data.recycle();
2398 reply.recycle();
2399 return res;
2400 }
2401 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
2402 throws RemoteException {
2403 Parcel data = Parcel.obtain();
2404 Parcel reply = Parcel.obtain();
2405 data.writeInterfaceToken(IActivityManager.descriptor);
2406 uri.writeToParcel(data, 0);
2407 data.writeInt(pid);
2408 data.writeInt(uid);
2409 data.writeInt(mode);
2410 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
2411 reply.readException();
2412 int res = reply.readInt();
2413 data.recycle();
2414 reply.recycle();
2415 return res;
2416 }
2417 public void grantUriPermission(IApplicationThread caller, String targetPkg,
2418 Uri uri, int mode) throws RemoteException {
2419 Parcel data = Parcel.obtain();
2420 Parcel reply = Parcel.obtain();
2421 data.writeInterfaceToken(IActivityManager.descriptor);
2422 data.writeStrongBinder(caller.asBinder());
2423 data.writeString(targetPkg);
2424 uri.writeToParcel(data, 0);
2425 data.writeInt(mode);
2426 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2427 reply.readException();
2428 data.recycle();
2429 reply.recycle();
2430 }
2431 public void revokeUriPermission(IApplicationThread caller, Uri uri,
2432 int mode) throws RemoteException {
2433 Parcel data = Parcel.obtain();
2434 Parcel reply = Parcel.obtain();
2435 data.writeInterfaceToken(IActivityManager.descriptor);
2436 data.writeStrongBinder(caller.asBinder());
2437 uri.writeToParcel(data, 0);
2438 data.writeInt(mode);
2439 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2440 reply.readException();
2441 data.recycle();
2442 reply.recycle();
2443 }
2444 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
2445 throws RemoteException {
2446 Parcel data = Parcel.obtain();
2447 Parcel reply = Parcel.obtain();
2448 data.writeInterfaceToken(IActivityManager.descriptor);
2449 data.writeStrongBinder(who.asBinder());
2450 data.writeInt(waiting ? 1 : 0);
2451 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
2452 reply.readException();
2453 data.recycle();
2454 reply.recycle();
2455 }
2456 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
2457 Parcel data = Parcel.obtain();
2458 Parcel reply = Parcel.obtain();
2459 data.writeInterfaceToken(IActivityManager.descriptor);
2460 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
2461 reply.readException();
2462 outInfo.readFromParcel(reply);
2463 data.recycle();
2464 reply.recycle();
2465 }
2466 public void unhandledBack() throws RemoteException
2467 {
2468 Parcel data = Parcel.obtain();
2469 Parcel reply = Parcel.obtain();
2470 data.writeInterfaceToken(IActivityManager.descriptor);
2471 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
2472 reply.readException();
2473 data.recycle();
2474 reply.recycle();
2475 }
2476 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
2477 {
2478 Parcel data = Parcel.obtain();
2479 Parcel reply = Parcel.obtain();
2480 data.writeInterfaceToken(IActivityManager.descriptor);
2481 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
2482 reply.readException();
2483 ParcelFileDescriptor pfd = null;
2484 if (reply.readInt() != 0) {
2485 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
2486 }
2487 data.recycle();
2488 reply.recycle();
2489 return pfd;
2490 }
2491 public void goingToSleep() throws RemoteException
2492 {
2493 Parcel data = Parcel.obtain();
2494 Parcel reply = Parcel.obtain();
2495 data.writeInterfaceToken(IActivityManager.descriptor);
2496 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
2497 reply.readException();
2498 data.recycle();
2499 reply.recycle();
2500 }
2501 public void wakingUp() throws RemoteException
2502 {
2503 Parcel data = Parcel.obtain();
2504 Parcel reply = Parcel.obtain();
2505 data.writeInterfaceToken(IActivityManager.descriptor);
2506 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
2507 reply.readException();
2508 data.recycle();
2509 reply.recycle();
2510 }
2511 public void setDebugApp(
2512 String packageName, boolean waitForDebugger, boolean persistent)
2513 throws RemoteException
2514 {
2515 Parcel data = Parcel.obtain();
2516 Parcel reply = Parcel.obtain();
2517 data.writeInterfaceToken(IActivityManager.descriptor);
2518 data.writeString(packageName);
2519 data.writeInt(waitForDebugger ? 1 : 0);
2520 data.writeInt(persistent ? 1 : 0);
2521 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2522 reply.readException();
2523 data.recycle();
2524 reply.recycle();
2525 }
2526 public void setAlwaysFinish(boolean enabled) throws RemoteException
2527 {
2528 Parcel data = Parcel.obtain();
2529 Parcel reply = Parcel.obtain();
2530 data.writeInterfaceToken(IActivityManager.descriptor);
2531 data.writeInt(enabled ? 1 : 0);
2532 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2533 reply.readException();
2534 data.recycle();
2535 reply.recycle();
2536 }
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002537 public void setActivityController(IActivityController watcher) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002538 {
2539 Parcel data = Parcel.obtain();
2540 Parcel reply = Parcel.obtain();
2541 data.writeInterfaceToken(IActivityManager.descriptor);
2542 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002543 mRemote.transact(SET_ACTIVITY_CONTROLLER_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002544 reply.readException();
2545 data.recycle();
2546 reply.recycle();
2547 }
2548 public void enterSafeMode() throws RemoteException {
2549 Parcel data = Parcel.obtain();
2550 data.writeInterfaceToken(IActivityManager.descriptor);
2551 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2552 data.recycle();
2553 }
2554 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2555 Parcel data = Parcel.obtain();
2556 data.writeStrongBinder(sender.asBinder());
2557 data.writeInterfaceToken(IActivityManager.descriptor);
2558 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2559 data.recycle();
2560 }
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07002561 public boolean killPids(int[] pids, String reason) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002562 Parcel data = Parcel.obtain();
2563 Parcel reply = Parcel.obtain();
2564 data.writeInterfaceToken(IActivityManager.descriptor);
2565 data.writeIntArray(pids);
Suchi Amalapurapue99bb5f2010-03-19 14:36:49 -07002566 data.writeString(reason);
2567 mRemote.transact(KILL_PIDS_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002568 boolean res = reply.readInt() != 0;
2569 data.recycle();
2570 reply.recycle();
2571 return res;
2572 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002573 public void startRunning(String pkg, String cls, String action,
2574 String indata) throws RemoteException {
2575 Parcel data = Parcel.obtain();
2576 Parcel reply = Parcel.obtain();
2577 data.writeInterfaceToken(IActivityManager.descriptor);
2578 data.writeString(pkg);
2579 data.writeString(cls);
2580 data.writeString(action);
2581 data.writeString(indata);
2582 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2583 reply.readException();
2584 data.recycle();
2585 reply.recycle();
2586 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002587 public boolean testIsSystemReady()
2588 {
2589 /* this base class version is never called */
2590 return true;
2591 }
Dan Egnor60d87622009-12-16 16:32:58 -08002592 public void handleApplicationCrash(IBinder app,
2593 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
2594 {
2595 Parcel data = Parcel.obtain();
2596 Parcel reply = Parcel.obtain();
2597 data.writeInterfaceToken(IActivityManager.descriptor);
2598 data.writeStrongBinder(app);
2599 crashInfo.writeToParcel(data, 0);
2600 mRemote.transact(HANDLE_APPLICATION_CRASH_TRANSACTION, data, reply, 0);
2601 reply.readException();
2602 reply.recycle();
2603 data.recycle();
2604 }
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002605
Dan Egnor60d87622009-12-16 16:32:58 -08002606 public boolean handleApplicationWtf(IBinder app, String tag,
Dan Egnorb7f03672009-12-09 16:22:32 -08002607 ApplicationErrorReport.CrashInfo crashInfo) throws RemoteException
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002608 {
2609 Parcel data = Parcel.obtain();
2610 Parcel reply = Parcel.obtain();
2611 data.writeInterfaceToken(IActivityManager.descriptor);
2612 data.writeStrongBinder(app);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002613 data.writeString(tag);
Dan Egnorb7f03672009-12-09 16:22:32 -08002614 crashInfo.writeToParcel(data, 0);
Dan Egnor60d87622009-12-16 16:32:58 -08002615 mRemote.transact(HANDLE_APPLICATION_WTF_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002616 reply.readException();
Dan Egnor60d87622009-12-16 16:32:58 -08002617 boolean res = reply.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002618 reply.recycle();
2619 data.recycle();
Dan Egnor60d87622009-12-16 16:32:58 -08002620 return res;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002621 }
Dan Egnorb7f03672009-12-09 16:22:32 -08002622
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002623 public void handleApplicationStrictModeViolation(IBinder app,
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07002624 int violationMask,
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07002625 StrictMode.ViolationInfo info) throws RemoteException
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002626 {
2627 Parcel data = Parcel.obtain();
2628 Parcel reply = Parcel.obtain();
2629 data.writeInterfaceToken(IActivityManager.descriptor);
2630 data.writeStrongBinder(app);
Brad Fitzpatrick46d42382010-06-11 13:57:58 -07002631 data.writeInt(violationMask);
Brad Fitzpatrickcb9ceb12010-07-29 14:29:02 -07002632 info.writeToParcel(data, 0);
Brad Fitzpatrick438d0592010-06-10 12:19:19 -07002633 mRemote.transact(HANDLE_APPLICATION_STRICT_MODE_VIOLATION_TRANSACTION, data, reply, 0);
2634 reply.readException();
2635 reply.recycle();
2636 data.recycle();
2637 }
2638
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002639 public void signalPersistentProcesses(int sig) throws RemoteException {
2640 Parcel data = Parcel.obtain();
2641 Parcel reply = Parcel.obtain();
2642 data.writeInterfaceToken(IActivityManager.descriptor);
2643 data.writeInt(sig);
2644 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2645 reply.readException();
2646 data.recycle();
2647 reply.recycle();
2648 }
2649
Dianne Hackborn03abb812010-01-04 18:43:19 -08002650 public void killBackgroundProcesses(String packageName) throws RemoteException {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002651 Parcel data = Parcel.obtain();
2652 Parcel reply = Parcel.obtain();
2653 data.writeInterfaceToken(IActivityManager.descriptor);
2654 data.writeString(packageName);
Dianne Hackborn03abb812010-01-04 18:43:19 -08002655 mRemote.transact(KILL_BACKGROUND_PROCESSES_TRANSACTION, data, reply, 0);
2656 reply.readException();
2657 data.recycle();
2658 reply.recycle();
2659 }
2660
2661 public void forceStopPackage(String packageName) throws RemoteException {
2662 Parcel data = Parcel.obtain();
2663 Parcel reply = Parcel.obtain();
2664 data.writeInterfaceToken(IActivityManager.descriptor);
2665 data.writeString(packageName);
2666 mRemote.transact(FORCE_STOP_PACKAGE_TRANSACTION, data, reply, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002667 reply.readException();
2668 data.recycle();
2669 reply.recycle();
2670 }
2671
2672 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2673 {
2674 Parcel data = Parcel.obtain();
2675 Parcel reply = Parcel.obtain();
2676 data.writeInterfaceToken(IActivityManager.descriptor);
2677 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2678 reply.readException();
2679 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2680 reply.recycle();
2681 data.recycle();
2682 return res;
2683 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002684
2685 public boolean profileControl(String process, boolean start,
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002686 String path, ParcelFileDescriptor fd) throws RemoteException
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002687 {
2688 Parcel data = Parcel.obtain();
2689 Parcel reply = Parcel.obtain();
2690 data.writeInterfaceToken(IActivityManager.descriptor);
2691 data.writeString(process);
2692 data.writeInt(start ? 1 : 0);
2693 data.writeString(path);
Dianne Hackborn9c8dd552009-06-23 19:22:52 -07002694 if (fd != null) {
2695 data.writeInt(1);
2696 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
2697 } else {
2698 data.writeInt(0);
2699 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002700 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2701 reply.readException();
2702 boolean res = reply.readInt() != 0;
2703 reply.recycle();
2704 data.recycle();
2705 return res;
2706 }
2707
Dianne Hackborn55280a92009-05-07 15:53:46 -07002708 public boolean shutdown(int timeout) throws RemoteException
2709 {
2710 Parcel data = Parcel.obtain();
2711 Parcel reply = Parcel.obtain();
2712 data.writeInterfaceToken(IActivityManager.descriptor);
2713 data.writeInt(timeout);
2714 mRemote.transact(SHUTDOWN_TRANSACTION, data, reply, 0);
2715 reply.readException();
2716 boolean res = reply.readInt() != 0;
2717 reply.recycle();
2718 data.recycle();
2719 return res;
2720 }
2721
Dianne Hackborn95fc68f2009-05-19 18:37:45 -07002722 public void stopAppSwitches() throws RemoteException {
2723 Parcel data = Parcel.obtain();
2724 Parcel reply = Parcel.obtain();
2725 data.writeInterfaceToken(IActivityManager.descriptor);
2726 mRemote.transact(STOP_APP_SWITCHES_TRANSACTION, data, reply, 0);
2727 reply.readException();
2728 reply.recycle();
2729 data.recycle();
2730 }
2731
2732 public void resumeAppSwitches() throws RemoteException {
2733 Parcel data = Parcel.obtain();
2734 Parcel reply = Parcel.obtain();
2735 data.writeInterfaceToken(IActivityManager.descriptor);
2736 mRemote.transact(RESUME_APP_SWITCHES_TRANSACTION, data, reply, 0);
2737 reply.readException();
2738 reply.recycle();
2739 data.recycle();
2740 }
2741
Dianne Hackbornb06ea702009-07-13 13:07:51 -07002742 public void registerActivityWatcher(IActivityWatcher watcher)
2743 throws RemoteException {
2744 Parcel data = Parcel.obtain();
2745 Parcel reply = Parcel.obtain();
2746 data.writeInterfaceToken(IActivityManager.descriptor);
2747 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2748 mRemote.transact(REGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2749 reply.readException();
2750 data.recycle();
2751 reply.recycle();
2752 }
2753
2754 public void unregisterActivityWatcher(IActivityWatcher watcher)
2755 throws RemoteException {
2756 Parcel data = Parcel.obtain();
2757 Parcel reply = Parcel.obtain();
2758 data.writeInterfaceToken(IActivityManager.descriptor);
2759 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2760 mRemote.transact(UNREGISTER_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2761 reply.readException();
2762 data.recycle();
2763 reply.recycle();
2764 }
2765
Dianne Hackborn2d91af02009-07-16 13:34:33 -07002766 public int startActivityInPackage(int uid,
2767 Intent intent, String resolvedType, IBinder resultTo,
2768 String resultWho, int requestCode, boolean onlyIfNeeded)
2769 throws RemoteException {
2770 Parcel data = Parcel.obtain();
2771 Parcel reply = Parcel.obtain();
2772 data.writeInterfaceToken(IActivityManager.descriptor);
2773 data.writeInt(uid);
2774 intent.writeToParcel(data, 0);
2775 data.writeString(resolvedType);
2776 data.writeStrongBinder(resultTo);
2777 data.writeString(resultWho);
2778 data.writeInt(requestCode);
2779 data.writeInt(onlyIfNeeded ? 1 : 0);
2780 mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
2781 reply.readException();
2782 int result = reply.readInt();
2783 reply.recycle();
2784 data.recycle();
2785 return result;
2786 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002787
Suchi Amalapurapu261e66a2009-07-27 15:21:34 -07002788 public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
2789 Parcel data = Parcel.obtain();
2790 Parcel reply = Parcel.obtain();
2791 data.writeInterfaceToken(IActivityManager.descriptor);
2792 data.writeString(pkg);
2793 data.writeInt(uid);
2794 mRemote.transact(KILL_APPLICATION_WITH_UID_TRANSACTION, data, reply, 0);
2795 reply.readException();
2796 data.recycle();
2797 reply.recycle();
2798 }
Dianne Hackborna6ddc8a2009-07-28 17:49:55 -07002799
2800 public void closeSystemDialogs(String reason) throws RemoteException {
2801 Parcel data = Parcel.obtain();
2802 Parcel reply = Parcel.obtain();
2803 data.writeInterfaceToken(IActivityManager.descriptor);
2804 data.writeString(reason);
2805 mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
2806 reply.readException();
2807 data.recycle();
2808 reply.recycle();
2809 }
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002810
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002811 public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002812 throws RemoteException {
2813 Parcel data = Parcel.obtain();
2814 Parcel reply = Parcel.obtain();
2815 data.writeInterfaceToken(IActivityManager.descriptor);
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002816 data.writeIntArray(pids);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002817 mRemote.transact(GET_PROCESS_MEMORY_INFO_TRANSACTION, data, reply, 0);
2818 reply.readException();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002819 Debug.MemoryInfo[] res = reply.createTypedArray(Debug.MemoryInfo.CREATOR);
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002820 data.recycle();
2821 reply.recycle();
Dianne Hackborn4f21c4c2009-09-17 10:24:05 -07002822 return res;
Dianne Hackborn3025ef32009-08-31 21:31:47 -07002823 }
Christopher Tate5e1ab332009-09-01 20:32:49 -07002824
2825 public void killApplicationProcess(String processName, int uid) throws RemoteException {
2826 Parcel data = Parcel.obtain();
2827 Parcel reply = Parcel.obtain();
2828 data.writeInterfaceToken(IActivityManager.descriptor);
2829 data.writeString(processName);
2830 data.writeInt(uid);
2831 mRemote.transact(KILL_APPLICATION_PROCESS_TRANSACTION, data, reply, 0);
2832 reply.readException();
2833 data.recycle();
2834 reply.recycle();
2835 }
2836
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07002837 public void overridePendingTransition(IBinder token, String packageName,
2838 int enterAnim, int exitAnim) throws RemoteException {
2839 Parcel data = Parcel.obtain();
2840 Parcel reply = Parcel.obtain();
2841 data.writeInterfaceToken(IActivityManager.descriptor);
2842 data.writeStrongBinder(token);
2843 data.writeString(packageName);
2844 data.writeInt(enterAnim);
2845 data.writeInt(exitAnim);
2846 mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
2847 reply.readException();
2848 data.recycle();
2849 reply.recycle();
2850 }
2851
Dianne Hackborn9327f4f2010-01-29 10:38:29 -08002852 public boolean isUserAMonkey() throws RemoteException {
2853 Parcel data = Parcel.obtain();
2854 Parcel reply = Parcel.obtain();
2855 data.writeInterfaceToken(IActivityManager.descriptor);
2856 mRemote.transact(IS_USER_A_MONKEY_TRANSACTION, data, reply, 0);
2857 reply.readException();
2858 boolean res = reply.readInt() != 0;
2859 data.recycle();
2860 reply.recycle();
2861 return res;
2862 }
2863
Dianne Hackborn860755f2010-06-03 18:47:52 -07002864 public void finishHeavyWeightApp() throws RemoteException {
2865 Parcel data = Parcel.obtain();
2866 Parcel reply = Parcel.obtain();
2867 data.writeInterfaceToken(IActivityManager.descriptor);
2868 mRemote.transact(FINISH_HEAVY_WEIGHT_APP_TRANSACTION, data, reply, 0);
2869 reply.readException();
2870 data.recycle();
2871 reply.recycle();
2872 }
2873
Daniel Sandler69a48172010-06-23 16:29:36 -04002874 public void setImmersive(IBinder token, boolean immersive)
2875 throws RemoteException {
2876 Parcel data = Parcel.obtain();
2877 Parcel reply = Parcel.obtain();
2878 data.writeInterfaceToken(IActivityManager.descriptor);
2879 data.writeStrongBinder(token);
2880 data.writeInt(immersive ? 1 : 0);
2881 mRemote.transact(SET_IMMERSIVE_TRANSACTION, data, reply, 0);
2882 reply.readException();
2883 data.recycle();
2884 reply.recycle();
2885 }
2886
2887 public boolean isImmersive(IBinder token)
2888 throws RemoteException {
2889 Parcel data = Parcel.obtain();
2890 Parcel reply = Parcel.obtain();
2891 data.writeInterfaceToken(IActivityManager.descriptor);
2892 data.writeStrongBinder(token);
2893 mRemote.transact(IS_IMMERSIVE_TRANSACTION, data, reply, 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04002894 reply.readException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07002895 boolean res = reply.readInt() == 1;
Daniel Sandler69a48172010-06-23 16:29:36 -04002896 data.recycle();
2897 reply.recycle();
2898 return res;
2899 }
2900
2901 public boolean isTopActivityImmersive()
2902 throws RemoteException {
2903 Parcel data = Parcel.obtain();
2904 Parcel reply = Parcel.obtain();
2905 data.writeInterfaceToken(IActivityManager.descriptor);
2906 mRemote.transact(IS_TOP_ACTIVITY_IMMERSIVE_TRANSACTION, data, reply, 0);
Daniel Sandler69a48172010-06-23 16:29:36 -04002907 reply.readException();
Dianne Hackborn7e269642010-08-25 19:50:20 -07002908 boolean res = reply.readInt() == 1;
Daniel Sandler69a48172010-06-23 16:29:36 -04002909 data.recycle();
2910 reply.recycle();
2911 return res;
2912 }
2913
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07002914 public void crashApplication(int uid, int initialPid, String packageName,
2915 String message) throws RemoteException {
2916 Parcel data = Parcel.obtain();
2917 Parcel reply = Parcel.obtain();
2918 data.writeInterfaceToken(IActivityManager.descriptor);
2919 data.writeInt(uid);
2920 data.writeInt(initialPid);
2921 data.writeString(packageName);
2922 data.writeString(message);
2923 mRemote.transact(CRASH_APPLICATION_TRANSACTION, data, reply, 0);
2924 reply.readException();
2925 data.recycle();
2926 reply.recycle();
2927 }
Andy McFadden824c5102010-07-09 16:26:57 -07002928
Dianne Hackborn7e269642010-08-25 19:50:20 -07002929 public IBinder newUriPermissionOwner(String name)
2930 throws RemoteException {
2931 Parcel data = Parcel.obtain();
2932 Parcel reply = Parcel.obtain();
2933 data.writeInterfaceToken(IActivityManager.descriptor);
2934 data.writeString(name);
2935 mRemote.transact(NEW_URI_PERMISSION_OWNER_TRANSACTION, data, reply, 0);
2936 reply.readException();
2937 IBinder res = reply.readStrongBinder();
2938 data.recycle();
2939 reply.recycle();
2940 return res;
2941 }
2942
2943 public void grantUriPermissionFromOwner(IBinder owner, int fromUid, String targetPkg,
2944 Uri uri, int mode) throws RemoteException {
2945 Parcel data = Parcel.obtain();
2946 Parcel reply = Parcel.obtain();
2947 data.writeInterfaceToken(IActivityManager.descriptor);
2948 data.writeStrongBinder(owner);
2949 data.writeInt(fromUid);
2950 data.writeString(targetPkg);
2951 uri.writeToParcel(data, 0);
2952 data.writeInt(mode);
2953 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
2954 reply.readException();
2955 data.recycle();
2956 reply.recycle();
2957 }
2958
2959 public void revokeUriPermissionFromOwner(IBinder owner, Uri uri,
2960 int mode) throws RemoteException {
2961 Parcel data = Parcel.obtain();
2962 Parcel reply = Parcel.obtain();
2963 data.writeInterfaceToken(IActivityManager.descriptor);
2964 data.writeStrongBinder(owner);
2965 if (uri != null) {
2966 data.writeInt(1);
2967 uri.writeToParcel(data, 0);
2968 } else {
2969 data.writeInt(0);
2970 }
2971 data.writeInt(mode);
2972 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
2973 reply.readException();
2974 data.recycle();
2975 reply.recycle();
2976 }
Dianne Hackbornc8f84972010-08-25 23:14:44 -07002977
Andy McFadden824c5102010-07-09 16:26:57 -07002978 public boolean dumpHeap(String process, boolean managed,
2979 String path, ParcelFileDescriptor fd) throws RemoteException {
2980 Parcel data = Parcel.obtain();
2981 Parcel reply = Parcel.obtain();
2982 data.writeInterfaceToken(IActivityManager.descriptor);
2983 data.writeString(process);
2984 data.writeInt(managed ? 1 : 0);
2985 data.writeString(path);
2986 if (fd != null) {
2987 data.writeInt(1);
2988 fd.writeToParcel(data, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
2989 } else {
2990 data.writeInt(0);
2991 }
2992 mRemote.transact(DUMP_HEAP_TRANSACTION, data, reply, 0);
2993 reply.readException();
2994 boolean res = reply.readInt() != 0;
2995 reply.recycle();
2996 data.recycle();
2997 return res;
2998 }
Dianne Hackborn9d39d0c2010-06-24 15:57:42 -07002999
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003000 private IBinder mRemote;
3001}