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