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