blob: 541f413676c8530215344b521f4cff90b0465f5f [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
Dianne Hackborn55280a92009-05-07 15:53:46 -0700993 case SHUTDOWN_TRANSACTION: {
994 data.enforceInterface(IActivityManager.descriptor);
995 boolean res = shutdown(data.readInt());
996 reply.writeNoException();
997 reply.writeInt(res ? 1 : 0);
998 return true;
999 }
1000
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001001 case PEEK_SERVICE_TRANSACTION: {
1002 data.enforceInterface(IActivityManager.descriptor);
1003 Intent service = Intent.CREATOR.createFromParcel(data);
1004 String resolvedType = data.readString();
1005 IBinder binder = peekService(service, resolvedType);
1006 reply.writeNoException();
1007 reply.writeStrongBinder(binder);
1008 return true;
1009 }
1010 }
1011
1012 return super.onTransact(code, data, reply, flags);
1013 }
1014
1015 public IBinder asBinder()
1016 {
1017 return this;
1018 }
1019
1020 private static IActivityManager gDefault;
1021}
1022
1023class ActivityManagerProxy implements IActivityManager
1024{
1025 public ActivityManagerProxy(IBinder remote)
1026 {
1027 mRemote = remote;
1028 }
1029
1030 public IBinder asBinder()
1031 {
1032 return mRemote;
1033 }
1034
1035 public int startActivity(IApplicationThread caller, Intent intent,
1036 String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
1037 IBinder resultTo, String resultWho,
1038 int requestCode, boolean onlyIfNeeded,
1039 boolean debug) throws RemoteException {
1040 Parcel data = Parcel.obtain();
1041 Parcel reply = Parcel.obtain();
1042 data.writeInterfaceToken(IActivityManager.descriptor);
1043 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1044 intent.writeToParcel(data, 0);
1045 data.writeString(resolvedType);
1046 data.writeTypedArray(grantedUriPermissions, 0);
1047 data.writeInt(grantedMode);
1048 data.writeStrongBinder(resultTo);
1049 data.writeString(resultWho);
1050 data.writeInt(requestCode);
1051 data.writeInt(onlyIfNeeded ? 1 : 0);
1052 data.writeInt(debug ? 1 : 0);
1053 mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
1054 reply.readException();
1055 int result = reply.readInt();
1056 reply.recycle();
1057 data.recycle();
1058 return result;
1059 }
1060 public boolean startNextMatchingActivity(IBinder callingActivity,
1061 Intent intent) throws RemoteException {
1062 Parcel data = Parcel.obtain();
1063 Parcel reply = Parcel.obtain();
1064 data.writeInterfaceToken(IActivityManager.descriptor);
1065 data.writeStrongBinder(callingActivity);
1066 intent.writeToParcel(data, 0);
1067 mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
1068 reply.readException();
1069 int result = reply.readInt();
1070 reply.recycle();
1071 data.recycle();
1072 return result != 0;
1073 }
1074 public boolean finishActivity(IBinder token, int resultCode, Intent resultData)
1075 throws RemoteException {
1076 Parcel data = Parcel.obtain();
1077 Parcel reply = Parcel.obtain();
1078 data.writeInterfaceToken(IActivityManager.descriptor);
1079 data.writeStrongBinder(token);
1080 data.writeInt(resultCode);
1081 if (resultData != null) {
1082 data.writeInt(1);
1083 resultData.writeToParcel(data, 0);
1084 } else {
1085 data.writeInt(0);
1086 }
1087 mRemote.transact(FINISH_ACTIVITY_TRANSACTION, data, reply, 0);
1088 reply.readException();
1089 boolean res = reply.readInt() != 0;
1090 data.recycle();
1091 reply.recycle();
1092 return res;
1093 }
1094 public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException
1095 {
1096 Parcel data = Parcel.obtain();
1097 Parcel reply = Parcel.obtain();
1098 data.writeInterfaceToken(IActivityManager.descriptor);
1099 data.writeStrongBinder(token);
1100 data.writeString(resultWho);
1101 data.writeInt(requestCode);
1102 mRemote.transact(FINISH_SUB_ACTIVITY_TRANSACTION, data, reply, 0);
1103 reply.readException();
1104 data.recycle();
1105 reply.recycle();
1106 }
1107 public Intent registerReceiver(IApplicationThread caller,
1108 IIntentReceiver receiver,
1109 IntentFilter filter, String perm) throws RemoteException
1110 {
1111 Parcel data = Parcel.obtain();
1112 Parcel reply = Parcel.obtain();
1113 data.writeInterfaceToken(IActivityManager.descriptor);
1114 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1115 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1116 filter.writeToParcel(data, 0);
1117 data.writeString(perm);
1118 mRemote.transact(REGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1119 reply.readException();
1120 Intent intent = null;
1121 int haveIntent = reply.readInt();
1122 if (haveIntent != 0) {
1123 intent = Intent.CREATOR.createFromParcel(reply);
1124 }
1125 reply.recycle();
1126 data.recycle();
1127 return intent;
1128 }
1129 public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException
1130 {
1131 Parcel data = Parcel.obtain();
1132 Parcel reply = Parcel.obtain();
1133 data.writeInterfaceToken(IActivityManager.descriptor);
1134 data.writeStrongBinder(receiver.asBinder());
1135 mRemote.transact(UNREGISTER_RECEIVER_TRANSACTION, data, reply, 0);
1136 reply.readException();
1137 data.recycle();
1138 reply.recycle();
1139 }
1140 public int broadcastIntent(IApplicationThread caller,
1141 Intent intent, String resolvedType, IIntentReceiver resultTo,
1142 int resultCode, String resultData, Bundle map,
1143 String requiredPermission, boolean serialized,
1144 boolean sticky) throws RemoteException
1145 {
1146 Parcel data = Parcel.obtain();
1147 Parcel reply = Parcel.obtain();
1148 data.writeInterfaceToken(IActivityManager.descriptor);
1149 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1150 intent.writeToParcel(data, 0);
1151 data.writeString(resolvedType);
1152 data.writeStrongBinder(resultTo != null ? resultTo.asBinder() : null);
1153 data.writeInt(resultCode);
1154 data.writeString(resultData);
1155 data.writeBundle(map);
1156 data.writeString(requiredPermission);
1157 data.writeInt(serialized ? 1 : 0);
1158 data.writeInt(sticky ? 1 : 0);
1159 mRemote.transact(BROADCAST_INTENT_TRANSACTION, data, reply, 0);
1160 reply.readException();
1161 int res = reply.readInt();
1162 reply.recycle();
1163 data.recycle();
1164 return res;
1165 }
1166 public void unbroadcastIntent(IApplicationThread caller, Intent intent) throws RemoteException
1167 {
1168 Parcel data = Parcel.obtain();
1169 Parcel reply = Parcel.obtain();
1170 data.writeInterfaceToken(IActivityManager.descriptor);
1171 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1172 intent.writeToParcel(data, 0);
1173 mRemote.transact(UNBROADCAST_INTENT_TRANSACTION, data, reply, 0);
1174 reply.readException();
1175 data.recycle();
1176 reply.recycle();
1177 }
1178 public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
1179 {
1180 Parcel data = Parcel.obtain();
1181 Parcel reply = Parcel.obtain();
1182 data.writeInterfaceToken(IActivityManager.descriptor);
1183 data.writeStrongBinder(who);
1184 data.writeInt(resultCode);
1185 data.writeString(resultData);
1186 data.writeBundle(map);
1187 data.writeInt(abortBroadcast ? 1 : 0);
1188 mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1189 reply.readException();
1190 data.recycle();
1191 reply.recycle();
1192 }
1193 public void setPersistent(IBinder token, boolean isPersistent) throws RemoteException
1194 {
1195 Parcel data = Parcel.obtain();
1196 Parcel reply = Parcel.obtain();
1197 data.writeInterfaceToken(IActivityManager.descriptor);
1198 data.writeStrongBinder(token);
1199 data.writeInt(isPersistent ? 1 : 0);
1200 mRemote.transact(SET_PERSISTENT_TRANSACTION, data, reply, 0);
1201 reply.readException();
1202 data.recycle();
1203 reply.recycle();
1204 }
1205 public void attachApplication(IApplicationThread app) throws RemoteException
1206 {
1207 Parcel data = Parcel.obtain();
1208 Parcel reply = Parcel.obtain();
1209 data.writeInterfaceToken(IActivityManager.descriptor);
1210 data.writeStrongBinder(app.asBinder());
1211 mRemote.transact(ATTACH_APPLICATION_TRANSACTION, data, reply, 0);
1212 reply.readException();
1213 data.recycle();
1214 reply.recycle();
1215 }
1216 public void activityIdle(IBinder token) throws RemoteException
1217 {
1218 Parcel data = Parcel.obtain();
1219 Parcel reply = Parcel.obtain();
1220 data.writeInterfaceToken(IActivityManager.descriptor);
1221 data.writeStrongBinder(token);
1222 mRemote.transact(ACTIVITY_IDLE_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1223 reply.readException();
1224 data.recycle();
1225 reply.recycle();
1226 }
1227 public void activityPaused(IBinder token, Bundle state) throws RemoteException
1228 {
1229 Parcel data = Parcel.obtain();
1230 Parcel reply = Parcel.obtain();
1231 data.writeInterfaceToken(IActivityManager.descriptor);
1232 data.writeStrongBinder(token);
1233 data.writeBundle(state);
1234 mRemote.transact(ACTIVITY_PAUSED_TRANSACTION, data, reply, 0);
1235 reply.readException();
1236 data.recycle();
1237 reply.recycle();
1238 }
1239 public void activityStopped(IBinder token,
1240 Bitmap thumbnail, CharSequence description) throws RemoteException
1241 {
1242 Parcel data = Parcel.obtain();
1243 Parcel reply = Parcel.obtain();
1244 data.writeInterfaceToken(IActivityManager.descriptor);
1245 data.writeStrongBinder(token);
1246 if (thumbnail != null) {
1247 data.writeInt(1);
1248 thumbnail.writeToParcel(data, 0);
1249 } else {
1250 data.writeInt(0);
1251 }
1252 TextUtils.writeToParcel(description, data, 0);
1253 mRemote.transact(ACTIVITY_STOPPED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1254 reply.readException();
1255 data.recycle();
1256 reply.recycle();
1257 }
1258 public void activityDestroyed(IBinder token) throws RemoteException
1259 {
1260 Parcel data = Parcel.obtain();
1261 Parcel reply = Parcel.obtain();
1262 data.writeInterfaceToken(IActivityManager.descriptor);
1263 data.writeStrongBinder(token);
1264 mRemote.transact(ACTIVITY_DESTROYED_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1265 reply.readException();
1266 data.recycle();
1267 reply.recycle();
1268 }
1269 public String getCallingPackage(IBinder token) throws RemoteException
1270 {
1271 Parcel data = Parcel.obtain();
1272 Parcel reply = Parcel.obtain();
1273 data.writeInterfaceToken(IActivityManager.descriptor);
1274 data.writeStrongBinder(token);
1275 mRemote.transact(GET_CALLING_PACKAGE_TRANSACTION, data, reply, 0);
1276 reply.readException();
1277 String res = reply.readString();
1278 data.recycle();
1279 reply.recycle();
1280 return res;
1281 }
1282 public ComponentName getCallingActivity(IBinder token)
1283 throws RemoteException {
1284 Parcel data = Parcel.obtain();
1285 Parcel reply = Parcel.obtain();
1286 data.writeInterfaceToken(IActivityManager.descriptor);
1287 data.writeStrongBinder(token);
1288 mRemote.transact(GET_CALLING_ACTIVITY_TRANSACTION, data, reply, 0);
1289 reply.readException();
1290 ComponentName res = ComponentName.readFromParcel(reply);
1291 data.recycle();
1292 reply.recycle();
1293 return res;
1294 }
1295 public List getTasks(int maxNum, int flags,
1296 IThumbnailReceiver receiver) throws RemoteException {
1297 Parcel data = Parcel.obtain();
1298 Parcel reply = Parcel.obtain();
1299 data.writeInterfaceToken(IActivityManager.descriptor);
1300 data.writeInt(maxNum);
1301 data.writeInt(flags);
1302 data.writeStrongBinder(receiver != null ? receiver.asBinder() : null);
1303 mRemote.transact(GET_TASKS_TRANSACTION, data, reply, 0);
1304 reply.readException();
1305 ArrayList list = null;
1306 int N = reply.readInt();
1307 if (N >= 0) {
1308 list = new ArrayList();
1309 while (N > 0) {
1310 ActivityManager.RunningTaskInfo info =
1311 ActivityManager.RunningTaskInfo.CREATOR
1312 .createFromParcel(reply);
1313 list.add(info);
1314 N--;
1315 }
1316 }
1317 data.recycle();
1318 reply.recycle();
1319 return list;
1320 }
1321 public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,
1322 int flags) throws RemoteException {
1323 Parcel data = Parcel.obtain();
1324 Parcel reply = Parcel.obtain();
1325 data.writeInterfaceToken(IActivityManager.descriptor);
1326 data.writeInt(maxNum);
1327 data.writeInt(flags);
1328 mRemote.transact(GET_RECENT_TASKS_TRANSACTION, data, reply, 0);
1329 reply.readException();
1330 ArrayList<ActivityManager.RecentTaskInfo> list
1331 = reply.createTypedArrayList(ActivityManager.RecentTaskInfo.CREATOR);
1332 data.recycle();
1333 reply.recycle();
1334 return list;
1335 }
1336 public List getServices(int maxNum, int flags) throws RemoteException {
1337 Parcel data = Parcel.obtain();
1338 Parcel reply = Parcel.obtain();
1339 data.writeInterfaceToken(IActivityManager.descriptor);
1340 data.writeInt(maxNum);
1341 data.writeInt(flags);
1342 mRemote.transact(GET_SERVICES_TRANSACTION, data, reply, 0);
1343 reply.readException();
1344 ArrayList list = null;
1345 int N = reply.readInt();
1346 if (N >= 0) {
1347 list = new ArrayList();
1348 while (N > 0) {
1349 ActivityManager.RunningServiceInfo info =
1350 ActivityManager.RunningServiceInfo.CREATOR
1351 .createFromParcel(reply);
1352 list.add(info);
1353 N--;
1354 }
1355 }
1356 data.recycle();
1357 reply.recycle();
1358 return list;
1359 }
1360 public List<ActivityManager.ProcessErrorStateInfo> getProcessesInErrorState()
1361 throws RemoteException {
1362 Parcel data = Parcel.obtain();
1363 Parcel reply = Parcel.obtain();
1364 data.writeInterfaceToken(IActivityManager.descriptor);
1365 mRemote.transact(GET_PROCESSES_IN_ERROR_STATE_TRANSACTION, data, reply, 0);
1366 reply.readException();
1367 ArrayList<ActivityManager.ProcessErrorStateInfo> list
1368 = reply.createTypedArrayList(ActivityManager.ProcessErrorStateInfo.CREATOR);
1369 data.recycle();
1370 reply.recycle();
1371 return list;
1372 }
1373 public List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses()
1374 throws RemoteException {
1375 Parcel data = Parcel.obtain();
1376 Parcel reply = Parcel.obtain();
1377 data.writeInterfaceToken(IActivityManager.descriptor);
1378 mRemote.transact(GET_RUNNING_APP_PROCESSES_TRANSACTION, data, reply, 0);
1379 reply.readException();
1380 ArrayList<ActivityManager.RunningAppProcessInfo> list
1381 = reply.createTypedArrayList(ActivityManager.RunningAppProcessInfo.CREATOR);
1382 data.recycle();
1383 reply.recycle();
1384 return list;
1385 }
1386 public void moveTaskToFront(int task) throws RemoteException
1387 {
1388 Parcel data = Parcel.obtain();
1389 Parcel reply = Parcel.obtain();
1390 data.writeInterfaceToken(IActivityManager.descriptor);
1391 data.writeInt(task);
1392 mRemote.transact(MOVE_TASK_TO_FRONT_TRANSACTION, data, reply, 0);
1393 reply.readException();
1394 data.recycle();
1395 reply.recycle();
1396 }
1397 public void moveTaskToBack(int task) throws RemoteException
1398 {
1399 Parcel data = Parcel.obtain();
1400 Parcel reply = Parcel.obtain();
1401 data.writeInterfaceToken(IActivityManager.descriptor);
1402 data.writeInt(task);
1403 mRemote.transact(MOVE_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1404 reply.readException();
1405 data.recycle();
1406 reply.recycle();
1407 }
1408 public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot)
1409 throws RemoteException {
1410 Parcel data = Parcel.obtain();
1411 Parcel reply = Parcel.obtain();
1412 data.writeInterfaceToken(IActivityManager.descriptor);
1413 data.writeStrongBinder(token);
1414 data.writeInt(nonRoot ? 1 : 0);
1415 mRemote.transact(MOVE_ACTIVITY_TASK_TO_BACK_TRANSACTION, data, reply, 0);
1416 reply.readException();
1417 boolean res = reply.readInt() != 0;
1418 data.recycle();
1419 reply.recycle();
1420 return res;
1421 }
1422 public void moveTaskBackwards(int task) throws RemoteException
1423 {
1424 Parcel data = Parcel.obtain();
1425 Parcel reply = Parcel.obtain();
1426 data.writeInterfaceToken(IActivityManager.descriptor);
1427 data.writeInt(task);
1428 mRemote.transact(MOVE_TASK_BACKWARDS_TRANSACTION, data, reply, 0);
1429 reply.readException();
1430 data.recycle();
1431 reply.recycle();
1432 }
1433 public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException
1434 {
1435 Parcel data = Parcel.obtain();
1436 Parcel reply = Parcel.obtain();
1437 data.writeInterfaceToken(IActivityManager.descriptor);
1438 data.writeStrongBinder(token);
1439 data.writeInt(onlyRoot ? 1 : 0);
1440 mRemote.transact(GET_TASK_FOR_ACTIVITY_TRANSACTION, data, reply, 0);
1441 reply.readException();
1442 int res = reply.readInt();
1443 data.recycle();
1444 reply.recycle();
1445 return res;
1446 }
1447 public void finishOtherInstances(IBinder token, ComponentName className) throws RemoteException
1448 {
1449 Parcel data = Parcel.obtain();
1450 Parcel reply = Parcel.obtain();
1451 data.writeInterfaceToken(IActivityManager.descriptor);
1452 data.writeStrongBinder(token);
1453 ComponentName.writeToParcel(className, data);
1454 mRemote.transact(FINISH_OTHER_INSTANCES_TRANSACTION, data, reply, 0);
1455 reply.readException();
1456 data.recycle();
1457 reply.recycle();
1458 }
1459 public void reportThumbnail(IBinder token,
1460 Bitmap thumbnail, CharSequence description) throws RemoteException
1461 {
1462 Parcel data = Parcel.obtain();
1463 Parcel reply = Parcel.obtain();
1464 data.writeInterfaceToken(IActivityManager.descriptor);
1465 data.writeStrongBinder(token);
1466 if (thumbnail != null) {
1467 data.writeInt(1);
1468 thumbnail.writeToParcel(data, 0);
1469 } else {
1470 data.writeInt(0);
1471 }
1472 TextUtils.writeToParcel(description, data, 0);
1473 mRemote.transact(REPORT_THUMBNAIL_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1474 reply.readException();
1475 data.recycle();
1476 reply.recycle();
1477 }
1478 public ContentProviderHolder getContentProvider(IApplicationThread caller,
1479 String name) throws RemoteException
1480 {
1481 Parcel data = Parcel.obtain();
1482 Parcel reply = Parcel.obtain();
1483 data.writeInterfaceToken(IActivityManager.descriptor);
1484 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1485 data.writeString(name);
1486 mRemote.transact(GET_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1487 reply.readException();
1488 int res = reply.readInt();
1489 ContentProviderHolder cph = null;
1490 if (res != 0) {
1491 cph = ContentProviderHolder.CREATOR.createFromParcel(reply);
1492 }
1493 data.recycle();
1494 reply.recycle();
1495 return cph;
1496 }
1497 public void publishContentProviders(IApplicationThread caller,
1498 List<ContentProviderHolder> providers) throws RemoteException
1499 {
1500 Parcel data = Parcel.obtain();
1501 Parcel reply = Parcel.obtain();
1502 data.writeInterfaceToken(IActivityManager.descriptor);
1503 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1504 data.writeTypedList(providers);
1505 mRemote.transact(PUBLISH_CONTENT_PROVIDERS_TRANSACTION, data, reply, 0);
1506 reply.readException();
1507 data.recycle();
1508 reply.recycle();
1509 }
1510
1511 public void removeContentProvider(IApplicationThread caller,
1512 String name) throws RemoteException {
1513 Parcel data = Parcel.obtain();
1514 Parcel reply = Parcel.obtain();
1515 data.writeInterfaceToken(IActivityManager.descriptor);
1516 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1517 data.writeString(name);
1518 mRemote.transact(REMOVE_CONTENT_PROVIDER_TRANSACTION, data, reply, 0);
1519 reply.readException();
1520 data.recycle();
1521 reply.recycle();
1522 }
1523
1524 public ComponentName startService(IApplicationThread caller, Intent service,
1525 String resolvedType) throws RemoteException
1526 {
1527 Parcel data = Parcel.obtain();
1528 Parcel reply = Parcel.obtain();
1529 data.writeInterfaceToken(IActivityManager.descriptor);
1530 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1531 service.writeToParcel(data, 0);
1532 data.writeString(resolvedType);
1533 mRemote.transact(START_SERVICE_TRANSACTION, data, reply, 0);
1534 reply.readException();
1535 ComponentName res = ComponentName.readFromParcel(reply);
1536 data.recycle();
1537 reply.recycle();
1538 return res;
1539 }
1540 public int stopService(IApplicationThread caller, Intent service,
1541 String resolvedType) throws RemoteException
1542 {
1543 Parcel data = Parcel.obtain();
1544 Parcel reply = Parcel.obtain();
1545 data.writeInterfaceToken(IActivityManager.descriptor);
1546 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1547 service.writeToParcel(data, 0);
1548 data.writeString(resolvedType);
1549 mRemote.transact(STOP_SERVICE_TRANSACTION, data, reply, 0);
1550 reply.readException();
1551 int res = reply.readInt();
1552 reply.recycle();
1553 data.recycle();
1554 return res;
1555 }
1556 public boolean stopServiceToken(ComponentName className, IBinder token,
1557 int startId) throws RemoteException {
1558 Parcel data = Parcel.obtain();
1559 Parcel reply = Parcel.obtain();
1560 data.writeInterfaceToken(IActivityManager.descriptor);
1561 ComponentName.writeToParcel(className, data);
1562 data.writeStrongBinder(token);
1563 data.writeInt(startId);
1564 mRemote.transact(STOP_SERVICE_TOKEN_TRANSACTION, data, reply, 0);
1565 reply.readException();
1566 boolean res = reply.readInt() != 0;
1567 data.recycle();
1568 reply.recycle();
1569 return res;
1570 }
1571 public void setServiceForeground(ComponentName className, IBinder token,
1572 boolean isForeground) throws RemoteException {
1573 Parcel data = Parcel.obtain();
1574 Parcel reply = Parcel.obtain();
1575 data.writeInterfaceToken(IActivityManager.descriptor);
1576 ComponentName.writeToParcel(className, data);
1577 data.writeStrongBinder(token);
1578 data.writeInt(isForeground ? 1 : 0);
1579 mRemote.transact(SET_SERVICE_FOREGROUND_TRANSACTION, data, reply, 0);
1580 reply.readException();
1581 data.recycle();
1582 reply.recycle();
1583 }
1584 public int bindService(IApplicationThread caller, IBinder token,
1585 Intent service, String resolvedType, IServiceConnection connection,
1586 int flags) throws RemoteException {
1587 Parcel data = Parcel.obtain();
1588 Parcel reply = Parcel.obtain();
1589 data.writeInterfaceToken(IActivityManager.descriptor);
1590 data.writeStrongBinder(caller != null ? caller.asBinder() : null);
1591 data.writeStrongBinder(token);
1592 service.writeToParcel(data, 0);
1593 data.writeString(resolvedType);
1594 data.writeStrongBinder(connection.asBinder());
1595 data.writeInt(flags);
1596 mRemote.transact(BIND_SERVICE_TRANSACTION, data, reply, 0);
1597 reply.readException();
1598 int res = reply.readInt();
1599 data.recycle();
1600 reply.recycle();
1601 return res;
1602 }
1603 public boolean unbindService(IServiceConnection connection) throws RemoteException
1604 {
1605 Parcel data = Parcel.obtain();
1606 Parcel reply = Parcel.obtain();
1607 data.writeInterfaceToken(IActivityManager.descriptor);
1608 data.writeStrongBinder(connection.asBinder());
1609 mRemote.transact(UNBIND_SERVICE_TRANSACTION, data, reply, 0);
1610 reply.readException();
1611 boolean res = reply.readInt() != 0;
1612 data.recycle();
1613 reply.recycle();
1614 return res;
1615 }
1616
1617 public void publishService(IBinder token,
1618 Intent intent, IBinder service) throws RemoteException {
1619 Parcel data = Parcel.obtain();
1620 Parcel reply = Parcel.obtain();
1621 data.writeInterfaceToken(IActivityManager.descriptor);
1622 data.writeStrongBinder(token);
1623 intent.writeToParcel(data, 0);
1624 data.writeStrongBinder(service);
1625 mRemote.transact(PUBLISH_SERVICE_TRANSACTION, data, reply, 0);
1626 reply.readException();
1627 data.recycle();
1628 reply.recycle();
1629 }
1630
1631 public void unbindFinished(IBinder token, Intent intent, boolean doRebind)
1632 throws RemoteException {
1633 Parcel data = Parcel.obtain();
1634 Parcel reply = Parcel.obtain();
1635 data.writeInterfaceToken(IActivityManager.descriptor);
1636 data.writeStrongBinder(token);
1637 intent.writeToParcel(data, 0);
1638 data.writeInt(doRebind ? 1 : 0);
1639 mRemote.transact(UNBIND_FINISHED_TRANSACTION, data, reply, 0);
1640 reply.readException();
1641 data.recycle();
1642 reply.recycle();
1643 }
1644
1645 public void serviceDoneExecuting(IBinder token) throws RemoteException {
1646 Parcel data = Parcel.obtain();
1647 Parcel reply = Parcel.obtain();
1648 data.writeInterfaceToken(IActivityManager.descriptor);
1649 data.writeStrongBinder(token);
1650 mRemote.transact(SERVICE_DONE_EXECUTING_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
1651 reply.readException();
1652 data.recycle();
1653 reply.recycle();
1654 }
1655
1656 public IBinder peekService(Intent service, String resolvedType) throws RemoteException {
1657 Parcel data = Parcel.obtain();
1658 Parcel reply = Parcel.obtain();
1659 data.writeInterfaceToken(IActivityManager.descriptor);
1660 service.writeToParcel(data, 0);
1661 data.writeString(resolvedType);
1662 mRemote.transact(PEEK_SERVICE_TRANSACTION, data, reply, 0);
1663 reply.readException();
1664 IBinder binder = reply.readStrongBinder();
1665 reply.recycle();
1666 data.recycle();
1667 return binder;
1668 }
1669
1670 public boolean startInstrumentation(ComponentName className, String profileFile,
1671 int flags, Bundle arguments, IInstrumentationWatcher watcher)
1672 throws RemoteException {
1673 Parcel data = Parcel.obtain();
1674 Parcel reply = Parcel.obtain();
1675 data.writeInterfaceToken(IActivityManager.descriptor);
1676 ComponentName.writeToParcel(className, data);
1677 data.writeString(profileFile);
1678 data.writeInt(flags);
1679 data.writeBundle(arguments);
1680 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
1681 mRemote.transact(START_INSTRUMENTATION_TRANSACTION, data, reply, 0);
1682 reply.readException();
1683 boolean res = reply.readInt() != 0;
1684 reply.recycle();
1685 data.recycle();
1686 return res;
1687 }
1688
1689 public void finishInstrumentation(IApplicationThread target,
1690 int resultCode, Bundle results) throws RemoteException {
1691 Parcel data = Parcel.obtain();
1692 Parcel reply = Parcel.obtain();
1693 data.writeInterfaceToken(IActivityManager.descriptor);
1694 data.writeStrongBinder(target != null ? target.asBinder() : null);
1695 data.writeInt(resultCode);
1696 data.writeBundle(results);
1697 mRemote.transact(FINISH_INSTRUMENTATION_TRANSACTION, data, reply, 0);
1698 reply.readException();
1699 data.recycle();
1700 reply.recycle();
1701 }
1702 public Configuration getConfiguration() throws RemoteException
1703 {
1704 Parcel data = Parcel.obtain();
1705 Parcel reply = Parcel.obtain();
1706 data.writeInterfaceToken(IActivityManager.descriptor);
1707 mRemote.transact(GET_CONFIGURATION_TRANSACTION, data, reply, 0);
1708 reply.readException();
1709 Configuration res = Configuration.CREATOR.createFromParcel(reply);
1710 reply.recycle();
1711 data.recycle();
1712 return res;
1713 }
1714 public void updateConfiguration(Configuration values) throws RemoteException
1715 {
1716 Parcel data = Parcel.obtain();
1717 Parcel reply = Parcel.obtain();
1718 data.writeInterfaceToken(IActivityManager.descriptor);
1719 values.writeToParcel(data, 0);
1720 mRemote.transact(UPDATE_CONFIGURATION_TRANSACTION, data, reply, 0);
1721 reply.readException();
1722 data.recycle();
1723 reply.recycle();
1724 }
1725 public void setRequestedOrientation(IBinder token, int requestedOrientation)
1726 throws RemoteException {
1727 Parcel data = Parcel.obtain();
1728 Parcel reply = Parcel.obtain();
1729 data.writeInterfaceToken(IActivityManager.descriptor);
1730 data.writeStrongBinder(token);
1731 data.writeInt(requestedOrientation);
1732 mRemote.transact(SET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
1733 reply.readException();
1734 data.recycle();
1735 reply.recycle();
1736 }
1737 public int getRequestedOrientation(IBinder token) throws RemoteException {
1738 Parcel data = Parcel.obtain();
1739 Parcel reply = Parcel.obtain();
1740 data.writeInterfaceToken(IActivityManager.descriptor);
1741 data.writeStrongBinder(token);
1742 mRemote.transact(GET_REQUESTED_ORIENTATION_TRANSACTION, data, reply, 0);
1743 reply.readException();
1744 int res = reply.readInt();
1745 data.recycle();
1746 reply.recycle();
1747 return res;
1748 }
1749 public ComponentName getActivityClassForToken(IBinder token)
1750 throws RemoteException {
1751 Parcel data = Parcel.obtain();
1752 Parcel reply = Parcel.obtain();
1753 data.writeInterfaceToken(IActivityManager.descriptor);
1754 data.writeStrongBinder(token);
1755 mRemote.transact(GET_ACTIVITY_CLASS_FOR_TOKEN_TRANSACTION, data, reply, 0);
1756 reply.readException();
1757 ComponentName res = ComponentName.readFromParcel(reply);
1758 data.recycle();
1759 reply.recycle();
1760 return res;
1761 }
1762 public String getPackageForToken(IBinder token) throws RemoteException
1763 {
1764 Parcel data = Parcel.obtain();
1765 Parcel reply = Parcel.obtain();
1766 data.writeInterfaceToken(IActivityManager.descriptor);
1767 data.writeStrongBinder(token);
1768 mRemote.transact(GET_PACKAGE_FOR_TOKEN_TRANSACTION, data, reply, 0);
1769 reply.readException();
1770 String res = reply.readString();
1771 data.recycle();
1772 reply.recycle();
1773 return res;
1774 }
1775 public IIntentSender getIntentSender(int type,
1776 String packageName, IBinder token, String resultWho,
1777 int requestCode, Intent intent, String resolvedType, int flags)
1778 throws RemoteException {
1779 Parcel data = Parcel.obtain();
1780 Parcel reply = Parcel.obtain();
1781 data.writeInterfaceToken(IActivityManager.descriptor);
1782 data.writeInt(type);
1783 data.writeString(packageName);
1784 data.writeStrongBinder(token);
1785 data.writeString(resultWho);
1786 data.writeInt(requestCode);
1787 if (intent != null) {
1788 data.writeInt(1);
1789 intent.writeToParcel(data, 0);
1790 } else {
1791 data.writeInt(0);
1792 }
1793 data.writeString(resolvedType);
1794 data.writeInt(flags);
1795 mRemote.transact(GET_INTENT_SENDER_TRANSACTION, data, reply, 0);
1796 reply.readException();
1797 IIntentSender res = IIntentSender.Stub.asInterface(
1798 reply.readStrongBinder());
1799 data.recycle();
1800 reply.recycle();
1801 return res;
1802 }
1803 public void cancelIntentSender(IIntentSender sender) throws RemoteException {
1804 Parcel data = Parcel.obtain();
1805 Parcel reply = Parcel.obtain();
1806 data.writeInterfaceToken(IActivityManager.descriptor);
1807 data.writeStrongBinder(sender.asBinder());
1808 mRemote.transact(CANCEL_INTENT_SENDER_TRANSACTION, data, reply, 0);
1809 reply.readException();
1810 data.recycle();
1811 reply.recycle();
1812 }
1813 public String getPackageForIntentSender(IIntentSender sender) throws RemoteException {
1814 Parcel data = Parcel.obtain();
1815 Parcel reply = Parcel.obtain();
1816 data.writeInterfaceToken(IActivityManager.descriptor);
1817 data.writeStrongBinder(sender.asBinder());
1818 mRemote.transact(GET_PACKAGE_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
1819 reply.readException();
1820 String res = reply.readString();
1821 data.recycle();
1822 reply.recycle();
1823 return res;
1824 }
1825 public void setProcessLimit(int max) throws RemoteException
1826 {
1827 Parcel data = Parcel.obtain();
1828 Parcel reply = Parcel.obtain();
1829 data.writeInterfaceToken(IActivityManager.descriptor);
1830 data.writeInt(max);
1831 mRemote.transact(SET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
1832 reply.readException();
1833 data.recycle();
1834 reply.recycle();
1835 }
1836 public int getProcessLimit() throws RemoteException
1837 {
1838 Parcel data = Parcel.obtain();
1839 Parcel reply = Parcel.obtain();
1840 data.writeInterfaceToken(IActivityManager.descriptor);
1841 mRemote.transact(GET_PROCESS_LIMIT_TRANSACTION, data, reply, 0);
1842 reply.readException();
1843 int res = reply.readInt();
1844 data.recycle();
1845 reply.recycle();
1846 return res;
1847 }
1848 public void setProcessForeground(IBinder token, int pid,
1849 boolean isForeground) throws RemoteException {
1850 Parcel data = Parcel.obtain();
1851 Parcel reply = Parcel.obtain();
1852 data.writeInterfaceToken(IActivityManager.descriptor);
1853 data.writeStrongBinder(token);
1854 data.writeInt(pid);
1855 data.writeInt(isForeground ? 1 : 0);
1856 mRemote.transact(SET_PROCESS_FOREGROUND_TRANSACTION, data, reply, 0);
1857 reply.readException();
1858 data.recycle();
1859 reply.recycle();
1860 }
1861 public int checkPermission(String permission, int pid, int uid)
1862 throws RemoteException {
1863 Parcel data = Parcel.obtain();
1864 Parcel reply = Parcel.obtain();
1865 data.writeInterfaceToken(IActivityManager.descriptor);
1866 data.writeString(permission);
1867 data.writeInt(pid);
1868 data.writeInt(uid);
1869 mRemote.transact(CHECK_PERMISSION_TRANSACTION, data, reply, 0);
1870 reply.readException();
1871 int res = reply.readInt();
1872 data.recycle();
1873 reply.recycle();
1874 return res;
1875 }
1876 public boolean clearApplicationUserData(final String packageName,
1877 final IPackageDataObserver observer) throws RemoteException {
1878 Parcel data = Parcel.obtain();
1879 Parcel reply = Parcel.obtain();
1880 data.writeInterfaceToken(IActivityManager.descriptor);
1881 data.writeString(packageName);
1882 data.writeStrongBinder(observer.asBinder());
1883 mRemote.transact(CLEAR_APP_DATA_TRANSACTION, data, reply, 0);
1884 reply.readException();
1885 boolean res = reply.readInt() != 0;
1886 data.recycle();
1887 reply.recycle();
1888 return res;
1889 }
1890 public int checkUriPermission(Uri uri, int pid, int uid, int mode)
1891 throws RemoteException {
1892 Parcel data = Parcel.obtain();
1893 Parcel reply = Parcel.obtain();
1894 data.writeInterfaceToken(IActivityManager.descriptor);
1895 uri.writeToParcel(data, 0);
1896 data.writeInt(pid);
1897 data.writeInt(uid);
1898 data.writeInt(mode);
1899 mRemote.transact(CHECK_URI_PERMISSION_TRANSACTION, data, reply, 0);
1900 reply.readException();
1901 int res = reply.readInt();
1902 data.recycle();
1903 reply.recycle();
1904 return res;
1905 }
1906 public void grantUriPermission(IApplicationThread caller, String targetPkg,
1907 Uri uri, int mode) throws RemoteException {
1908 Parcel data = Parcel.obtain();
1909 Parcel reply = Parcel.obtain();
1910 data.writeInterfaceToken(IActivityManager.descriptor);
1911 data.writeStrongBinder(caller.asBinder());
1912 data.writeString(targetPkg);
1913 uri.writeToParcel(data, 0);
1914 data.writeInt(mode);
1915 mRemote.transact(GRANT_URI_PERMISSION_TRANSACTION, data, reply, 0);
1916 reply.readException();
1917 data.recycle();
1918 reply.recycle();
1919 }
1920 public void revokeUriPermission(IApplicationThread caller, Uri uri,
1921 int mode) throws RemoteException {
1922 Parcel data = Parcel.obtain();
1923 Parcel reply = Parcel.obtain();
1924 data.writeInterfaceToken(IActivityManager.descriptor);
1925 data.writeStrongBinder(caller.asBinder());
1926 uri.writeToParcel(data, 0);
1927 data.writeInt(mode);
1928 mRemote.transact(REVOKE_URI_PERMISSION_TRANSACTION, data, reply, 0);
1929 reply.readException();
1930 data.recycle();
1931 reply.recycle();
1932 }
1933 public void showWaitingForDebugger(IApplicationThread who, boolean waiting)
1934 throws RemoteException {
1935 Parcel data = Parcel.obtain();
1936 Parcel reply = Parcel.obtain();
1937 data.writeInterfaceToken(IActivityManager.descriptor);
1938 data.writeStrongBinder(who.asBinder());
1939 data.writeInt(waiting ? 1 : 0);
1940 mRemote.transact(SHOW_WAITING_FOR_DEBUGGER_TRANSACTION, data, reply, 0);
1941 reply.readException();
1942 data.recycle();
1943 reply.recycle();
1944 }
1945 public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) throws RemoteException {
1946 Parcel data = Parcel.obtain();
1947 Parcel reply = Parcel.obtain();
1948 data.writeInterfaceToken(IActivityManager.descriptor);
1949 mRemote.transact(GET_MEMORY_INFO_TRANSACTION, data, reply, 0);
1950 reply.readException();
1951 outInfo.readFromParcel(reply);
1952 data.recycle();
1953 reply.recycle();
1954 }
1955 public void unhandledBack() throws RemoteException
1956 {
1957 Parcel data = Parcel.obtain();
1958 Parcel reply = Parcel.obtain();
1959 data.writeInterfaceToken(IActivityManager.descriptor);
1960 mRemote.transact(UNHANDLED_BACK_TRANSACTION, data, reply, 0);
1961 reply.readException();
1962 data.recycle();
1963 reply.recycle();
1964 }
1965 public ParcelFileDescriptor openContentUri(Uri uri) throws RemoteException
1966 {
1967 Parcel data = Parcel.obtain();
1968 Parcel reply = Parcel.obtain();
1969 data.writeInterfaceToken(IActivityManager.descriptor);
1970 mRemote.transact(OPEN_CONTENT_URI_TRANSACTION, data, reply, 0);
1971 reply.readException();
1972 ParcelFileDescriptor pfd = null;
1973 if (reply.readInt() != 0) {
1974 pfd = ParcelFileDescriptor.CREATOR.createFromParcel(reply);
1975 }
1976 data.recycle();
1977 reply.recycle();
1978 return pfd;
1979 }
1980 public void goingToSleep() throws RemoteException
1981 {
1982 Parcel data = Parcel.obtain();
1983 Parcel reply = Parcel.obtain();
1984 data.writeInterfaceToken(IActivityManager.descriptor);
1985 mRemote.transact(GOING_TO_SLEEP_TRANSACTION, data, reply, 0);
1986 reply.readException();
1987 data.recycle();
1988 reply.recycle();
1989 }
1990 public void wakingUp() throws RemoteException
1991 {
1992 Parcel data = Parcel.obtain();
1993 Parcel reply = Parcel.obtain();
1994 data.writeInterfaceToken(IActivityManager.descriptor);
1995 mRemote.transact(WAKING_UP_TRANSACTION, data, reply, 0);
1996 reply.readException();
1997 data.recycle();
1998 reply.recycle();
1999 }
2000 public void setDebugApp(
2001 String packageName, boolean waitForDebugger, boolean persistent)
2002 throws RemoteException
2003 {
2004 Parcel data = Parcel.obtain();
2005 Parcel reply = Parcel.obtain();
2006 data.writeInterfaceToken(IActivityManager.descriptor);
2007 data.writeString(packageName);
2008 data.writeInt(waitForDebugger ? 1 : 0);
2009 data.writeInt(persistent ? 1 : 0);
2010 mRemote.transact(SET_DEBUG_APP_TRANSACTION, data, reply, 0);
2011 reply.readException();
2012 data.recycle();
2013 reply.recycle();
2014 }
2015 public void setAlwaysFinish(boolean enabled) throws RemoteException
2016 {
2017 Parcel data = Parcel.obtain();
2018 Parcel reply = Parcel.obtain();
2019 data.writeInterfaceToken(IActivityManager.descriptor);
2020 data.writeInt(enabled ? 1 : 0);
2021 mRemote.transact(SET_ALWAYS_FINISH_TRANSACTION, data, reply, 0);
2022 reply.readException();
2023 data.recycle();
2024 reply.recycle();
2025 }
2026 public void setActivityWatcher(IActivityWatcher watcher) throws RemoteException
2027 {
2028 Parcel data = Parcel.obtain();
2029 Parcel reply = Parcel.obtain();
2030 data.writeInterfaceToken(IActivityManager.descriptor);
2031 data.writeStrongBinder(watcher != null ? watcher.asBinder() : null);
2032 mRemote.transact(SET_ACTIVITY_WATCHER_TRANSACTION, data, reply, 0);
2033 reply.readException();
2034 data.recycle();
2035 reply.recycle();
2036 }
2037 public void enterSafeMode() throws RemoteException {
2038 Parcel data = Parcel.obtain();
2039 data.writeInterfaceToken(IActivityManager.descriptor);
2040 mRemote.transact(ENTER_SAFE_MODE_TRANSACTION, data, null, 0);
2041 data.recycle();
2042 }
2043 public void noteWakeupAlarm(IIntentSender sender) throws RemoteException {
2044 Parcel data = Parcel.obtain();
2045 data.writeStrongBinder(sender.asBinder());
2046 data.writeInterfaceToken(IActivityManager.descriptor);
2047 mRemote.transact(NOTE_WAKEUP_ALARM_TRANSACTION, data, null, 0);
2048 data.recycle();
2049 }
2050 public boolean killPidsForMemory(int[] pids) throws RemoteException {
2051 Parcel data = Parcel.obtain();
2052 Parcel reply = Parcel.obtain();
2053 data.writeInterfaceToken(IActivityManager.descriptor);
2054 data.writeIntArray(pids);
2055 mRemote.transact(KILL_PIDS_FOR_MEMORY_TRANSACTION, data, reply, 0);
2056 boolean res = reply.readInt() != 0;
2057 data.recycle();
2058 reply.recycle();
2059 return res;
2060 }
2061 public void reportPss(IApplicationThread caller, int pss) throws RemoteException {
2062 Parcel data = Parcel.obtain();
2063 data.writeInterfaceToken(IActivityManager.descriptor);
2064 data.writeStrongBinder(caller.asBinder());
2065 data.writeInt(pss);
2066 mRemote.transact(REPORT_PSS_TRANSACTION, data, null, 0);
2067 data.recycle();
2068 }
2069 public void startRunning(String pkg, String cls, String action,
2070 String indata) throws RemoteException {
2071 Parcel data = Parcel.obtain();
2072 Parcel reply = Parcel.obtain();
2073 data.writeInterfaceToken(IActivityManager.descriptor);
2074 data.writeString(pkg);
2075 data.writeString(cls);
2076 data.writeString(action);
2077 data.writeString(indata);
2078 mRemote.transact(START_RUNNING_TRANSACTION, data, reply, 0);
2079 reply.readException();
2080 data.recycle();
2081 reply.recycle();
2082 }
2083 public void systemReady() throws RemoteException
2084 {
2085 Parcel data = Parcel.obtain();
2086 Parcel reply = Parcel.obtain();
2087 data.writeInterfaceToken(IActivityManager.descriptor);
2088 mRemote.transact(SYSTEM_READY_TRANSACTION, data, reply, 0);
2089 reply.readException();
2090 data.recycle();
2091 reply.recycle();
2092 }
2093 public boolean testIsSystemReady()
2094 {
2095 /* this base class version is never called */
2096 return true;
2097 }
2098 public int handleApplicationError(IBinder app, int flags,
2099 String tag, String shortMsg, String longMsg,
2100 byte[] crashData) throws RemoteException
2101 {
2102 Parcel data = Parcel.obtain();
2103 Parcel reply = Parcel.obtain();
2104 data.writeInterfaceToken(IActivityManager.descriptor);
2105 data.writeStrongBinder(app);
2106 data.writeInt(flags);
2107 data.writeString(tag);
2108 data.writeString(shortMsg);
2109 data.writeString(longMsg);
2110 data.writeByteArray(crashData);
2111 mRemote.transact(HANDLE_APPLICATION_ERROR_TRANSACTION, data, reply, 0);
2112 reply.readException();
2113 int res = reply.readInt();
2114 reply.recycle();
2115 data.recycle();
2116 return res;
2117 }
2118
2119 public void signalPersistentProcesses(int sig) throws RemoteException {
2120 Parcel data = Parcel.obtain();
2121 Parcel reply = Parcel.obtain();
2122 data.writeInterfaceToken(IActivityManager.descriptor);
2123 data.writeInt(sig);
2124 mRemote.transact(SIGNAL_PERSISTENT_PROCESSES_TRANSACTION, data, reply, 0);
2125 reply.readException();
2126 data.recycle();
2127 reply.recycle();
2128 }
2129
2130 public void restartPackage(String packageName) throws RemoteException {
2131 Parcel data = Parcel.obtain();
2132 Parcel reply = Parcel.obtain();
2133 data.writeInterfaceToken(IActivityManager.descriptor);
2134 data.writeString(packageName);
2135 mRemote.transact(RESTART_PACKAGE_TRANSACTION, data, reply, 0);
2136 reply.readException();
2137 data.recycle();
2138 reply.recycle();
2139 }
2140
2141 public ConfigurationInfo getDeviceConfigurationInfo() throws RemoteException
2142 {
2143 Parcel data = Parcel.obtain();
2144 Parcel reply = Parcel.obtain();
2145 data.writeInterfaceToken(IActivityManager.descriptor);
2146 mRemote.transact(GET_DEVICE_CONFIGURATION_TRANSACTION, data, reply, 0);
2147 reply.readException();
2148 ConfigurationInfo res = ConfigurationInfo.CREATOR.createFromParcel(reply);
2149 reply.recycle();
2150 data.recycle();
2151 return res;
2152 }
The Android Open Source Projectf5b4b982009-03-05 20:00:43 -08002153
2154 public boolean profileControl(String process, boolean start,
2155 String path) throws RemoteException
2156 {
2157 Parcel data = Parcel.obtain();
2158 Parcel reply = Parcel.obtain();
2159 data.writeInterfaceToken(IActivityManager.descriptor);
2160 data.writeString(process);
2161 data.writeInt(start ? 1 : 0);
2162 data.writeString(path);
2163 mRemote.transact(PROFILE_CONTROL_TRANSACTION, data, reply, 0);
2164 reply.readException();
2165 boolean res = reply.readInt() != 0;
2166 reply.recycle();
2167 data.recycle();
2168 return res;
2169 }
2170
Dianne Hackborn55280a92009-05-07 15:53:46 -07002171 public boolean shutdown(int timeout) throws RemoteException
2172 {
2173 Parcel data = Parcel.obtain();
2174 Parcel reply = Parcel.obtain();
2175 data.writeInterfaceToken(IActivityManager.descriptor);
2176 data.writeInt(timeout);
2177 mRemote.transact(SHUTDOWN_TRANSACTION, data, reply, 0);
2178 reply.readException();
2179 boolean res = reply.readInt() != 0;
2180 reply.recycle();
2181 data.recycle();
2182 return res;
2183 }
2184
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002185 private IBinder mRemote;
2186}