ActivityManager.java revision dd9b82c283815747b75fe4434c65e4b6c9c9b54f
1/*
2 * Copyright (C) 2007 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.Context;
21import android.content.Intent;
22import android.content.pm.ConfigurationInfo;
23import android.content.pm.IPackageDataObserver;
24import android.graphics.Bitmap;
25import android.os.RemoteException;
26import android.os.Handler;
27import android.os.Parcel;
28import android.os.Parcelable;
29import android.text.TextUtils;
30import java.util.List;
31
32/**
33 * Interact with the overall activities running in the system.
34 */
35public class ActivityManager {
36    private static String TAG = "ActivityManager";
37    private static boolean DEBUG = false;
38    private static boolean localLOGV = DEBUG || android.util.Config.LOGV;
39
40    private final Context mContext;
41    private final Handler mHandler;
42
43    /*package*/ ActivityManager(Context context, Handler handler) {
44        mContext = context;
45        mHandler = handler;
46    }
47
48    /**
49     * Information you can retrieve about tasks that the user has most recently
50     * started or visited.
51     */
52    public static class RecentTaskInfo implements Parcelable {
53        /**
54         * If this task is currently running, this is the identifier for it.
55         * If it is not running, this will be -1.
56         */
57        public int id;
58
59        /**
60         * The original Intent used to launch the task.  You can use this
61         * Intent to re-launch the task (if it is no longer running) or bring
62         * the current task to the front.
63         */
64        public Intent baseIntent;
65
66        /**
67         * If this task was started from an alias, this is the actual
68         * activity component that was initially started; the component of
69         * the baseIntent in this case is the name of the actual activity
70         * implementation that the alias referred to.  Otherwise, this is null.
71         */
72        public ComponentName origActivity;
73
74        public RecentTaskInfo() {
75        }
76
77        public int describeContents() {
78            return 0;
79        }
80
81        public void writeToParcel(Parcel dest, int flags) {
82            dest.writeInt(id);
83            if (baseIntent != null) {
84                dest.writeInt(1);
85                baseIntent.writeToParcel(dest, 0);
86            } else {
87                dest.writeInt(0);
88            }
89            ComponentName.writeToParcel(origActivity, dest);
90        }
91
92        public void readFromParcel(Parcel source) {
93            id = source.readInt();
94            if (source.readInt() != 0) {
95                baseIntent = Intent.CREATOR.createFromParcel(source);
96            } else {
97                baseIntent = null;
98            }
99            origActivity = ComponentName.readFromParcel(source);
100        }
101
102        public static final Creator<RecentTaskInfo> CREATOR
103                = new Creator<RecentTaskInfo>() {
104            public RecentTaskInfo createFromParcel(Parcel source) {
105                return new RecentTaskInfo(source);
106            }
107            public RecentTaskInfo[] newArray(int size) {
108                return new RecentTaskInfo[size];
109            }
110        };
111
112        private RecentTaskInfo(Parcel source) {
113            readFromParcel(source);
114        }
115    }
116
117    /**
118     * Flag for use with {@link #getRecentTasks}: return all tasks, even those
119     * that have set their
120     * {@link android.content.Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS} flag.
121     */
122    public static final int RECENT_WITH_EXCLUDED = 0x0001;
123
124    /**
125     * Return a list of the tasks that the user has recently launched, with
126     * the most recent being first and older ones after in order.
127     *
128     * @param maxNum The maximum number of entries to return in the list.  The
129     * actual number returned may be smaller, depending on how many tasks the
130     * user has started and the maximum number the system can remember.
131     *
132     * @return Returns a list of RecentTaskInfo records describing each of
133     * the recent tasks.
134     *
135     * @throws SecurityException Throws SecurityException if the caller does
136     * not hold the {@link android.Manifest.permission#GET_TASKS} permission.
137     */
138    public List<RecentTaskInfo> getRecentTasks(int maxNum, int flags)
139            throws SecurityException {
140        try {
141            return ActivityManagerNative.getDefault().getRecentTasks(maxNum,
142                    flags);
143        } catch (RemoteException e) {
144            // System dead, we will be dead too soon!
145            return null;
146        }
147    }
148
149    /**
150     * Information you can retrieve about a particular task that is currently
151     * "running" in the system.  Note that a running task does not mean the
152     * given task actual has a process it is actively running in; it simply
153     * means that the user has gone to it and never closed it, but currently
154     * the system may have killed its process and is only holding on to its
155     * last state in order to restart it when the user returns.
156     */
157    public static class RunningTaskInfo implements Parcelable {
158        /**
159         * A unique identifier for this task.
160         */
161        public int id;
162
163        /**
164         * The component launched as the first activity in the task.  This can
165         * be considered the "application" of this task.
166         */
167        public ComponentName baseActivity;
168
169        /**
170         * The activity component at the top of the history stack of the task.
171         * This is what the user is currently doing.
172         */
173        public ComponentName topActivity;
174
175        /**
176         * Thumbnail representation of the task's current state.
177         */
178        public Bitmap thumbnail;
179
180        /**
181         * Description of the task's current state.
182         */
183        public CharSequence description;
184
185        /**
186         * Number of activities in this task.
187         */
188        public int numActivities;
189
190        /**
191         * Number of activities that are currently running (not stopped
192         * and persisted) in this task.
193         */
194        public int numRunning;
195
196        public RunningTaskInfo() {
197        }
198
199        public int describeContents() {
200            return 0;
201        }
202
203        public void writeToParcel(Parcel dest, int flags) {
204            dest.writeInt(id);
205            ComponentName.writeToParcel(baseActivity, dest);
206            ComponentName.writeToParcel(topActivity, dest);
207            if (thumbnail != null) {
208                dest.writeInt(1);
209                thumbnail.writeToParcel(dest, 0);
210            } else {
211                dest.writeInt(0);
212            }
213            TextUtils.writeToParcel(description, dest,
214                    Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
215            dest.writeInt(numActivities);
216            dest.writeInt(numRunning);
217        }
218
219        public void readFromParcel(Parcel source) {
220            id = source.readInt();
221            baseActivity = ComponentName.readFromParcel(source);
222            topActivity = ComponentName.readFromParcel(source);
223            if (source.readInt() != 0) {
224                thumbnail = Bitmap.CREATOR.createFromParcel(source);
225            } else {
226                thumbnail = null;
227            }
228            description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
229            numActivities = source.readInt();
230            numRunning = source.readInt();
231        }
232
233        public static final Creator<RunningTaskInfo> CREATOR = new Creator<RunningTaskInfo>() {
234            public RunningTaskInfo createFromParcel(Parcel source) {
235                return new RunningTaskInfo(source);
236            }
237            public RunningTaskInfo[] newArray(int size) {
238                return new RunningTaskInfo[size];
239            }
240        };
241
242        private RunningTaskInfo(Parcel source) {
243            readFromParcel(source);
244        }
245    }
246
247    /**
248     * Return a list of the tasks that are currently running, with
249     * the most recent being first and older ones after in order.  Note that
250     * "running" does not mean any of the task's code is currently loaded or
251     * activity -- the task may have been frozen by the system, so that it
252     * can be restarted in its previous state when next brought to the
253     * foreground.
254     *
255     * @param maxNum The maximum number of entries to return in the list.  The
256     * actual number returned may be smaller, depending on how many tasks the
257     * user has started.
258     *
259     * @return Returns a list of RunningTaskInfo records describing each of
260     * the running tasks.
261     *
262     * @throws SecurityException Throws SecurityException if the caller does
263     * not hold the {@link android.Manifest.permission#GET_TASKS} permission.
264     */
265    public List<RunningTaskInfo> getRunningTasks(int maxNum)
266            throws SecurityException {
267        try {
268            return (List<RunningTaskInfo>)ActivityManagerNative.getDefault()
269                    .getTasks(maxNum, 0, null);
270        } catch (RemoteException e) {
271            // System dead, we will be dead too soon!
272            return null;
273        }
274    }
275
276    /**
277     * Information you can retrieve about a particular Service that is
278     * currently running in the system.
279     */
280    public static class RunningServiceInfo implements Parcelable {
281        /**
282         * The service component.
283         */
284        public ComponentName service;
285
286        /**
287         * If non-zero, this is the process the service is running in.
288         */
289        public int pid;
290
291        /**
292         * The UID that owns this service.
293         */
294        public int uid;
295
296        /**
297         * The name of the process this service runs in.
298         */
299        public String process;
300
301        /**
302         * Set to true if the service has asked to run as a foreground process.
303         */
304        public boolean foreground;
305
306        /**
307         * The time when the service was first made active, either by someone
308         * starting or binding to it.
309         */
310        public long activeSince;
311
312        /**
313         * Set to true if this service has been explicitly started.
314         */
315        public boolean started;
316
317        /**
318         * Number of clients connected to the service.
319         */
320        public int clientCount;
321
322        /**
323         * Number of times the service's process has crashed while the service
324         * is running.
325         */
326        public int crashCount;
327
328        /**
329         * The time when there was last activity in the service (either
330         * explicit requests to start it or clients binding to it).
331         */
332        public long lastActivityTime;
333
334        /**
335         * If non-zero, this service is not currently running, but scheduled to
336         * restart at the given time.
337         */
338        public long restarting;
339
340        /**
341         * Bit for {@link #flags}: set if this service has been
342         * explicitly started.
343         */
344        public static final int FLAG_STARTED = 1<<0;
345
346        /**
347         * Bit for {@link #flags}: set if the service has asked to
348         * run as a foreground process.
349         */
350        public static final int FLAG_FOREGROUND = 1<<1;
351
352        /**
353         * Bit for {@link #flags): set if the service is running in a
354         * core system process.
355         */
356        public static final int FLAG_SYSTEM_PROCESS = 1<<2;
357
358        /**
359         * Bit for {@link #flags): set if the service is running in a
360         * persistent process.
361         */
362        public static final int FLAG_PERSISTENT_PROCESS = 1<<3;
363
364        /**
365         * Running flags.
366         */
367        public int flags;
368
369        /**
370         * For special services that are bound to by system code, this is
371         * the package that holds the binding.
372         */
373        public String clientPackage;
374
375        /**
376         * For special services that are bound to by system code, this is
377         * a string resource providing a user-visible label for who the
378         * client is.
379         */
380        public int clientLabel;
381
382        public RunningServiceInfo() {
383        }
384
385        public int describeContents() {
386            return 0;
387        }
388
389        public void writeToParcel(Parcel dest, int flags) {
390            ComponentName.writeToParcel(service, dest);
391            dest.writeInt(pid);
392            dest.writeInt(uid);
393            dest.writeString(process);
394            dest.writeInt(foreground ? 1 : 0);
395            dest.writeLong(activeSince);
396            dest.writeInt(started ? 1 : 0);
397            dest.writeInt(clientCount);
398            dest.writeInt(crashCount);
399            dest.writeLong(lastActivityTime);
400            dest.writeLong(restarting);
401            dest.writeInt(this.flags);
402            dest.writeString(clientPackage);
403            dest.writeInt(clientLabel);
404        }
405
406        public void readFromParcel(Parcel source) {
407            service = ComponentName.readFromParcel(source);
408            pid = source.readInt();
409            uid = source.readInt();
410            process = source.readString();
411            foreground = source.readInt() != 0;
412            activeSince = source.readLong();
413            started = source.readInt() != 0;
414            clientCount = source.readInt();
415            crashCount = source.readInt();
416            lastActivityTime = source.readLong();
417            restarting = source.readLong();
418            flags = source.readInt();
419            clientPackage = source.readString();
420            clientLabel = source.readInt();
421        }
422
423        public static final Creator<RunningServiceInfo> CREATOR = new Creator<RunningServiceInfo>() {
424            public RunningServiceInfo createFromParcel(Parcel source) {
425                return new RunningServiceInfo(source);
426            }
427            public RunningServiceInfo[] newArray(int size) {
428                return new RunningServiceInfo[size];
429            }
430        };
431
432        private RunningServiceInfo(Parcel source) {
433            readFromParcel(source);
434        }
435    }
436
437    /**
438     * Return a list of the services that are currently running.
439     *
440     * @param maxNum The maximum number of entries to return in the list.  The
441     * actual number returned may be smaller, depending on how many services
442     * are running.
443     *
444     * @return Returns a list of RunningServiceInfo records describing each of
445     * the running tasks.
446     */
447    public List<RunningServiceInfo> getRunningServices(int maxNum)
448            throws SecurityException {
449        try {
450            return (List<RunningServiceInfo>)ActivityManagerNative.getDefault()
451                    .getServices(maxNum, 0);
452        } catch (RemoteException e) {
453            // System dead, we will be dead too soon!
454            return null;
455        }
456    }
457
458    /**
459     * Returns a PendingIntent you can start to show a control panel for the
460     * given running service.  If the service does not have a control panel,
461     * null is returned.
462     */
463    public PendingIntent getRunningServiceControlPanel(ComponentName service)
464            throws SecurityException {
465        try {
466            return ActivityManagerNative.getDefault()
467                    .getRunningServiceControlPanel(service);
468        } catch (RemoteException e) {
469            // System dead, we will be dead too soon!
470            return null;
471        }
472    }
473
474    /**
475     * Information you can retrieve about the available memory through
476     * {@link ActivityManager#getMemoryInfo}.
477     */
478    public static class MemoryInfo implements Parcelable {
479        /**
480         * The total available memory on the system.  This number should not
481         * be considered absolute: due to the nature of the kernel, a significant
482         * portion of this memory is actually in use and needed for the overall
483         * system to run well.
484         */
485        public long availMem;
486
487        /**
488         * The threshold of {@link #availMem} at which we consider memory to be
489         * low and start killing background services and other non-extraneous
490         * processes.
491         */
492        public long threshold;
493
494        /**
495         * Set to true if the system considers itself to currently be in a low
496         * memory situation.
497         */
498        public boolean lowMemory;
499
500        public MemoryInfo() {
501        }
502
503        public int describeContents() {
504            return 0;
505        }
506
507        public void writeToParcel(Parcel dest, int flags) {
508            dest.writeLong(availMem);
509            dest.writeLong(threshold);
510            dest.writeInt(lowMemory ? 1 : 0);
511        }
512
513        public void readFromParcel(Parcel source) {
514            availMem = source.readLong();
515            threshold = source.readLong();
516            lowMemory = source.readInt() != 0;
517        }
518
519        public static final Creator<MemoryInfo> CREATOR
520                = new Creator<MemoryInfo>() {
521            public MemoryInfo createFromParcel(Parcel source) {
522                return new MemoryInfo(source);
523            }
524            public MemoryInfo[] newArray(int size) {
525                return new MemoryInfo[size];
526            }
527        };
528
529        private MemoryInfo(Parcel source) {
530            readFromParcel(source);
531        }
532    }
533
534    public void getMemoryInfo(MemoryInfo outInfo) {
535        try {
536            ActivityManagerNative.getDefault().getMemoryInfo(outInfo);
537        } catch (RemoteException e) {
538        }
539    }
540
541    /**
542     * @hide
543     */
544    public boolean clearApplicationUserData(String packageName, IPackageDataObserver observer) {
545        try {
546            return ActivityManagerNative.getDefault().clearApplicationUserData(packageName,
547                    observer);
548        } catch (RemoteException e) {
549            return false;
550        }
551    }
552
553    /**
554     * Information you can retrieve about any processes that are in an error condition.
555     */
556    public static class ProcessErrorStateInfo implements Parcelable {
557        /**
558         * Condition codes
559         */
560        public static final int NO_ERROR = 0;
561        public static final int CRASHED = 1;
562        public static final int NOT_RESPONDING = 2;
563
564        /**
565         * The condition that the process is in.
566         */
567        public int condition;
568
569        /**
570         * The process name in which the crash or error occurred.
571         */
572        public String processName;
573
574        /**
575         * The pid of this process; 0 if none
576         */
577        public int pid;
578
579        /**
580         * The kernel user-ID that has been assigned to this process;
581         * currently this is not a unique ID (multiple applications can have
582         * the same uid).
583         */
584        public int uid;
585
586        /**
587         * The tag that was provided when the process crashed.
588         */
589        public String tag;
590
591        /**
592         * A short message describing the error condition.
593         */
594        public String shortMsg;
595
596        /**
597         * A long message describing the error condition.
598         */
599        public String longMsg;
600
601        /**
602         * Raw data about the crash (typically a stack trace).
603         */
604        public byte[] crashData;
605
606        public ProcessErrorStateInfo() {
607        }
608
609        public int describeContents() {
610            return 0;
611        }
612
613        public void writeToParcel(Parcel dest, int flags) {
614            dest.writeInt(condition);
615            dest.writeString(processName);
616            dest.writeInt(pid);
617            dest.writeInt(uid);
618            dest.writeString(tag);
619            dest.writeString(shortMsg);
620            dest.writeString(longMsg);
621            dest.writeInt(crashData == null ? -1 : crashData.length);
622            dest.writeByteArray(crashData);
623        }
624
625        public void readFromParcel(Parcel source) {
626            condition = source.readInt();
627            processName = source.readString();
628            pid = source.readInt();
629            uid = source.readInt();
630            tag = source.readString();
631            shortMsg = source.readString();
632            longMsg = source.readString();
633            int cdLen = source.readInt();
634            if (cdLen == -1) {
635                crashData = null;
636            } else {
637                crashData = new byte[cdLen];
638                source.readByteArray(crashData);
639            }
640        }
641
642        public static final Creator<ProcessErrorStateInfo> CREATOR =
643                new Creator<ProcessErrorStateInfo>() {
644            public ProcessErrorStateInfo createFromParcel(Parcel source) {
645                return new ProcessErrorStateInfo(source);
646            }
647            public ProcessErrorStateInfo[] newArray(int size) {
648                return new ProcessErrorStateInfo[size];
649            }
650        };
651
652        private ProcessErrorStateInfo(Parcel source) {
653            readFromParcel(source);
654        }
655    }
656
657    /**
658     * Returns a list of any processes that are currently in an error condition.  The result
659     * will be null if all processes are running properly at this time.
660     *
661     * @return Returns a list of ProcessErrorStateInfo records, or null if there are no
662     * current error conditions (it will not return an empty list).  This list ordering is not
663     * specified.
664     */
665    public List<ProcessErrorStateInfo> getProcessesInErrorState() {
666        try {
667            return ActivityManagerNative.getDefault().getProcessesInErrorState();
668        } catch (RemoteException e) {
669            return null;
670        }
671    }
672
673    /**
674     * Information you can retrieve about a running process.
675     */
676    public static class RunningAppProcessInfo implements Parcelable {
677        /**
678         * The name of the process that this object is associated with
679         */
680        public String processName;
681
682        /**
683         * The pid of this process; 0 if none
684         */
685        public int pid;
686
687        public String pkgList[];
688
689        /**
690         * Constant for {@link #importance}: this process is running the
691         * foreground UI.
692         */
693        public static final int IMPORTANCE_FOREGROUND = 100;
694
695        /**
696         * Constant for {@link #importance}: this process is running something
697         * that is considered to be actively visible to the user.
698         */
699        public static final int IMPORTANCE_VISIBLE = 200;
700
701        /**
702         * Constant for {@link #importance}: this process is contains services
703         * that should remain running.
704         */
705        public static final int IMPORTANCE_SERVICE = 300;
706
707        /**
708         * Constant for {@link #importance}: this process process contains
709         * background code that is expendable.
710         */
711        public static final int IMPORTANCE_BACKGROUND = 400;
712
713        /**
714         * Constant for {@link #importance}: this process is empty of any
715         * actively running code.
716         */
717        public static final int IMPORTANCE_EMPTY = 500;
718
719        /**
720         * The relative importance level that the system places on this
721         * process.  May be one of {@link #IMPORTANCE_FOREGROUND},
722         * {@link #IMPORTANCE_VISIBLE}, {@link #IMPORTANCE_SERVICE},
723         * {@link #IMPORTANCE_BACKGROUND}, or {@link #IMPORTANCE_EMPTY}.  These
724         * constants are numbered so that "more important" values are always
725         * smaller than "less important" values.
726         */
727        public int importance;
728
729        /**
730         * An additional ordering within a particular {@link #importance}
731         * category, providing finer-grained information about the relative
732         * utility of processes within a category.  This number means nothing
733         * except that a smaller values are more recently used (and thus
734         * more important).  Currently an LRU value is only maintained for
735         * the {@link #IMPORTANCE_BACKGROUND} category, though others may
736         * be maintained in the future.
737         */
738        public int lru;
739
740        /**
741         * Constant for {@link #importanceReasonCode}: nothing special has
742         * been specified for the reason for this level.
743         */
744        public static final int REASON_UNKNOWN = 0;
745
746        /**
747         * Constant for {@link #importanceReasonCode}: one of the application's
748         * content providers is being used by another process.  The pid of
749         * the client process is in {@link #importanceReasonPid} and the
750         * target provider in this process is in
751         * {@link #importanceReasonComponent}.
752         */
753        public static final int REASON_PROVIDER_IN_USE = 1;
754
755        /**
756         * Constant for {@link #importanceReasonCode}: one of the application's
757         * content providers is being used by another process.  The pid of
758         * the client process is in {@link #importanceReasonPid} and the
759         * target provider in this process is in
760         * {@link #importanceReasonComponent}.
761         */
762        public static final int REASON_SERVICE_IN_USE = 2;
763
764        /**
765         * The reason for {@link #importance}, if any.
766         */
767        public int importanceReasonCode;
768
769        /**
770         * For the specified values of {@link #importanceReasonCode}, this
771         * is the process ID of the other process that is a client of this
772         * process.  This will be 0 if no other process is using this one.
773         */
774        public int importanceReasonPid;
775
776        /**
777         * For the specified values of {@link #importanceReasonCode}, this
778         * is the name of the component that is being used in this process.
779         */
780        public ComponentName importanceReasonComponent;
781
782        public RunningAppProcessInfo() {
783            importance = IMPORTANCE_FOREGROUND;
784            importanceReasonCode = REASON_UNKNOWN;
785        }
786
787        public RunningAppProcessInfo(String pProcessName, int pPid, String pArr[]) {
788            processName = pProcessName;
789            pid = pPid;
790            pkgList = pArr;
791        }
792
793        public int describeContents() {
794            return 0;
795        }
796
797        public void writeToParcel(Parcel dest, int flags) {
798            dest.writeString(processName);
799            dest.writeInt(pid);
800            dest.writeStringArray(pkgList);
801            dest.writeInt(importance);
802            dest.writeInt(lru);
803            dest.writeInt(importanceReasonCode);
804            dest.writeInt(importanceReasonPid);
805            ComponentName.writeToParcel(importanceReasonComponent, dest);
806        }
807
808        public void readFromParcel(Parcel source) {
809            processName = source.readString();
810            pid = source.readInt();
811            pkgList = source.readStringArray();
812            importance = source.readInt();
813            lru = source.readInt();
814            importanceReasonCode = source.readInt();
815            importanceReasonPid = source.readInt();
816            importanceReasonComponent = ComponentName.readFromParcel(source);
817        }
818
819        public static final Creator<RunningAppProcessInfo> CREATOR =
820            new Creator<RunningAppProcessInfo>() {
821            public RunningAppProcessInfo createFromParcel(Parcel source) {
822                return new RunningAppProcessInfo(source);
823            }
824            public RunningAppProcessInfo[] newArray(int size) {
825                return new RunningAppProcessInfo[size];
826            }
827        };
828
829        private RunningAppProcessInfo(Parcel source) {
830            readFromParcel(source);
831        }
832    }
833
834    /**
835     * Returns a list of application processes that are running on the device.
836     *
837     * @return Returns a list of RunningAppProcessInfo records, or null if there are no
838     * running processes (it will not return an empty list).  This list ordering is not
839     * specified.
840     */
841    public List<RunningAppProcessInfo> getRunningAppProcesses() {
842        try {
843            return ActivityManagerNative.getDefault().getRunningAppProcesses();
844        } catch (RemoteException e) {
845            return null;
846        }
847    }
848
849    /**
850     * Have the system perform a force stop of everything associated with
851     * the given application package.  All processes that share its uid
852     * will be killed, all services it has running stopped, all activities
853     * removed, etc.  In addition, a {@link Intent#ACTION_PACKAGE_RESTARTED}
854     * broadcast will be sent, so that any of its registered alarms can
855     * be stopped, notifications removed, etc.
856     *
857     * <p>You must hold the permission
858     * {@link android.Manifest.permission#RESTART_PACKAGES} to be able to
859     * call this method.
860     *
861     * @param packageName The name of the package to be stopped.
862     */
863    public void restartPackage(String packageName) {
864        try {
865            ActivityManagerNative.getDefault().restartPackage(packageName);
866        } catch (RemoteException e) {
867        }
868    }
869
870    /**
871     * Get the device configuration attributes.
872     */
873    public ConfigurationInfo getDeviceConfigurationInfo() {
874        try {
875            return ActivityManagerNative.getDefault().getDeviceConfigurationInfo();
876        } catch (RemoteException e) {
877        }
878        return null;
879    }
880
881}
882