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