blob: 53e6f34a691564b24565339eb7f813c68101550e [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;
20import android.content.ContentResolver;
21import android.content.Intent;
22import android.content.IntentFilter;
23import android.content.pm.ConfigurationInfo;
24import android.content.pm.IPackageDataObserver;
25import android.content.res.Configuration;
26import android.graphics.Bitmap;
27import android.net.Uri;
28import android.os.Binder;
29import android.os.Bundle;
30import android.os.Parcelable;
31import android.os.ParcelFileDescriptor;
32import android.os.RemoteException;
33import android.os.IBinder;
34import android.os.Parcel;
35import android.os.ServiceManager;
36import android.text.TextUtils;
37import android.util.Config;
38import android.util.Log;
39
40import java.io.FileNotFoundException;
41import java.io.FileDescriptor;
42import java.io.IOException;
43import 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 }
147
148 case START_NEXT_MATCHING_ACTIVITY_TRANSACTION:
149 {
150 data.enforceInterface(IActivityManager.descriptor);
151 IBinder callingActivity = data.readStrongBinder();
152 Intent intent = Intent.CREATOR.createFromParcel(data);
153 boolean result = startNextMatchingActivity(callingActivity, intent);
154 reply.writeNoException();
155 reply.writeInt(result ? 1 : 0);
156 return true;
157 }
158
159 case FINISH_ACTIVITY_TRANSACTION: {
160 data.enforceInterface(IActivityManager.descriptor);
161 IBinder token = data.readStrongBinder();
162 Intent resultData = null;
163 int resultCode = data.readInt();
164 if (data.readInt() != 0) {
165 resultData = Intent.CREATOR.createFromParcel(data);
166 }
167 boolean res = finishActivity(token, resultCode, resultData);
168 reply.writeNoException();
169 reply.writeInt(res ? 1 : 0);
170 return true;
171 }
172
173 case FINISH_SUB_ACTIVITY_TRANSACTION: {
174 data.enforceInterface(IActivityManager.descriptor);
175 IBinder token = data.readStrongBinder();
176 String resultWho = data.readString();
177 int requestCode = data.readInt();
178 finishSubActivity(token, resultWho, requestCode);
179 reply.writeNoException();
180 return true;
181 }
182
183 case REGISTER_RECEIVER_TRANSACTION:
184 {
185 data.enforceInterface(IActivityManager.descriptor);
186 IBinder b = data.readStrongBinder();
187 IApplicationThread app =
188 b != null ? ApplicationThreadNative.asInterface(b) : null;
189 b = data.readStrongBinder();
190 IIntentReceiver rec
191 = b != null ? IIntentReceiver.Stub.asInterface(b) : null;
192 IntentFilter filter = IntentFilter.CREATOR.createFromParcel(data);
193 String perm = data.readString();
194 Intent intent = registerReceiver(app, rec, filter, perm);
195 reply.writeNoException();
196 if (intent != null) {
197 reply.writeInt(1);
198 intent.writeToParcel(reply, 0);
199 } else {
200 reply.writeInt(0);
201 }
202 return true;
203 }
204
205 case UNREGISTER_RECEIVER_TRANSACTION:
206 {
207 data.enforceInterface(IActivityManager.descriptor);
208 IBinder b = data.readStrongBinder();
209 if (b == null) {
210 return true;
211 }
212 IIntentReceiver rec = IIntentReceiver.Stub.asInterface(b);
213 unregisterReceiver(rec);
214 reply.writeNoException();
215 return true;
216 }
217
218 case BROADCAST_INTENT_TRANSACTION:
219 {
220 data.enforceInterface(IActivityManager.descriptor);
221 IBinder b = data.readStrongBinder();
222 IApplicationThread app =
223 b != null ? ApplicationThreadNative.asInterface(b) : null;
224 Intent intent = Intent.CREATOR.createFromParcel(data);
225 String resolvedType = data.readString();
226 b = data.readStrongBinder();
227 IIntentReceiver resultTo =
228 b != null ? IIntentReceiver.Stub.asInterface(b) : null;
229 int resultCode = data.readInt();
230 String resultData = data.readString();
231 Bundle resultExtras = data.readBundle();
232 String perm = data.readString();
233 boolean serialized = data.readInt() != 0;
234 boolean sticky = data.readInt() != 0;
235 int res = broadcastIntent(app, intent, resolvedType, resultTo,
236 resultCode, resultData, resultExtras, perm,
237 serialized, sticky);
238 reply.writeNoException();
239 reply.writeInt(res);
240 return true;
241 }
242
243 case UNBROADCAST_INTENT_TRANSACTION:
244 {
245 data.enforceInterface(IActivityManager.descriptor);
246 IBinder b = data.readStrongBinder();
247 IApplicationThread app = b != null ? ApplicationThreadNative.asInterface(b) : null;
248 Intent intent = Intent.CREATOR.createFromParcel(data);
249 unbroadcastIntent(app, intent);
250 reply.writeNoException();
251 return true;
252 }
253
254 case FINISH_RECEIVER_TRANSACTION: {
255 data.enforceInterface(IActivityManager.descriptor);
256 IBinder who = data.readStrongBinder();
257 int resultCode = data.readInt();
258 String resultData = data.readString();
259 Bundle resultExtras = data.readBundle();
260 boolean resultAbort = data.readInt() != 0;
261 if (who != null) {
262 finishReceiver(who, resultCode, resultData, resultExtras, resultAbort);
263 }
264 reply.writeNoException();
265 return true;
266 }
267
268 case SET_PERSISTENT_TRANSACTION: {
269 data.enforceInterface(IActivityManager.descriptor);
270 IBinder token = data.readStrongBinder();
271 boolean isPersistent = data.readInt() != 0;
272 if (token != null) {
273 setPersistent(token, isPersistent);
274 }
275 reply.writeNoException();
276 return true;
277 }
278
279 case ATTACH_APPLICATION_TRANSACTION: {
280 data.enforceInterface(IActivityManager.descriptor);
281 IApplicationThread app = ApplicationThreadNative.asInterface(
282 data.readStrongBinder());
283 if (app != null) {
284 attachApplication(app);
285 }
286 reply.writeNoException();
287 return true;
288 }
289
290 case ACTIVITY_IDLE_TRANSACTION: {
291 data.enforceInterface(IActivityManager.descriptor);
292 IBinder token = data.readStrongBinder();
293 if (token != null) {
294 activityIdle(token);
295 }
296 reply.writeNoException();
297 return true;
298 }
299
300 case ACTIVITY_PAUSED_TRANSACTION: {
301 data.enforceInterface(IActivityManager.descriptor);
302 IBinder token = data.readStrongBinder();
303 Bundle map = data.readBundle();
304 activityPaused(token, map);
305 reply.writeNoException();
306 return true;
307 }
308
309 case ACTIVITY_STOPPED_TRANSACTION: {
310 data.enforceInterface(IActivityManager.descriptor);
311 IBinder token = data.readStrongBinder();
312 Bitmap thumbnail = data.readInt() != 0
313 ? Bitmap.CREATOR.createFromParcel(data) : null;
314 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
315 activityStopped(token, thumbnail, description);
316 reply.writeNoException();
317 return true;
318 }
319
320 case ACTIVITY_DESTROYED_TRANSACTION: {
321 data.enforceInterface(IActivityManager.descriptor);
322 IBinder token = data.readStrongBinder();
323 activityDestroyed(token);
324 reply.writeNoException();
325 return true;
326 }
327
328 case GET_CALLING_PACKAGE_TRANSACTION: {
329 data.enforceInterface(IActivityManager.descriptor);
330 IBinder token = data.readStrongBinder();
331 String res = token != null ? getCallingPackage(token) : null;
332 reply.writeNoException();
333 reply.writeString(res);
334 return true;
335 }
336
337 case GET_CALLING_ACTIVITY_TRANSACTION: {
338 data.enforceInterface(IActivityManager.descriptor);
339 IBinder token = data.readStrongBinder();
340 ComponentName cn = getCallingActivity(token);
341 reply.writeNoException();
342 ComponentName.writeToParcel(cn, reply);
343 return true;
344 }
345
346 case GET_TASKS_TRANSACTION: {
347 data.enforceInterface(IActivityManager.descriptor);
348 int maxNum = data.readInt();
349 int fl = data.readInt();
350 IBinder receiverBinder = data.readStrongBinder();
351 IThumbnailReceiver receiver = receiverBinder != null
352 ? IThumbnailReceiver.Stub.asInterface(receiverBinder)
353 : null;
354 List list = getTasks(maxNum, fl, receiver);
355 reply.writeNoException();
356 int N = list != null ? list.size() : -1;
357 reply.writeInt(N);
358 int i;
359 for (i=0; i<N; i++) {
360 ActivityManager.RunningTaskInfo info =
361 (ActivityManager.RunningTaskInfo)list.get(i);
362 info.writeToParcel(reply, 0);
363 }
364 return true;
365 }
366
367 case GET_RECENT_TASKS_TRANSACTION: {
368 data.enforceInterface(IActivityManager.descriptor);
369 int maxNum = data.readInt();
370 int fl = data.readInt();
371 List<ActivityManager.RecentTaskInfo> list = getRecentTasks(maxNum,
372 fl);
373 reply.writeNoException();
374 reply.writeTypedList(list);
375 return true;
376 }
377
378 case GET_SERVICES_TRANSACTION: {
379 data.enforceInterface(IActivityManager.descriptor);
380 int maxNum = data.readInt();
381 int fl = data.readInt();
382 List list = getServices(maxNum, fl);
383 reply.writeNoException();
384 int N = list != null ? list.size() : -1;
385 reply.writeInt(N);
386 int i;
387 for (i=0; i<N; i++) {
388 ActivityManager.RunningServiceInfo info =
389 (ActivityManager.RunningServiceInfo)list.get(i);
390 info.writeToParcel(reply, 0);
391 }
392 return true;
393 }
394
395 case GET_PROCESSES_IN_ERROR_STATE_TRANSACTION: {
396 data.enforceInterface(IActivityManager.descriptor);
397 List<ActivityManager.ProcessErrorStateInfo> list = getProcessesInErrorState();
398 reply.writeNoException();
399 reply.writeTypedList(list);
400 return true;
401 }
402
403 case GET_RUNNING_APP_PROCESSES_TRANSACTION: {
404 data.enforceInterface(IActivityManager.descriptor);
405 List<ActivityManager.RunningAppProcessInfo> list = getRunningAppProcesses();
406 reply.writeNoException();
407 reply.writeTypedList(list);
408 return true;
409 }
410
411 case MOVE_TASK_TO_FRONT_TRANSACTION: {
412 data.enforceInterface(IActivityManager.descriptor);
413 int task = data.readInt();
414 moveTaskToFront(task);
415 reply.writeNoException();
416 return true;
417 }
418
419 case MOVE_TASK_TO_BACK_TRANSACTION: {
420 data.enforceInterface(IActivityManager.descriptor);
421 int task = data.readInt();
422 moveTaskToBack(task);
423 reply.writeNoException();
424 return true;
425 }
426
427 case MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION: {
428 data.enforceInterface(IActivityManager.descriptor);
429 IBinder token = data.readStrongBinder();
430 boolean nonRoot = data.readInt() != 0;
431 boolean res = moveActivityTaskToBack(token, nonRoot);
432 reply.writeNoException();
433 reply.writeInt(res ? 1 : 0);
434 return true;
435 }
436
437 case MOVE_TASK_BACKWARDS_TRANSACTION: {
438 data.enforceInterface(IActivityManager.descriptor);
439 int task = data.readInt();
440 moveTaskBackwards(task);
441 reply.writeNoException();
442 return true;
443 }
444
445 case GET_TASK_FOR_ACTIVITY_TRANSACTION: {
446 data.enforceInterface(IActivityManager.descriptor);
447 IBinder token = data.readStrongBinder();
448 boolean onlyRoot = data.readInt() != 0;
449 int res = token != null
450 ? getTaskForActivity(token, onlyRoot) : -1;
451 reply.writeNoException();
452 reply.writeInt(res);
453 return true;
454 }
455
456 case FINISH_OTHER_INSTANCES_TRANSACTION: {
457 data.enforceInterface(IActivityManager.descriptor);
458 IBinder token = data.readStrongBinder();
459 ComponentName className = ComponentName.readFromParcel(data);
460 finishOtherInstances(token, className);
461 reply.writeNoException();
462 return true;
463 }
464
465 case REPORT_THUMBNAIL_TRANSACTION: {
466 data.enforceInterface(IActivityManager.descriptor);
467 IBinder token = data.readStrongBinder();
468 Bitmap thumbnail = data.readInt() != 0
469 ? Bitmap.CREATOR.createFromParcel(data) : null;
470 CharSequence description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(data);
471 reportThumbnail(token, thumbnail, description);
472 reply.writeNoException();
473 return true;
474 }
475
476 case GET_CONTENT_PROVIDER_TRANSACTION: {
477 data.enforceInterface(IActivityManager.descriptor);
478 IBinder b = data.readStrongBinder();
479 IApplicationThread app = ApplicationThreadNative.asInterface(b);
480 String name = data.readString();
481 ContentProviderHolder cph = getContentProvider(app, name);
482 reply.writeNoException();
483 if (cph != null) {
484 reply.writeInt(1);
485 cph.writeToParcel(reply, 0);
486 } else {
487 reply.writeInt(0);
488 }
489 return true;
490 }
491
492 case PUBLISH_CONTENT_PROVIDERS_TRANSACTION: {
493 data.enforceInterface(IActivityManager.descriptor);
494 IBinder b = data.readStrongBinder();
495 IApplicationThread app = ApplicationThreadNative.asInterface(b);
496 ArrayList<ContentProviderHolder> providers =
497 data.createTypedArrayList(ContentProviderHolder.CREATOR);
498 publishContentProviders(app, providers);
499 reply.writeNoException();
500 return true;
501 }
502
503 case REMOVE_CONTENT_PROVIDER_TRANSACTION: {
504 data.enforceInterface(IActivityManager.descriptor);
505 IBinder b = data.readStrongBinder();
506 IApplicationThread app = ApplicationThreadNative.asInterface(b);
507 String name = data.readString();
508 removeContentProvider(app, name);
509 reply.writeNoException();
510 return true;
511 }
512
513 case START_SERVICE_TRANSACTION: {
514 data.enforceInterface(IActivityManager.descriptor);
515 IBinder b = data.readStrongBinder();
516 IApplicationThread app = ApplicationThreadNative.asInterface(b);
517 Intent service = Intent.CREATOR.createFromParcel(data);
518 String resolvedType = data.readString();
519 ComponentName cn = startService(app, service, resolvedType);
520 reply.writeNoException();
521 ComponentName.writeToParcel(cn, reply);
522 return true;
523 }
524
525 case STOP_SERVICE_TRANSACTION: {
526 data.enforceInterface(IActivityManager.descriptor);
527 IBinder b = data.readStrongBinder();
528 IApplicationThread app = ApplicationThreadNative.asInterface(b);
529 Intent service = Intent.CREATOR.createFromParcel(data);
530 String resolvedType = data.readString();
531 int res = stopService(app, service, resolvedType);
532 reply.writeNoException();
533 reply.writeInt(res);
534 return true;
535 }
536
537 case STOP_SERVICE_TOKEN_TRANSACTION: {
538 data.enforceInterface(IActivityManager.descriptor);
539 ComponentName className = ComponentName.readFromParcel(data);
540 IBinder token = data.readStrongBinder();
541 int startId = data.readInt();
542 boolean res = stopServiceToken(className, token, startId);
543 reply.writeNoException();
544 reply.writeInt(res ? 1 : 0);
545 return true;
546 }
547
548 case SET_SERVICE_FOREGROUND_TRANSACTION: {
549 data.enforceInterface(IActivityManager.descriptor);
550 ComponentName className = ComponentName.readFromParcel(data);
551 IBinder token = data.readStrongBinder();
552 boolean isForeground = data.readInt() != 0;
553 setServiceForeground(className, token, isForeground);
554 reply.writeNoException();
555 return true;
556 }
557
558 case BIND_SERVICE_TRANSACTION: {
559 data.enforceInterface(IActivityManager.descriptor);
560 IBinder b = data.readStrongBinder();
561 IApplicationThread app = ApplicationThreadNative.asInterface(b);
562 IBinder token = data.readStrongBinder();
563 Intent service = Intent.CREATOR.createFromParcel(data);
564 String resolvedType = data.readString();
565 b = data.readStrongBinder();
566 int fl = data.readInt();
567 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
568 int res = bindService(app, token, service, resolvedType, conn, fl);
569 reply.writeNoException();
570 reply.writeInt(res);
571 return true;
572 }
573
574 case UNBIND_SERVICE_TRANSACTION: {
575 data.enforceInterface(IActivityManager.descriptor);
576 IBinder b = data.readStrongBinder();
577 IServiceConnection conn = IServiceConnection.Stub.asInterface(b);
578 boolean res = unbindService(conn);
579 reply.writeNoException();
580 reply.writeInt(res ? 1 : 0);
581 return true;
582 }
583
584 case PUBLISH_SERVICE_TRANSACTION: {
585 data.enforceInterface(IActivityManager.descriptor);
586 IBinder token = data.readStrongBinder();
587 Intent intent = Intent.CREATOR.createFromParcel(data);
588 IBinder service = data.readStrongBinder();
589 publishService(token, intent, service);
590 reply.writeNoException();
591 return true;
592 }
593
594 case UNBIND_FINISHED_TRANSACTION: {
595 data.enforceInterface(IActivityManager.descriptor);
596 IBinder token = data.readStrongBinder();
597 Intent intent = Intent.CREATOR.createFromParcel(data);
598 boolean doRebind = data.readInt() != 0;
599 unbindFinished(token, intent, doRebind);
600 reply.writeNoException();
601 return true;
602 }
603
604 case SERVICE_DONE_EXECUTING_TRANSACTION: {
605 data.enforceInterface(IActivityManager.descriptor);
606 IBinder token = data.readStrongBinder();
607 serviceDoneExecuting(token);
608 reply.writeNoException();
609 return true;
610 }
611
612 case START_INSTRUMENTATION_TRANSACTION: {
613 data.enforceInterface(IActivityManager.descriptor);
614 ComponentName className = ComponentName.readFromParcel(data);
615 String profileFile = data.readString();
616 int fl = data.readInt();
617 Bundle arguments = data.readBundle();
618 IBinder b = data.readStrongBinder();
619 IInstrumentationWatcher w = IInstrumentationWatcher.Stub.asInterface(b);
620 boolean res = startInstrumentation(className, profileFile, fl, arguments, w);
621 reply.writeNoException();
622 reply.writeInt(res ? 1 : 0);
623 return true;
624 }
625
626
627 case FINISH_INSTRUMENTATION_TRANSACTION: {
628 data.enforceInterface(IActivityManager.descriptor);
629 IBinder b = data.readStrongBinder();
630 IApplicationThread app = ApplicationThreadNative.asInterface(b);
631 int resultCode = data.readInt();
632 Bundle results = data.readBundle();
633 finishInstrumentation(app, resultCode, results);
634 reply.writeNoException();
635 return true;
636 }
637
638 case GET_CONFIGURATION_TRANSACTION: {
639 data.enforceInterface(IActivityManager.descriptor);
640 Configuration config = getConfiguration();
641 reply.writeNoException();
642 config.writeToParcel(reply, 0);
643 return true;
644 }
645
646 case UPDATE_CONFIGURATION_TRANSACTION: {
647 data.enforceInterface(IActivityManager.descriptor);
648 Configuration config = Configuration.CREATOR.createFromParcel(data);
649 updateConfiguration(config);
650 reply.writeNoException();
651 return true;
652 }
653
654 case SET_REQUESTED_ORIENTATION_TRANSACTION: {
655 data.enforceInterface(IActivityManager.descriptor);
656 IBinder token = data.readStrongBinder();
657 int requestedOrientation = data.readInt();
658 setRequestedOrientation(token, requestedOrientation);
659 reply.writeNoException();
660 return true;
661 }
662
663 case GET_REQUESTED_ORIENTATION_TRANSACTION: {
664 data.enforceInterface(IActivityManager.descriptor);
665 IBinder token = data.readStrongBinder();
666 int req = getRequestedOrientation(token);
667 reply.writeNoException();
668 reply.writeInt(req);
669 return true;
670 }
671
672 case GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION: {
673 data.enforceInterface(IActivityManager.descriptor);
674 IBinder token = data.readStrongBinder();
675 ComponentName cn = getActivityClassForToken(token);
676 reply.writeNoException();
677 ComponentName.writeToParcel(cn, reply);
678 return true;
679 }
680
681 case GET_PACKAGE_FOR_TOKEN_TRANSACTION: {
682 data.enforceInterface(IActivityManager.descriptor);
683 IBinder token = data.readStrongBinder();
684 reply.writeNoException();
685 reply.writeString(getPackageForToken(token));
686 return true;
687 }
688
689 case GET_INTENT_SENDER_TRANSACTION: {
690 data.enforceInterface(IActivityManager.descriptor);
691 int type = data.readInt();
692 String packageName = data.readString();
693 IBinder token = data.readStrongBinder();
694 String resultWho = data.readString();
695 int requestCode = data.readInt();
696 Intent requestIntent = data.readInt() != 0
697 ? Intent.CREATOR.createFromParcel(data) : null;
698 String requestResolvedType = data.readString();
699 int fl = data.readInt();
700 IIntentSender res = getIntentSender(type, packageName, token,
701 resultWho, requestCode, requestIntent,
702 requestResolvedType, fl);
703 reply.writeNoException();
704 reply.writeStrongBinder(res != null ? res.asBinder() : null);
705 return true;
706 }
707
708 case CANCEL_INTENT_SENDER_TRANSACTION: {
709 data.enforceInterface(IActivityManager.descriptor);
710 IIntentSender r = IIntentSender.Stub.asInterface(
711 data.readStrongBinder());
712 cancelIntentSender(r);
713 reply.writeNoException();
714 return true;
715 }
716
717 case GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION: {
718 data.enforceInterface(IActivityManager.descriptor);
719 IIntentSender r = IIntentSender.Stub.asInterface(
720 data.readStrongBinder());
721 String res = getPackageForIntentSender(r);
722 reply.writeNoException();
723 reply.writeString(res);
724 return true;
725 }
726
727 case SET_PROCESS_LIMIT_TRANSACTION: {
728 data.enforceInterface(IActivityManager.descriptor);
729 int max = data.readInt();
730 setProcessLimit(max);
731 reply.writeNoException();
732 return true;
733 }
734
735 case GET_PROCESS_LIMIT_TRANSACTION: {
736 data.enforceInterface(IActivityManager.descriptor);
737 int limit = getProcessLimit();
738 reply.writeNoException();
739 reply.writeInt(limit);
740 return true;
741 }
742
743 case SET_PROCESS_FOREGROUND_TRANSACTION: {
744 data.enforceInterface(IActivityManager.descriptor);
745 IBinder token = data.readStrongBinder();
746 int pid = data.readInt();
747 boolean isForeground = data.readInt() != 0;
748 setProcessForeground(token, pid, isForeground);
749 reply.writeNoException();
750 return true;
751 }
752
753 case CHECK_PERMISSION_TRANSACTION: {
754 data.enforceInterface(IActivityManager.descriptor);
755 String perm = data.readString();
756 int pid = data.readInt();
757 int uid = data.readInt();
758 int res = checkPermission(perm, pid, uid);
759 reply.writeNoException();
760 reply.writeInt(res);
761 return true;
762 }
763
764 case CHECK_URI_PERMISSION_TRANSACTION: {
765 data.enforceInterface(IActivityManager.descriptor);
766 Uri uri = Uri.CREATOR.createFromParcel(data);
767 int pid = data.readInt();
768 int uid = data.readInt();
769 int mode = data.readInt();
770 int res = checkUriPermission(uri, pid, uid, mode);
771 reply.writeNoException();
772 reply.writeInt(res);
773 return true;
774 }
775
776 case CLEAR_APP_DATA_TRANSACTION: {
777 data.enforceInterface(IActivityManager.descriptor);
778 String packageName = data.readString();
779 IPackageDataObserver observer = IPackageDataObserver.Stub.asInterface(
780 data.readStrongBinder());
781 boolean res = clearApplicationUserData(packageName, observer);
782 reply.writeNoException();
783 reply.writeInt(res ? 1 : 0);
784 return true;
785 }
786
787 case GRANT_URI_PERMISSION_TRANSACTION: {
788 data.enforceInterface(IActivityManager.descriptor);
789 IBinder b = data.readStrongBinder();
790 IApplicationThread app = ApplicationThreadNative.asInterface(b);
791 String targetPkg = data.readString();
792 Uri uri = Uri.CREATOR.createFromParcel(data);
793 int mode = data.readInt();
794 grantUriPermission(app, targetPkg, uri, mode);
795 reply.writeNoException();
796 return true;
797 }
798
799 case REVOKE_URI_PERMISSION_TRANSACTION: {
800 data.enforceInterface(IActivityManager.descriptor);
801 IBinder b = data.readStrongBinder();
802 IApplicationThread app = ApplicationThreadNative.asInterface(b);
803 Uri uri = Uri.CREATOR.createFromParcel(data);
804 int mode = data.readInt();
805 revokeUriPermission(app, uri, mode);
806 reply.writeNoException();
807 return true;
808 }
809
810 case SHOW_WAITING_FOR_DEBUGGER_TRANSACTION: {
811 data.enforceInterface(IActivityManager.descriptor);
812 IBinder b = data.readStrongBinder();
813 IApplicationThread app = ApplicationThreadNative.asInterface(b);
814 boolean waiting = data.readInt() != 0;
815 showWaitingForDebugger(app, waiting);
816 reply.writeNoException();
817 return true;
818 }
819
820 case GET_MEMORY_INFO_TRANSACTION: {
821 data.enforceInterface(IActivityManager.descriptor);
822 ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
823 getMemoryInfo(mi);
824 reply.writeNoException();
825 mi.writeToParcel(reply, 0);
826 return true;
827 }
828
829 case UNHANDLED_BACK_TRANSACTION: {
830 data.enforceInterface(IActivityManager.descriptor);
831 unhandledBack();
832 reply.writeNoException();
833 return true;
834 }
835
836 case OPEN_CONTENT_URI_TRANSACTION: {
837 data.enforceInterface(IActivityManager.descriptor);
838 Uri uri = Uri.parse(data.readString());
839 ParcelFileDescriptor pfd = openContentUri(uri);
840 reply.writeNoException();
841 if (pfd != null) {
842 reply.writeInt(1);
843 pfd.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
844 } else {
845 reply.writeInt(0);
846 }
847 return true;
848 }
849
850 case GOING_TO_SLEEP_TRANSACTION: {
851 data.enforceInterface(IActivityManager.descriptor);
852 goingToSleep();
853 reply.writeNoException();
854 return true;
855 }
856
857 case WAKING_UP_TRANSACTION: {
858 data.enforceInterface(IActivityManager.descriptor);
859 wakingUp();
860 reply.writeNoException();
861 return true;
862 }
863
864 case SET_DEBUG_APP_TRANSACTION: {
865 data.enforceInterface(IActivityManager.descriptor);
866 String pn = data.readString();
867 boolean wfd = data.readInt() != 0;
868 boolean per = data.readInt() != 0;
869 setDebugApp(pn, wfd, per);
870 reply.writeNoException();
871 return true;
872 }
873
874 case SET_ALWAYS_FINISH_TRANSACTION: {
875 data.enforceInterface(IActivityManager.descriptor);
876 boolean enabled = data.readInt() != 0;
877 setAlwaysFinish(enabled);
878 reply.writeNoException();
879 return true;
880 }
881
882 case SET_ACTIVITY_WATCHER_TRANSACTION: {
883 data.enforceInterface(IActivityManager.descriptor);
884 IActivityWatcher watcher = IActivityWatcher.Stub.asInterface(
885 data.readStrongBinder());
886 setActivityWatcher(watcher);
887 return true;
888 }
889
890 case ENTER_SAFE_MODE_TRANSACTION: {
891 data.enforceInterface(IActivityManager.descriptor);
892 enterSafeMode();
893 reply.writeNoException();
894 return true;
895 }
896
897 case NOTE_WAKEUP_ALARM_TRANSACTION: {
898 data.enforceInterface(IActivityManager.descriptor);
899 IIntentSender is = IIntentSender.Stub.asInterface(
900 data.readStrongBinder());
901 noteWakeupAlarm(is);
902 reply.writeNoException();
903 return true;
904 }
905
906 case KILL_PIDS_FOR_MEMORY_TRANSACTION: {
907 data.enforceInterface(IActivityManager.descriptor);
908 int[] pids = data.createIntArray();
909 boolean res = killPidsForMemory(pids);
910 reply.writeNoException();
911 reply.writeInt(res ? 1 : 0);
912 return true;
913 }
914
915 case REPORT_PSS_TRANSACTION: {
916 data.enforceInterface(IActivityManager.descriptor);
917 IBinder b = data.readStrongBinder();
918 IApplicationThread app = ApplicationThreadNative.asInterface(b);
919 int pss = data.readInt();
920 reportPss(app, pss);
921 reply.writeNoException();
922 return true;
923 }
924
925 case START_RUNNING_TRANSACTION: {
926 data.enforceInterface(IActivityManager.descriptor);
927 String pkg = data.readString();
928 String cls = data.readString();
929 String action = data.readString();
930 String indata = data.readString();
931 startRunning(pkg, cls, action, indata);
932 reply.writeNoException();
933 return true;
934 }
935
936 case SYSTEM_READY_TRANSACTION: {
937 data.enforceInterface(IActivityManager.descriptor);
938 systemReady();
939 reply.writeNoException();
940 return true;
941 }
942
943 case HANDLE_APPLICATION_ERROR_TRANSACTION: {
944 data.enforceInterface(IActivityManager.descriptor);
945 IBinder app = data.readStrongBinder();
946 int fl = data.readInt();
947 String tag = data.readString();
948 String shortMsg = data.readString();
949 String longMsg = data.readString();
950 byte[] crashData = data.createByteArray();
951 int res = handleApplicationError(app, fl, tag, shortMsg, longMsg,
952 crashData);
953 reply.writeNoException();
954 reply.writeInt(res);
955 return true;
956 }
957
958 case SIGNAL_PERSISTENT_PROCESSES_TRANSACTION: {
959 data.enforceInterface(IActivityManager.descriptor);
960 int sig = data.readInt();
961 signalPersistentProcesses(sig);
962 reply.writeNoException();
963 return true;
964 }
965
966 case RESTART_PACKAGE_TRANSACTION: {
967 data.enforceInterface(IActivityManager.descriptor);
968 String packageName = data.readString();
969 restartPackage(packageName);
970 reply.writeNoException();
971 return true;
972 }
973
974 case GET_DEVICE_CONFIGURATION_TRANSACTION: {
975 data.enforceInterface(IActivityManager.descriptor);
976 ConfigurationInfo config = getDeviceConfigurationInfo();
977 reply.writeNoException();
978 config.writeToParcel(reply, 0);
979 return true;
980 }
981
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -0800982 case PROFILE_CONTROL_TRANSACTION: {
983 data.enforceInterface(IActivityManager.descriptor);
984 String process = data.readString();
985 boolean start = data.readInt() != 0;
986 String path = data.readString();
987 boolean res = profileControl(process, start, path);
988 reply.writeNoException();
989 reply.writeInt(res ? 1 : 0);
990 return true;
991 }
992
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800993 case PEEK_SERVICE_TRANSACTION: {
994 data.enforceInterface(IActivityManager.descriptor);
995 Intent service = Intent.CREATOR.createFromParcel(data);
996 String resolvedType = data.readString();
997 IBinder binder = peekService(service, resolvedType);
998 reply.writeNoException();
999 reply.writeStrongBinder(binder);
1000 return true;
1001 }
1002 }
1003
1004 return super.onTransact(code, data, reply, flags);
1005 }
1006
1007 public IBinder asBinder()
1008 {
1009 return this;
1010 }
1011
1012 private static IActivityManager gDefault;
1013}
1014
1015class ActivityManagerProxy implements IActivityManager
1016{
1017 public ActivityManagerProxy(IBinder remote)
1018 {
1019 mRemote = remote;
1020 }
1021
1022 public IBinder asBinder()
1023 {
1024 return mRemote;
1025 }
1026
1027 public int startActivity(IApplicationThread caller, Intent intent,
1028 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1029 IBinder resultTo, String resultWho,
1030 int requestCode, boolean onlyIfNeeded,
1031 boolean debug) throws RemoteException {
1032 Parcel data = Parcel.obtain();
1033 Parcel reply = Parcel.obtain();
1034 data.writeInterfaceToken(IActivityManager.descriptor);
1035 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1036 intent.writeToParcel(data, 0);
1037 data.writeString(resolvedType);
1038 data.writeTypedArray(grantedUriPermissions, 0);
1039 data.writeInt(grantedMode);
1040 data.writeStrongBinder(resultTo);
1041 data.writeString(resultWho);
1042 data.writeInt(requestCode);
1043 data.writeInt(onlyIfNeeded ? 1 : 0);
1044 data.writeInt(debug ? 1 : 0);
1045 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1046 reply.readException();
1047 int result = reply.readInt();
1048 reply.recycle();
1049 data.recycle();
1050 return result;
1051 }
1052 public boolean startNextMatchingActivity(IBinder callingActivity,
1053 Intent intent) throws RemoteException {
1054 Parcel data = Parcel.obtain();
1055 Parcel reply = Parcel.obtain();
1056 data.writeInterfaceToken(IActivityManager.descriptor);
1057 data.writeStrongBinder(callingActivity);
1058 intent.writeToParcel(data, 0);
1059 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1060 reply.readException();
1061 int result = reply.readInt();
1062 reply.recycle();
1063 data.recycle();
1064 return result != 0;
1065 }
1066 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1067 throws RemoteException {
1068 Parcel data = Parcel.obtain();
1069 Parcel reply = Parcel.obtain();
1070 data.writeInterfaceToken(IActivityManager.descriptor);
1071 data.writeStrongBinder(token);
1072 data.writeInt(resultCode);
1073 if (resultData != null) {
1074 data.writeInt(1);
1075 resultData.writeToParcel(data, 0);
1076 } else {
1077 data.writeInt(0);
1078 }
1079 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1080 reply.readException();
1081 boolean res = reply.readInt() != 0;
1082 data.recycle();
1083 reply.recycle();
1084 return res;
1085 }
1086 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1087 {
1088 Parcel data = Parcel.obtain();
1089 Parcel reply = Parcel.obtain();
1090 data.writeInterfaceToken(IActivityManager.descriptor);
1091 data.writeStrongBinder(token);
1092 data.writeString(resultWho);
1093 data.writeInt(requestCode);
1094 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1095 reply.readException();
1096 data.recycle();
1097 reply.recycle();
1098 }
1099 public Intent registerReceiver(IApplicationThread caller,
1100 IIntentReceiver receiver,
1101 IntentFilter filter, String perm) throws RemoteException
1102 {
1103 Parcel data = Parcel.obtain();
1104 Parcel reply = Parcel.obtain();
1105 data.writeInterfaceToken(IActivityManager.descriptor);
1106 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1107 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1108 filter.writeToParcel(data, 0);
1109 data.writeString(perm);
1110 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1111 reply.readException();
1112 Intent intent = null;
1113 int haveIntent = reply.readInt();
1114 if (haveIntent != 0) {
1115 intent = Intent.CREATOR.createFromParcel(reply);
1116 }
1117 reply.recycle();
1118 data.recycle();
1119 return intent;
1120 }
1121 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1122 {
1123 Parcel data = Parcel.obtain();
1124 Parcel reply = Parcel.obtain();
1125 data.writeInterfaceToken(IActivityManager.descriptor);
1126 data.writeStrongBinder(receiver.asBinder());
1127 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1128 reply.readException();
1129 data.recycle();
1130 reply.recycle();
1131 }
1132 public int broadcastIntent(IApplicationThread caller,
1133 Intent intent, String resolvedType, IIntentReceiver resultTo,
1134 int resultCode, String resultData, Bundle map,
1135 String requiredPermission, boolean serialized,
1136 boolean sticky) throws RemoteException
1137 {
1138 Parcel data = Parcel.obtain();
1139 Parcel reply = Parcel.obtain();
1140 data.writeInterfaceToken(IActivityManager.descriptor);
1141 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1142 intent.writeToParcel(data, 0);
1143 data.writeString(resolvedType);
1144 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1145 data.writeInt(resultCode);
1146 data.writeString(resultData);
1147 data.writeBundle(map);
1148 data.writeString(requiredPermission);
1149 data.writeInt(serialized ? 1 : 0);
1150 data.writeInt(sticky ? 1 : 0);
1151 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1152 reply.readException();
1153 int res = reply.readInt();
1154 reply.recycle();
1155 data.recycle();
1156 return res;
1157 }
1158 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1159 {
1160 Parcel data = Parcel.obtain();
1161 Parcel reply = Parcel.obtain();
1162 data.writeInterfaceToken(IActivityManager.descriptor);
1163 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1164 intent.writeToParcel(data, 0);
1165 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1166 reply.readException();
1167 data.recycle();
1168 reply.recycle();
1169 }
1170 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1171 {
1172 Parcel data = Parcel.obtain();
1173 Parcel reply = Parcel.obtain();
1174 data.writeInterfaceToken(IActivityManager.descriptor);
1175 data.writeStrongBinder(who);
1176 data.writeInt(resultCode);
1177 data.writeString(resultData);
1178 data.writeBundle(map);
1179 data.writeInt(abortBroadcast ? 1 : 0);
1180 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1181 reply.readException();
1182 data.recycle();
1183 reply.recycle();
1184 }
1185 public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
1186 {
1187 Parcel data = Parcel.obtain();
1188 Parcel reply = Parcel.obtain();
1189 data.writeInterfaceToken(IActivityManager.descriptor);
1190 data.writeStrongBinder(token);
1191 data.writeInt(isPersistent ? 1 : 0);
1192 mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
1193 reply.readException();
1194 data.recycle();
1195 reply.recycle();
1196 }
1197 public void attachApplication(IApplicationThread app) throws RemoteException
1198 {
1199 Parcel data = Parcel.obtain();
1200 Parcel reply = Parcel.obtain();
1201 data.writeInterfaceToken(IActivityManager.descriptor);
1202 data.writeStrongBinder(app.asBinder());
1203 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1204 reply.readException();
1205 data.recycle();
1206 reply.recycle();
1207 }
1208 public void activityIdle(IBinder token) throws RemoteException
1209 {
1210 Parcel data = Parcel.obtain();
1211 Parcel reply = Parcel.obtain();
1212 data.writeInterfaceToken(IActivityManager.descriptor);
1213 data.writeStrongBinder(token);
1214 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1215 reply.readException();
1216 data.recycle();
1217 reply.recycle();
1218 }
1219 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1220 {
1221 Parcel data = Parcel.obtain();
1222 Parcel reply = Parcel.obtain();
1223 data.writeInterfaceToken(IActivityManager.descriptor);
1224 data.writeStrongBinder(token);
1225 data.writeBundle(state);
1226 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1227 reply.readException();
1228 data.recycle();
1229 reply.recycle();
1230 }
1231 public void activityStopped(IBinder token,
1232 Bitmap thumbnail, CharSequence description) throws RemoteException
1233 {
1234 Parcel data = Parcel.obtain();
1235 Parcel reply = Parcel.obtain();
1236 data.writeInterfaceToken(IActivityManager.descriptor);
1237 data.writeStrongBinder(token);
1238 if (thumbnail != null) {
1239 data.writeInt(1);
1240 thumbnail.writeToParcel(data, 0);
1241 } else {
1242 data.writeInt(0);
1243 }
1244 TextUtils.writeToParcel(description, data, 0);
1245 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1246 reply.readException();
1247 data.recycle();
1248 reply.recycle();
1249 }
1250 public void activityDestroyed(IBinder token) throws RemoteException
1251 {
1252 Parcel data = Parcel.obtain();
1253 Parcel reply = Parcel.obtain();
1254 data.writeInterfaceToken(IActivityManager.descriptor);
1255 data.writeStrongBinder(token);
1256 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1257 reply.readException();
1258 data.recycle();
1259 reply.recycle();
1260 }
1261 public String getCallingPackage(IBinder token) throws RemoteException
1262 {
1263 Parcel data = Parcel.obtain();
1264 Parcel reply = Parcel.obtain();
1265 data.writeInterfaceToken(IActivityManager.descriptor);
1266 data.writeStrongBinder(token);
1267 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1268 reply.readException();
1269 String res = reply.readString();
1270 data.recycle();
1271 reply.recycle();
1272 return res;
1273 }
1274 public ComponentName getCallingActivity(IBinder token)
1275 throws RemoteException {
1276 Parcel data = Parcel.obtain();
1277 Parcel reply = Parcel.obtain();
1278 data.writeInterfaceToken(IActivityManager.descriptor);
1279 data.writeStrongBinder(token);
1280 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1281 reply.readException();
1282 ComponentName res = ComponentName.readFromParcel(reply);
1283 data.recycle();
1284 reply.recycle();
1285 return res;
1286 }
1287 public List getTasks(int maxNum, int flags,
1288 IThumbnailReceiver receiver) throws RemoteException {
1289 Parcel data = Parcel.obtain();
1290 Parcel reply = Parcel.obtain();
1291 data.writeInterfaceToken(IActivityManager.descriptor);
1292 data.writeInt(maxNum);
1293 data.writeInt(flags);
1294 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1295 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1296 reply.readException();
1297 ArrayList list = null;
1298 int N = reply.readInt();
1299 if (N >= 0) {
1300 list = new ArrayList();
1301 while (N > 0) {
1302 ActivityManager.RunningTaskInfo info =
1303 ActivityManager.RunningTaskInfo.CREATOR
1304 .createFromParcel(reply);
1305 list.add(info);
1306 N--;
1307 }
1308 }
1309 data.recycle();
1310 reply.recycle();
1311 return list;
1312 }
1313 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1314 int flags) throws RemoteException {
1315 Parcel data = Parcel.obtain();
1316 Parcel reply = Parcel.obtain();
1317 data.writeInterfaceToken(IActivityManager.descriptor);
1318 data.writeInt(maxNum);
1319 data.writeInt(flags);
1320 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1321 reply.readException();
1322 ArrayList<ActivityManager.RecentTaskInfo> list
1323 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1324 data.recycle();
1325 reply.recycle();
1326 return list;
1327 }
1328 public List getServices(int maxNum, int flags) throws RemoteException {
1329 Parcel data = Parcel.obtain();
1330 Parcel reply = Parcel.obtain();
1331 data.writeInterfaceToken(IActivityManager.descriptor);
1332 data.writeInt(maxNum);
1333 data.writeInt(flags);
1334 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1335 reply.readException();
1336 ArrayList list = null;
1337 int N = reply.readInt();
1338 if (N >= 0) {
1339 list = new ArrayList();
1340 while (N > 0) {
1341 ActivityManager.RunningServiceInfo info =
1342 ActivityManager.RunningServiceInfo.CREATOR
1343 .createFromParcel(reply);
1344 list.add(info);
1345 N--;
1346 }
1347 }
1348 data.recycle();
1349 reply.recycle();
1350 return list;
1351 }
1352 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1353 throws RemoteException {
1354 Parcel data = Parcel.obtain();
1355 Parcel reply = Parcel.obtain();
1356 data.writeInterfaceToken(IActivityManager.descriptor);
1357 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1358 reply.readException();
1359 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1360 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1361 data.recycle();
1362 reply.recycle();
1363 return list;
1364 }
1365 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1366 throws RemoteException {
1367 Parcel data = Parcel.obtain();
1368 Parcel reply = Parcel.obtain();
1369 data.writeInterfaceToken(IActivityManager.descriptor);
1370 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1371 reply.readException();
1372 ArrayList<ActivityManager.RunningAppProcessInfo> list
1373 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1374 data.recycle();
1375 reply.recycle();
1376 return list;
1377 }
1378 public void moveTaskToFront(int task) throws RemoteException
1379 {
1380 Parcel data = Parcel.obtain();
1381 Parcel reply = Parcel.obtain();
1382 data.writeInterfaceToken(IActivityManager.descriptor);
1383 data.writeInt(task);
1384 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1385 reply.readException();
1386 data.recycle();
1387 reply.recycle();
1388 }
1389 public void moveTaskToBack(int task) throws RemoteException
1390 {
1391 Parcel data = Parcel.obtain();
1392 Parcel reply = Parcel.obtain();
1393 data.writeInterfaceToken(IActivityManager.descriptor);
1394 data.writeInt(task);
1395 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1396 reply.readException();
1397 data.recycle();
1398 reply.recycle();
1399 }
1400 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1401 throws RemoteException {
1402 Parcel data = Parcel.obtain();
1403 Parcel reply = Parcel.obtain();
1404 data.writeInterfaceToken(IActivityManager.descriptor);
1405 data.writeStrongBinder(token);
1406 data.writeInt(nonRoot ? 1 : 0);
1407 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1408 reply.readException();
1409 boolean res = reply.readInt() != 0;
1410 data.recycle();
1411 reply.recycle();
1412 return res;
1413 }
1414 public void moveTaskBackwards(int task) throws RemoteException
1415 {
1416 Parcel data = Parcel.obtain();
1417 Parcel reply = Parcel.obtain();
1418 data.writeInterfaceToken(IActivityManager.descriptor);
1419 data.writeInt(task);
1420 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1421 reply.readException();
1422 data.recycle();
1423 reply.recycle();
1424 }
1425 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1426 {
1427 Parcel data = Parcel.obtain();
1428 Parcel reply = Parcel.obtain();
1429 data.writeInterfaceToken(IActivityManager.descriptor);
1430 data.writeStrongBinder(token);
1431 data.writeInt(onlyRoot ? 1 : 0);
1432 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1433 reply.readException();
1434 int res = reply.readInt();
1435 data.recycle();
1436 reply.recycle();
1437 return res;
1438 }
1439 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1440 {
1441 Parcel data = Parcel.obtain();
1442 Parcel reply = Parcel.obtain();
1443 data.writeInterfaceToken(IActivityManager.descriptor);
1444 data.writeStrongBinder(token);
1445 ComponentName.writeToParcel(className, data);
1446 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1447 reply.readException();
1448 data.recycle();
1449 reply.recycle();
1450 }
1451 public void reportThumbnail(IBinder token,
1452 Bitmap thumbnail, CharSequence description) throws RemoteException
1453 {
1454 Parcel data = Parcel.obtain();
1455 Parcel reply = Parcel.obtain();
1456 data.writeInterfaceToken(IActivityManager.descriptor);
1457 data.writeStrongBinder(token);
1458 if (thumbnail != null) {
1459 data.writeInt(1);
1460 thumbnail.writeToParcel(data, 0);
1461 } else {
1462 data.writeInt(0);
1463 }
1464 TextUtils.writeToParcel(description, data, 0);
1465 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1466 reply.readException();
1467 data.recycle();
1468 reply.recycle();
1469 }
1470 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1471 String name) throws RemoteException
1472 {
1473 Parcel data = Parcel.obtain();
1474 Parcel reply = Parcel.obtain();
1475 data.writeInterfaceToken(IActivityManager.descriptor);
1476 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1477 data.writeString(name);
1478 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1479 reply.readException();
1480 int res = reply.readInt();
1481 ContentProviderHolder cph = null;
1482 if (res != 0) {
1483 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1484 }
1485 data.recycle();
1486 reply.recycle();
1487 return cph;
1488 }
1489 public void publishContentProviders(IApplicationThread caller,
1490 List<ContentProviderHolder> providers) throws RemoteException
1491 {
1492 Parcel data = Parcel.obtain();
1493 Parcel reply = Parcel.obtain();
1494 data.writeInterfaceToken(IActivityManager.descriptor);
1495 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1496 data.writeTypedList(providers);
1497 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1498 reply.readException();
1499 data.recycle();
1500 reply.recycle();
1501 }
1502
1503 public void removeContentProvider(IApplicationThread caller,
1504 String name) throws RemoteException {
1505 Parcel data = Parcel.obtain();
1506 Parcel reply = Parcel.obtain();
1507 data.writeInterfaceToken(IActivityManager.descriptor);
1508 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1509 data.writeString(name);
1510 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1511 reply.readException();
1512 data.recycle();
1513 reply.recycle();
1514 }
1515
1516 public ComponentName startService(IApplicationThread caller, Intent service,
1517 String resolvedType) throws RemoteException
1518 {
1519 Parcel data = Parcel.obtain();
1520 Parcel reply = Parcel.obtain();
1521 data.writeInterfaceToken(IActivityManager.descriptor);
1522 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1523 service.writeToParcel(data, 0);
1524 data.writeString(resolvedType);
1525 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
1526 reply.readException();
1527 ComponentName res = ComponentName.readFromParcel(reply);
1528 data.recycle();
1529 reply.recycle();
1530 return res;
1531 }
1532 public int stopService(IApplicationThread caller, Intent service,
1533 String resolvedType) throws RemoteException
1534 {
1535 Parcel data = Parcel.obtain();
1536 Parcel reply = Parcel.obtain();
1537 data.writeInterfaceToken(IActivityManager.descriptor);
1538 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1539 service.writeToParcel(data, 0);
1540 data.writeString(resolvedType);
1541 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
1542 reply.readException();
1543 int res = reply.readInt();
1544 reply.recycle();
1545 data.recycle();
1546 return res;
1547 }
1548 public boolean stopServiceToken(ComponentName className, IBinder token,
1549 int startId) throws RemoteException {
1550 Parcel data = Parcel.obtain();
1551 Parcel reply = Parcel.obtain();
1552 data.writeInterfaceToken(IActivityManager.descriptor);
1553 ComponentName.writeToParcel(className, data);
1554 data.writeStrongBinder(token);
1555 data.writeInt(startId);
1556 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
1557 reply.readException();
1558 boolean res = reply.readInt() != 0;
1559 data.recycle();
1560 reply.recycle();
1561 return res;
1562 }
1563 public void setServiceForeground(ComponentName className, IBinder token,
1564 boolean isForeground) throws RemoteException {
1565 Parcel data = Parcel.obtain();
1566 Parcel reply = Parcel.obtain();
1567 data.writeInterfaceToken(IActivityManager.descriptor);
1568 ComponentName.writeToParcel(className, data);
1569 data.writeStrongBinder(token);
1570 data.writeInt(isForeground ? 1 : 0);
1571 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
1572 reply.readException();
1573 data.recycle();
1574 reply.recycle();
1575 }
1576 public int bindService(IApplicationThread caller, IBinder token,
1577 Intent service, String resolvedType, IServiceConnection connection,
1578 int flags) throws RemoteException {
1579 Parcel data = Parcel.obtain();
1580 Parcel reply = Parcel.obtain();
1581 data.writeInterfaceToken(IActivityManager.descriptor);
1582 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1583 data.writeStrongBinder(token);
1584 service.writeToParcel(data, 0);
1585 data.writeString(resolvedType);
1586 data.writeStrongBinder(connection.asBinder());
1587 data.writeInt(flags);
1588 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
1589 reply.readException();
1590 int res = reply.readInt();
1591 data.recycle();
1592 reply.recycle();
1593 return res;
1594 }
1595 public boolean unbindService(IServiceConnection connection) throws RemoteException
1596 {
1597 Parcel data = Parcel.obtain();
1598 Parcel reply = Parcel.obtain();
1599 data.writeInterfaceToken(IActivityManager.descriptor);
1600 data.writeStrongBinder(connection.asBinder());
1601 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
1602 reply.readException();
1603 boolean res = reply.readInt() != 0;
1604 data.recycle();
1605 reply.recycle();
1606 return res;
1607 }
1608
1609 public void publishService(IBinder token,
1610 Intent intent, IBinder service) throws RemoteException {
1611 Parcel data = Parcel.obtain();
1612 Parcel reply = Parcel.obtain();
1613 data.writeInterfaceToken(IActivityManager.descriptor);
1614 data.writeStrongBinder(token);
1615 intent.writeToParcel(data, 0);
1616 data.writeStrongBinder(service);
1617 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
1618 reply.readException();
1619 data.recycle();
1620 reply.recycle();
1621 }
1622
1623 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
1624 throws RemoteException {
1625 Parcel data = Parcel.obtain();
1626 Parcel reply = Parcel.obtain();
1627 data.writeInterfaceToken(IActivityManager.descriptor);
1628 data.writeStrongBinder(token);
1629 intent.writeToParcel(data, 0);
1630 data.writeInt(doRebind ? 1 : 0);
1631 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
1632 reply.readException();
1633 data.recycle();
1634 reply.recycle();
1635 }
1636
1637 public void serviceDoneExecuting(IBinder token) throws RemoteException {
1638 Parcel data = Parcel.obtain();
1639 Parcel reply = Parcel.obtain();
1640 data.writeInterfaceToken(IActivityManager.descriptor);
1641 data.writeStrongBinder(token);
1642 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1643 reply.readException();
1644 data.recycle();
1645 reply.recycle();
1646 }
1647
1648 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
1649 Parcel data = Parcel.obtain();
1650 Parcel reply = Parcel.obtain();
1651 data.writeInterfaceToken(IActivityManager.descriptor);
1652 service.writeToParcel(data, 0);
1653 data.writeString(resolvedType);
1654 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
1655 reply.readException();
1656 IBinder binder = reply.readStrongBinder();
1657 reply.recycle();
1658 data.recycle();
1659 return binder;
1660 }
1661
1662 public boolean startInstrumentation(ComponentName className, String profileFile,
1663 int flags, Bundle arguments, IInstrumentationWatcher watcher)
1664 throws RemoteException {
1665 Parcel data = Parcel.obtain();
1666 Parcel reply = Parcel.obtain();
1667 data.writeInterfaceToken(IActivityManager.descriptor);
1668 ComponentName.writeToParcel(className, data);
1669 data.writeString(profileFile);
1670 data.writeInt(flags);
1671 data.writeBundle(arguments);
1672 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
1673 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
1674 reply.readException();
1675 boolean res = reply.readInt() != 0;
1676 reply.recycle();
1677 data.recycle();
1678 return res;
1679 }
1680
1681 public void finishInstrumentation(IApplicationThread target,
1682 int resultCode, Bundle results) throws RemoteException {
1683 Parcel data = Parcel.obtain();
1684 Parcel reply = Parcel.obtain();
1685 data.writeInterfaceToken(IActivityManager.descriptor);
1686 data.writeStrongBinder(target != null ? target.asBinder() : null);
1687 data.writeInt(resultCode);
1688 data.writeBundle(results);
1689 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
1690 reply.readException();
1691 data.recycle();
1692 reply.recycle();
1693 }
1694 public Configuration getConfiguration() throws RemoteException
1695 {
1696 Parcel data = Parcel.obtain();
1697 Parcel reply = Parcel.obtain();
1698 data.writeInterfaceToken(IActivityManager.descriptor);
1699 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
1700 reply.readException();
1701 Configuration res = Configuration.CREATOR.createFromParcel(reply);
1702 reply.recycle();
1703 data.recycle();
1704 return res;
1705 }
1706 public void updateConfiguration(Configuration values) throws RemoteException
1707 {
1708 Parcel data = Parcel.obtain();
1709 Parcel reply = Parcel.obtain();
1710 data.writeInterfaceToken(IActivityManager.descriptor);
1711 values.writeToParcel(data, 0);
1712 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
1713 reply.readException();
1714 data.recycle();
1715 reply.recycle();
1716 }
1717 public void setRequestedOrientation(IBinder token, int requestedOrientation)
1718 throws RemoteException {
1719 Parcel data = Parcel.obtain();
1720 Parcel reply = Parcel.obtain();
1721 data.writeInterfaceToken(IActivityManager.descriptor);
1722 data.writeStrongBinder(token);
1723 data.writeInt(requestedOrientation);
1724 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
1725 reply.readException();
1726 data.recycle();
1727 reply.recycle();
1728 }
1729 public int getRequestedOrientation(IBinder token) throws RemoteException {
1730 Parcel data = Parcel.obtain();
1731 Parcel reply = Parcel.obtain();
1732 data.writeInterfaceToken(IActivityManager.descriptor);
1733 data.writeStrongBinder(token);
1734 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
1735 reply.readException();
1736 int res = reply.readInt();
1737 data.recycle();
1738 reply.recycle();
1739 return res;
1740 }
1741 public ComponentName getActivityClassForToken(IBinder token)
1742 throws RemoteException {
1743 Parcel data = Parcel.obtain();
1744 Parcel reply = Parcel.obtain();
1745 data.writeInterfaceToken(IActivityManager.descriptor);
1746 data.writeStrongBinder(token);
1747 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
1748 reply.readException();
1749 ComponentName res = ComponentName.readFromParcel(reply);
1750 data.recycle();
1751 reply.recycle();
1752 return res;
1753 }
1754 public String getPackageForToken(IBinder token) throws RemoteException
1755 {
1756 Parcel data = Parcel.obtain();
1757 Parcel reply = Parcel.obtain();
1758 data.writeInterfaceToken(IActivityManager.descriptor);
1759 data.writeStrongBinder(token);
1760 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
1761 reply.readException();
1762 String res = reply.readString();
1763 data.recycle();
1764 reply.recycle();
1765 return res;
1766 }
1767 public IIntentSender getIntentSender(int type,
1768 String packageName, IBinder token, String resultWho,
1769 int requestCode, Intent intent, String resolvedType, int flags)
1770 throws RemoteException {
1771 Parcel data = Parcel.obtain();
1772 Parcel reply = Parcel.obtain();
1773 data.writeInterfaceToken(IActivityManager.descriptor);
1774 data.writeInt(type);
1775 data.writeString(packageName);
1776 data.writeStrongBinder(token);
1777 data.writeString(resultWho);
1778 data.writeInt(requestCode);
1779 if (intent != null) {
1780 data.writeInt(1);
1781 intent.writeToParcel(data, 0);
1782 } else {
1783 data.writeInt(0);
1784 }
1785 data.writeString(resolvedType);
1786 data.writeInt(flags);
1787 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
1788 reply.readException();
1789 IIntentSender res = IIntentSender.Stub.asInterface(
1790 reply.readStrongBinder());
1791 data.recycle();
1792 reply.recycle();
1793 return res;
1794 }
1795 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
1796 Parcel data = Parcel.obtain();
1797 Parcel reply = Parcel.obtain();
1798 data.writeInterfaceToken(IActivityManager.descriptor);
1799 data.writeStrongBinder(sender.asBinder());
1800 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
1801 reply.readException();
1802 data.recycle();
1803 reply.recycle();
1804 }
1805 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
1806 Parcel data = Parcel.obtain();
1807 Parcel reply = Parcel.obtain();
1808 data.writeInterfaceToken(IActivityManager.descriptor);
1809 data.writeStrongBinder(sender.asBinder());
1810 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
1811 reply.readException();
1812 String res = reply.readString();
1813 data.recycle();
1814 reply.recycle();
1815 return res;
1816 }
1817 public void setProcessLimit(int max) throws RemoteException
1818 {
1819 Parcel data = Parcel.obtain();
1820 Parcel reply = Parcel.obtain();
1821 data.writeInterfaceToken(IActivityManager.descriptor);
1822 data.writeInt(max);
1823 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
1824 reply.readException();
1825 data.recycle();
1826 reply.recycle();
1827 }
1828 public int getProcessLimit() throws RemoteException
1829 {
1830 Parcel data = Parcel.obtain();
1831 Parcel reply = Parcel.obtain();
1832 data.writeInterfaceToken(IActivityManager.descriptor);
1833 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
1834 reply.readException();
1835 int res = reply.readInt();
1836 data.recycle();
1837 reply.recycle();
1838 return res;
1839 }
1840 public void setProcessForeground(IBinder token, int pid,
1841 boolean isForeground) throws RemoteException {
1842 Parcel data = Parcel.obtain();
1843 Parcel reply = Parcel.obtain();
1844 data.writeInterfaceToken(IActivityManager.descriptor);
1845 data.writeStrongBinder(token);
1846 data.writeInt(pid);
1847 data.writeInt(isForeground ? 1 : 0);
1848 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
1849 reply.readException();
1850 data.recycle();
1851 reply.recycle();
1852 }
1853 public int checkPermission(String permission, int pid, int uid)
1854 throws RemoteException {
1855 Parcel data = Parcel.obtain();
1856 Parcel reply = Parcel.obtain();
1857 data.writeInterfaceToken(IActivityManager.descriptor);
1858 data.writeString(permission);
1859 data.writeInt(pid);
1860 data.writeInt(uid);
1861 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
1862 reply.readException();
1863 int res = reply.readInt();
1864 data.recycle();
1865 reply.recycle();
1866 return res;
1867 }
1868 public boolean clearApplicationUserData(final String packageName,
1869 final IPackageDataObserver observer) throws RemoteException {
1870 Parcel data = Parcel.obtain();
1871 Parcel reply = Parcel.obtain();
1872 data.writeInterfaceToken(IActivityManager.descriptor);
1873 data.writeString(packageName);
1874 data.writeStrongBinder(observer.asBinder());
1875 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
1876 reply.readException();
1877 boolean res = reply.readInt() != 0;
1878 data.recycle();
1879 reply.recycle();
1880 return res;
1881 }
1882 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
1883 throws RemoteException {
1884 Parcel data = Parcel.obtain();
1885 Parcel reply = Parcel.obtain();
1886 data.writeInterfaceToken(IActivityManager.descriptor);
1887 uri.writeToParcel(data, 0);
1888 data.writeInt(pid);
1889 data.writeInt(uid);
1890 data.writeInt(mode);
1891 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
1892 reply.readException();
1893 int res = reply.readInt();
1894 data.recycle();
1895 reply.recycle();
1896 return res;
1897 }
1898 public void grantUriPermission(IApplicationThread caller, String targetPkg,
1899 Uri uri, int mode) throws RemoteException {
1900 Parcel data = Parcel.obtain();
1901 Parcel reply = Parcel.obtain();
1902 data.writeInterfaceToken(IActivityManager.descriptor);
1903 data.writeStrongBinder(caller.asBinder());
1904 data.writeString(targetPkg);
1905 uri.writeToParcel(data, 0);
1906 data.writeInt(mode);
1907 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
1908 reply.readException();
1909 data.recycle();
1910 reply.recycle();
1911 }
1912 public void revokeUriPermission(IApplicationThread caller, Uri uri,
1913 int mode) throws RemoteException {
1914 Parcel data = Parcel.obtain();
1915 Parcel reply = Parcel.obtain();
1916 data.writeInterfaceToken(IActivityManager.descriptor);
1917 data.writeStrongBinder(caller.asBinder());
1918 uri.writeToParcel(data, 0);
1919 data.writeInt(mode);
1920 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
1921 reply.readException();
1922 data.recycle();
1923 reply.recycle();
1924 }
1925 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
1926 throws RemoteException {
1927 Parcel data = Parcel.obtain();
1928 Parcel reply = Parcel.obtain();
1929 data.writeInterfaceToken(IActivityManager.descriptor);
1930 data.writeStrongBinder(who.asBinder());
1931 data.writeInt(waiting ? 1 : 0);
1932 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
1933 reply.readException();
1934 data.recycle();
1935 reply.recycle();
1936 }
1937 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
1938 Parcel data = Parcel.obtain();
1939 Parcel reply = Parcel.obtain();
1940 data.writeInterfaceToken(IActivityManager.descriptor);
1941 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
1942 reply.readException();
1943 outInfo.readFromParcel(reply);
1944 data.recycle();
1945 reply.recycle();
1946 }
1947 public void unhandledBack() throws RemoteException
1948 {
1949 Parcel data = Parcel.obtain();
1950 Parcel reply = Parcel.obtain();
1951 data.writeInterfaceToken(IActivityManager.descriptor);
1952 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
1953 reply.readException();
1954 data.recycle();
1955 reply.recycle();
1956 }
1957 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
1958 {
1959 Parcel data = Parcel.obtain();
1960 Parcel reply = Parcel.obtain();
1961 data.writeInterfaceToken(IActivityManager.descriptor);
1962 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
1963 reply.readException();
1964 ParcelFileDescriptor pfd = null;
1965 if (reply.readInt() != 0) {
1966 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
1967 }
1968 data.recycle();
1969 reply.recycle();
1970 return pfd;
1971 }
1972 public void goingToSleep() throws RemoteException
1973 {
1974 Parcel data = Parcel.obtain();
1975 Parcel reply = Parcel.obtain();
1976 data.writeInterfaceToken(IActivityManager.descriptor);
1977 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
1978 reply.readException();
1979 data.recycle();
1980 reply.recycle();
1981 }
1982 public void wakingUp() throws RemoteException
1983 {
1984 Parcel data = Parcel.obtain();
1985 Parcel reply = Parcel.obtain();
1986 data.writeInterfaceToken(IActivityManager.descriptor);
1987 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
1988 reply.readException();
1989 data.recycle();
1990 reply.recycle();
1991 }
1992 public void setDebugApp(
1993 String packageName, boolean waitForDebugger, boolean persistent)
1994 throws RemoteException
1995 {
1996 Parcel data = Parcel.obtain();
1997 Parcel reply = Parcel.obtain();
1998 data.writeInterfaceToken(IActivityManager.descriptor);
1999 data.writeString(packageName);
2000 data.writeInt(waitForDebugger ? 1 : 0);
2001 data.writeInt(persistent ? 1 : 0);
2002 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2003 reply.readException();
2004 data.recycle();
2005 reply.recycle();
2006 }
2007 public void setAlwaysFinish(boolean enabled) throws RemoteException
2008 {
2009 Parcel data = Parcel.obtain();
2010 Parcel reply = Parcel.obtain();
2011 data.writeInterfaceToken(IActivityManager.descriptor);
2012 data.writeInt(enabled ? 1 : 0);
2013 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2014 reply.readException();
2015 data.recycle();
2016 reply.recycle();
2017 }
2018 public void setActivityWatcher(IActivityWatcher watcher) throws RemoteException
2019 {
2020 Parcel data = Parcel.obtain();
2021 Parcel reply = Parcel.obtain();
2022 data.writeInterfaceToken(IActivityManager.descriptor);
2023 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2024 mRemote.transact(SET_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2025 reply.readException();
2026 data.recycle();
2027 reply.recycle();
2028 }
2029 public void enterSafeMode() throws RemoteException {
2030 Parcel data = Parcel.obtain();
2031 data.writeInterfaceToken(IActivityManager.descriptor);
2032 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2033 data.recycle();
2034 }
2035 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2036 Parcel data = Parcel.obtain();
2037 data.writeStrongBinder(sender.asBinder());
2038 data.writeInterfaceToken(IActivityManager.descriptor);
2039 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2040 data.recycle();
2041 }
2042 public boolean killPidsForMemory(int[] pids) throws RemoteException {
2043 Parcel data = Parcel.obtain();
2044 Parcel reply = Parcel.obtain();
2045 data.writeInterfaceToken(IActivityManager.descriptor);
2046 data.writeIntArray(pids);
2047 mRemote.transact(KILL_PIDS_FOR_MEMORY_TRANSACTION, data, reply, 0);
2048 boolean res = reply.readInt() != 0;
2049 data.recycle();
2050 reply.recycle();
2051 return res;
2052 }
2053 public void reportPss(IApplicationThread caller, int pss) throws RemoteException {
2054 Parcel data = Parcel.obtain();
2055 data.writeInterfaceToken(IActivityManager.descriptor);
2056 data.writeStrongBinder(caller.asBinder());
2057 data.writeInt(pss);
2058 mRemote.transact(REPORT_PSS_TRANSACTION, data, null, 0);
2059 data.recycle();
2060 }
2061 public void startRunning(String pkg, String cls, String action,
2062 String indata) throws RemoteException {
2063 Parcel data = Parcel.obtain();
2064 Parcel reply = Parcel.obtain();
2065 data.writeInterfaceToken(IActivityManager.descriptor);
2066 data.writeString(pkg);
2067 data.writeString(cls);
2068 data.writeString(action);
2069 data.writeString(indata);
2070 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2071 reply.readException();
2072 data.recycle();
2073 reply.recycle();
2074 }
2075 public void systemReady() throws RemoteException
2076 {
2077 Parcel data = Parcel.obtain();
2078 Parcel reply = Parcel.obtain();
2079 data.writeInterfaceToken(IActivityManager.descriptor);
2080 mRemote.transact(SYSTEM_READY_TRANSACTION, data, reply, 0);
2081 reply.readException();
2082 data.recycle();
2083 reply.recycle();
2084 }
2085 public boolean testIsSystemReady()
2086 {
2087 /* this base class version is never called */
2088 return true;
2089 }
2090 public int handleApplicationError(IBinder app, int flags,
2091 String tag, String shortMsg, String longMsg,
2092 byte[] crashData) throws RemoteException
2093 {
2094 Parcel data = Parcel.obtain();
2095 Parcel reply = Parcel.obtain();
2096 data.writeInterfaceToken(IActivityManager.descriptor);
2097 data.writeStrongBinder(app);
2098 data.writeInt(flags);
2099 data.writeString(tag);
2100 data.writeString(shortMsg);
2101 data.writeString(longMsg);
2102 data.writeByteArray(crashData);
2103 mRemote.transact(HANDLE_APPLICATION_ERROR_TRANSACTION, data, reply, 0);
2104 reply.readException();
2105 int res = reply.readInt();
2106 reply.recycle();
2107 data.recycle();
2108 return res;
2109 }
2110
2111 public void signalPersistentProcesses(int sig) throws RemoteException {
2112 Parcel data = Parcel.obtain();
2113 Parcel reply = Parcel.obtain();
2114 data.writeInterfaceToken(IActivityManager.descriptor);
2115 data.writeInt(sig);
2116 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2117 reply.readException();
2118 data.recycle();
2119 reply.recycle();
2120 }
2121
2122 public void restartPackage(String packageName) throws RemoteException {
2123 Parcel data = Parcel.obtain();
2124 Parcel reply = Parcel.obtain();
2125 data.writeInterfaceToken(IActivityManager.descriptor);
2126 data.writeString(packageName);
2127 mRemote.transact(RESTART_PACKAGE_TRANSACTION, data, reply, 0);
2128 reply.readException();
2129 data.recycle();
2130 reply.recycle();
2131 }
2132
2133 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2134 {
2135 Parcel data = Parcel.obtain();
2136 Parcel reply = Parcel.obtain();
2137 data.writeInterfaceToken(IActivityManager.descriptor);
2138 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2139 reply.readException();
2140 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2141 reply.recycle();
2142 data.recycle();
2143 return res;
2144 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002145
2146 public boolean profileControl(String process, boolean start,
2147 String path) throws RemoteException
2148 {
2149 Parcel data = Parcel.obtain();
2150 Parcel reply = Parcel.obtain();
2151 data.writeInterfaceToken(IActivityManager.descriptor);
2152 data.writeString(process);
2153 data.writeInt(start ? 1 : 0);
2154 data.writeString(path);
2155 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2156 reply.readException();
2157 boolean res = reply.readInt() != 0;
2158 reply.recycle();
2159 data.recycle();
2160 return res;
2161 }
2162
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002163 private IBinder mRemote;
2164}