Context.java revision 2f1a2e423e0fbb64467d6fcfa4e82c6384f31210
16f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/*
26f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Copyright (C) 2006 The Android Open Source Project
36f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
46f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Licensed under the Apache License, Version 2.0 (the "License");
56f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * you may not use this file except in compliance with the License.
66f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * You may obtain a copy of the License at
76f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
86f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *      http://www.apache.org/licenses/LICENSE-2.0
96f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org *
106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Unless required by applicable law or agreed to in writing, software
116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * distributed under the License is distributed on an "AS IS" BASIS,
126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * See the License for the specific language governing permissions and
146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * limitations under the License.
156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpackage android.content;
186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.content.pm.ApplicationInfo;
206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.content.pm.PackageManager;
216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.content.res.AssetManager;
226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.content.res.Configuration;
236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.content.res.Resources;
246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.content.res.TypedArray;
256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.database.DatabaseErrorHandler;
266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.database.sqlite.SQLiteDatabase;
276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.database.sqlite.SQLiteDatabase.CursorFactory;
286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.graphics.Bitmap;
296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.graphics.drawable.Drawable;
306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.media.MediaScannerConnection.OnScanCompletedListener;
316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.net.Uri;
326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.os.Bundle;
336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.os.Handler;
346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.os.Looper;
356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.os.UserHandle;
366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.os.UserManager;
376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.util.AttributeSet;
386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.view.DisplayAdjustments;
396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.view.Display;
406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport android.view.WindowManager;
416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport java.io.File;
436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport java.io.FileInputStream;
446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport java.io.FileNotFoundException;
456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport java.io.FileOutputStream;
466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport java.io.IOException;
476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgimport java.io.InputStream;
486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org/**
506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * Interface to global information about an application environment.  This is
516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * an abstract class whose implementation is provided by
526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * the Android system.  It
536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * allows access to application-specific resources and classes, as well as
546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * up-calls for application-level operations such as launching activities,
556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org * broadcasting and receiving intents, etc.
566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org */
576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.orgpublic abstract class Context {
586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * File creation mode: the default mode, where the created file can only
606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * be accessed by the calling application (or all applications sharing the
616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * same user ID).
626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #MODE_WORLD_READABLE
636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #MODE_WORLD_WRITEABLE
646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int MODE_PRIVATE = 0x0000;
666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @deprecated Creating world-readable files is very dangerous, and likely
686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * to cause security holes in applications.  It is strongly discouraged;
696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * instead, applications should use more formal mechanism for interactions
706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link android.app.Service}.  There are no guarantees that this
726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * access mode will remain on a file, such as when it goes through a
736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * backup and restore.
746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * File creation mode: allow all other applications to have read access
756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * to the created file.
766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #MODE_PRIVATE
776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #MODE_WORLD_WRITEABLE
786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    @Deprecated
806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int MODE_WORLD_READABLE = 0x0001;
816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @deprecated Creating world-writable files is very dangerous, and likely
836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * to cause security holes in applications.  It is strongly discouraged;
846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * instead, applications should use more formal mechanism for interactions
856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link android.app.Service}.  There are no guarantees that this
876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * access mode will remain on a file, such as when it goes through a
886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * backup and restore.
896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * File creation mode: allow all other applications to have write access
906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * to the created file.
916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #MODE_PRIVATE
926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #MODE_WORLD_READABLE
936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    @Deprecated
956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int MODE_WORLD_WRITEABLE = 0x0002;
966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * File creation mode: for use with {@link #openFileOutput}, if the file
986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * already exists then write data to the end of the existing file
996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * instead of erasing it.
1006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #openFileOutput
1016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int MODE_APPEND = 0x8000;
1036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * SharedPreference loading flag: when set, the file on disk will
1066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * be checked for modification even if the shared preferences
1076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * instance is already loaded in this process.  This behavior is
1086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * sometimes desired in cases where the application has multiple
1096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * processes, all writing to the same SharedPreferences file.
1106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Generally there are better forms of communication between
1116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * processes, though.
1126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
1136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <p>This was the legacy (but undocumented) behavior in and
1146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * before Gingerbread (Android 2.3) and this flag is implied when
1156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * targetting such releases.  For applications targetting SDK
1166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * versions <em>greater than</em> Android 2.3, this flag must be
1176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * explicitly set if desired.
1186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
1196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #getSharedPreferences
1206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int MODE_MULTI_PROCESS = 0x0004;
1226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Database open flag: when set, the database is opened with write-ahead
1256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * logging enabled by default.
1266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
1276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #openOrCreateDatabase(String, int, CursorFactory)
1286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler)
1296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see SQLiteDatabase#enableWriteAheadLogging
1306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008;
1326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: automatically create the service as long
1356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * as the binding exists.  Note that while this will create the service,
1366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * its {@link android.app.Service#onStartCommand}
1376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * method will still only be called due to an
1386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * explicit call to {@link #startService}.  Even without that, though,
1396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * this still provides you with access to the service object while the
1406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * service is created.
1416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
1426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH},
1436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * not supplying this flag would also impact how important the system
1446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * consider's the target service's process to be.  When set, the only way
1456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * for it to be raised was by binding from a service in which case it will
1466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * only be important when that activity is in the foreground.  Now to
1476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * achieve this behavior you must explicitly supply the new flag
1486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link #BIND_ADJUST_WITH_ACTIVITY}.  For compatibility, old applications
1496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * that don't specify {@link #BIND_AUTO_CREATE} will automatically have
1506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * the flags {@link #BIND_WAIVE_PRIORITY} and
1516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve
1526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * the same result.
1536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_AUTO_CREATE = 0x0001;
1556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: include debugging help for mismatched
1586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * calls to unbind.  When this flag is set, the callstack of the following
1596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link #unbindService} call is retained, to be printed if a later
1606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * incorrect unbind call is made.  Note that doing this requires retaining
1616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * information about the binding that was made for the lifetime of the app,
1626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * resulting in a leak -- this should only be used for debugging.
1636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_DEBUG_UNBIND = 0x0002;
1656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: don't allow this binding to raise
1686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * the target service's process to the foreground scheduling priority.
1696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * It will still be raised to at least the same memory priority
1706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * as the client (so that its process will not be killable in any
1716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * situation where the client is not killable), but for CPU scheduling
1726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * purposes it may be left in the background.  This only has an impact
1736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * in the situation where the binding client is a foreground process
1746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * and the target service is in a background process.
1756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_NOT_FOREGROUND = 0x0004;
1776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: indicates that the client application
1806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * binding to this service considers the service to be more important than
1816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * the app itself.  When set, the platform will try to have the out of
1826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * memory killer kill the app before it kills the service it is bound to, though
1836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * this is not guaranteed to be the case.
1846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_ABOVE_CLIENT = 0x0008;
1866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: allow the process hosting the bound
1896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * service to go through its normal memory management.  It will be
1906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * treated more like a running service, allowing the system to
1916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * (temporarily) expunge the process if low on memory or for some other
1926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * whim it may have, and being more aggressive about making it a candidate
1936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * to be killed (and restarted) if running for a long time.
1946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
1956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010;
1966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
1976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
1986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: don't impact the scheduling or
1996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * memory management priority of the target service's hosting process.
2006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Allows the service's process to be managed on the background LRU list
2016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * just like a regular application process in the background.
2026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
2036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_WAIVE_PRIORITY = 0x0020;
2046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
2066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: this service is very important to
2076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * the client, so should be brought to the foreground process level
2086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * when the client is.  Normally a process can only be raised to the
2096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * visibility level by a client, even if that client is in the foreground.
2106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
2116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_IMPORTANT = 0x0040;
2126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
2146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: If binding from an activity, allow the
2156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * target service's process importance to be raised based on whether the
2166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * activity is visible to the user, regardless whether another flag is
2176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * used to reduce the amount that the client process's overall importance
2186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * is used to impact it.
2196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
2206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080;
2216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
2236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @hide An idea that is not yet implemented.
2246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: If binding from an activity, consider
2256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * this service to be visible like the binding activity is.  That is,
2266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * it will be treated as something more important to keep around than
2276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * invisible background activities.  This will impact the number of
2286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * recent activities the user can switch between without having them
2296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * restart.  There is no guarantee this will be respected, as the system
2306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * tries to balance such requests from one app vs. the importantance of
2316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * keeping other apps around.
2326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
2336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_VISIBLE = 0x10000000;
2346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
2366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @hide
2376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: Consider this binding to be causing the target
2386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * process to be showing UI, so it will be do a UI_HIDDEN memory trim when it goes
2396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * away.
2406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
2416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_SHOWING_UI = 0x20000000;
2426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
2446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Flag for {@link #bindService}: Don't consider the bound service to be
2456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * visible, even if the caller is visible.
2466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @hide
2476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
2486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public static final int BIND_NOT_VISIBLE = 0x40000000;
2496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** Return an AssetManager instance for your application's package. */
2516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract AssetManager getAssets();
2526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** Return a Resources instance for your application's package. */
2546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract Resources getResources();
2556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** Return PackageManager instance to find global package information. */
2576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract PackageManager getPackageManager();
2586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** Return a ContentResolver instance for your application's package. */
2606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract ContentResolver getContentResolver();
2616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
2636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return the Looper for the main thread of the current process.  This is
2646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * the thread used to dispatch calls to application components (activities,
2656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * services, etc).
2666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <p>
2676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * By definition, this method returns the same result as would be obtained
2686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * by calling {@link Looper#getMainLooper() Looper.getMainLooper()}.
2696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * </p>
2706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
2716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @return The main looper.
2726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
2736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract Looper getMainLooper();
2746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
2756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
2766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return the context of the single, global Application object of the
2776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * current process.  This generally should only be used if you need a
2786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Context whose lifecycle is separate from the current context, that is
2796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * tied to the lifetime of the process rather than the current component.
2806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
2816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <p>Consider for example how this interacts with
2826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}:
2836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <ul>
2846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <li> <p>If used from an Activity context, the receiver is being registered
2856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * within that activity.  This means that you are expected to unregister
2866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * before the activity is done being destroyed; in fact if you do not do
2876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * so, the framework will clean up your leaked registration as it removes
2886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * the activity and log an error.  Thus, if you use the Activity context
2896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * to register a receiver that is static (global to the process, not
2906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * associated with an Activity instance) then that registration will be
2916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * removed on you at whatever point the activity you used is destroyed.
2926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <li> <p>If used from the Context returned here, the receiver is being
2936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * registered with the global state associated with your application.  Thus
2946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * it will never be unregistered for you.  This is necessary if the receiver
2956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * is associated with static data, not a particular component.  However
2966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * using the ApplicationContext elsewhere can easily lead to serious leaks
2976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * if you forget to unregister, unbind, etc.
2986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * </ul>
2996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract Context getApplicationContext();
3016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Add a new {@link ComponentCallbacks} to the base application of the
3046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Context, which will be called at the same times as the ComponentCallbacks
3056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * methods of activities and other components are called.  Note that you
3066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when
3076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * appropriate in the future; this will not be removed for you.
3086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
3096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @param callback The interface to call.  This can be either a
3106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface.
3116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public void registerComponentCallbacks(ComponentCallbacks callback) {
3136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        getApplicationContext().registerComponentCallbacks(callback);
3146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Remove a {@link ComponentCallbacks} object that was previously registered
3186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * with {@link #registerComponentCallbacks(ComponentCallbacks)}.
3196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public void unregisterComponentCallbacks(ComponentCallbacks callback) {
3216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        getApplicationContext().unregisterComponentCallbacks(callback);
3226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return a localized, styled CharSequence from the application's package's
3266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * default string table.
3276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
3286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @param resId Resource id for the CharSequence text
3296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public final CharSequence getText(int resId) {
3316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return getResources().getText(resId);
3326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return a localized string from the application's package's
3366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * default string table.
3376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
3386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @param resId Resource id for the string
3396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public final String getString(int resId) {
3416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return getResources().getString(resId);
3426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return a localized formatted string from the application's package's
3466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * default string table, substituting the format arguments as defined in
3476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link java.util.Formatter} and {@link java.lang.String#format}.
3486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
3496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @param resId Resource id for the format string
3506f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @param formatArgs The format arguments that will be used for substitution.
3516f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3526f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3536f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public final String getString(int resId, Object... formatArgs) {
3546f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return getResources().getString(resId, formatArgs);
3556f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3566f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3576f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     /**
3586f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Set the base theme for this context.  Note that this should be called
3596f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * before any views are instantiated in the Context (for example before
3606f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * calling {@link android.app.Activity#setContentView} or
3616f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link android.view.LayoutInflater#inflate}).
3626f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
3636f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @param resid The style resource describing the theme.
3646f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3656f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract void setTheme(int resid);
3666f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3676f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** @hide Needed for some internal implementation...  not public because
3686f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * you can't assume this actually means anything. */
3696f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public int getThemeResId() {
3706f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return 0;
3716f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3726f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3736f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3746f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return the Theme object associated with this Context.
3756f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3766f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract Resources.Theme getTheme();
3776f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3786f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3796f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Retrieve styled attribute information in this Context's theme.  See
3806f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link Resources.Theme#obtainStyledAttributes(int[])}
3816f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * for more information.
3826f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
3836f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see Resources.Theme#obtainStyledAttributes(int[])
3846f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3856f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public final TypedArray obtainStyledAttributes(
3866f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            int[] attrs) {
3876f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return getTheme().obtainStyledAttributes(attrs);
3886f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
3896f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
3906f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
3916f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Retrieve styled attribute information in this Context's theme.  See
3926f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link Resources.Theme#obtainStyledAttributes(int, int[])}
3936f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * for more information.
3946f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
3956f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see Resources.Theme#obtainStyledAttributes(int, int[])
3966f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
3976f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public final TypedArray obtainStyledAttributes(
3986f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            int resid, int[] attrs) throws Resources.NotFoundException {
3996f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return getTheme().obtainStyledAttributes(resid, attrs);
4006f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
4016f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4026f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
4036f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Retrieve styled attribute information in this Context's theme.  See
4046f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)}
4056f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * for more information.
4066f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
4076f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)
4086f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
4096f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public final TypedArray obtainStyledAttributes(
4106f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            AttributeSet set, int[] attrs) {
4116f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return getTheme().obtainStyledAttributes(set, attrs, 0, 0);
4126f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
4136f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4146f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
4156f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Retrieve styled attribute information in this Context's theme.  See
4166f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)}
4176f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * for more information.
4186f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
4196f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)
4206f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
4216f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public final TypedArray obtainStyledAttributes(
4226f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) {
4236f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org        return getTheme().obtainStyledAttributes(
4246f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org            set, attrs, defStyleAttr, defStyleRes);
4256f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    }
4266f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4276f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
4286f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return a class loader you can use to retrieve classes in this package.
4296f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     */
4306f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract ClassLoader getClassLoader();
4316f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4326f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** Return the name of this application's package. */
4336f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract String getPackageName();
4346f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4356f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** @hide Return the name of the base context this context is derived from. */
4366f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract String getBasePackageName();
4376f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4386f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /** Return the full application info for this context's package. */
4396f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    public abstract ApplicationInfo getApplicationInfo();
4406f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org
4416f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org    /**
4426f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * Return the full path to this context's primary Android package.
4436f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * The Android package is a ZIP file which contains the application's
4446f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * primary resources.
4456f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
4466f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * <p>Note: this is not generally useful for applications, since they should
4476f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * not be directly accessing the file system.
4486f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     *
4496f31ac30b9092fd02a8c97e5216cf53f3e4fae4jshin@chromium.org     * @return String Path to the resources.
450     */
451    public abstract String getPackageResourcePath();
452
453    /**
454     * Return the full path to this context's primary Android package.
455     * The Android package is a ZIP file which contains application's
456     * primary code and assets.
457     *
458     * <p>Note: this is not generally useful for applications, since they should
459     * not be directly accessing the file system.
460     *
461     * @return String Path to the code and assets.
462     */
463    public abstract String getPackageCodePath();
464
465    /**
466     * {@hide}
467     * Return the full path to the shared prefs file for the given prefs group name.
468     *
469     * <p>Note: this is not generally useful for applications, since they should
470     * not be directly accessing the file system.
471     */
472    public abstract File getSharedPrefsFile(String name);
473
474    /**
475     * Retrieve and hold the contents of the preferences file 'name', returning
476     * a SharedPreferences through which you can retrieve and modify its
477     * values.  Only one instance of the SharedPreferences object is returned
478     * to any callers for the same name, meaning they will see each other's
479     * edits as soon as they are made.
480     *
481     * @param name Desired preferences file. If a preferences file by this name
482     * does not exist, it will be created when you retrieve an
483     * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
484     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
485     * default operation, {@link #MODE_WORLD_READABLE}
486     * and {@link #MODE_WORLD_WRITEABLE} to control permissions.  The bit
487     * {@link #MODE_MULTI_PROCESS} can also be used if multiple processes
488     * are mutating the same SharedPreferences file.  {@link #MODE_MULTI_PROCESS}
489     * is always on in apps targetting Gingerbread (Android 2.3) and below, and
490     * off by default in later versions.
491     *
492     * @return The single {@link SharedPreferences} instance that can be used
493     *         to retrieve and modify the preference values.
494     *
495     * @see #MODE_PRIVATE
496     * @see #MODE_WORLD_READABLE
497     * @see #MODE_WORLD_WRITEABLE
498     * @see #MODE_MULTI_PROCESS
499     */
500    public abstract SharedPreferences getSharedPreferences(String name,
501            int mode);
502
503    /**
504     * Open a private file associated with this Context's application package
505     * for reading.
506     *
507     * @param name The name of the file to open; can not contain path
508     *             separators.
509     *
510     * @return The resulting {@link FileInputStream}.
511     *
512     * @see #openFileOutput
513     * @see #fileList
514     * @see #deleteFile
515     * @see java.io.FileInputStream#FileInputStream(String)
516     */
517    public abstract FileInputStream openFileInput(String name)
518        throws FileNotFoundException;
519
520    /**
521     * Open a private file associated with this Context's application package
522     * for writing.  Creates the file if it doesn't already exist.
523     *
524     * @param name The name of the file to open; can not contain path
525     *             separators.
526     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
527     * default operation, {@link #MODE_APPEND} to append to an existing file,
528     * {@link #MODE_WORLD_READABLE} and {@link #MODE_WORLD_WRITEABLE} to control
529     * permissions.
530     *
531     * @return The resulting {@link FileOutputStream}.
532     *
533     * @see #MODE_APPEND
534     * @see #MODE_PRIVATE
535     * @see #MODE_WORLD_READABLE
536     * @see #MODE_WORLD_WRITEABLE
537     * @see #openFileInput
538     * @see #fileList
539     * @see #deleteFile
540     * @see java.io.FileOutputStream#FileOutputStream(String)
541     */
542    public abstract FileOutputStream openFileOutput(String name, int mode)
543        throws FileNotFoundException;
544
545    /**
546     * Delete the given private file associated with this Context's
547     * application package.
548     *
549     * @param name The name of the file to delete; can not contain path
550     *             separators.
551     *
552     * @return {@code true} if the file was successfully deleted; else
553     *         {@code false}.
554     *
555     * @see #openFileInput
556     * @see #openFileOutput
557     * @see #fileList
558     * @see java.io.File#delete()
559     */
560    public abstract boolean deleteFile(String name);
561
562    /**
563     * Returns the absolute path on the filesystem where a file created with
564     * {@link #openFileOutput} is stored.
565     *
566     * @param name The name of the file for which you would like to get
567     *          its path.
568     *
569     * @return An absolute path to the given file.
570     *
571     * @see #openFileOutput
572     * @see #getFilesDir
573     * @see #getDir
574     */
575    public abstract File getFileStreamPath(String name);
576
577    /**
578     * Returns the absolute path to the directory on the filesystem where
579     * files created with {@link #openFileOutput} are stored.
580     *
581     * @return The path of the directory holding application files.
582     *
583     * @see #openFileOutput
584     * @see #getFileStreamPath
585     * @see #getDir
586     */
587    public abstract File getFilesDir();
588
589    /**
590     * Returns the absolute path to the directory on the external filesystem
591     * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory()
592     * Environment.getExternalStorageDirectory()}) where the application can
593     * place persistent files it owns.  These files are private to the
594     * applications, and not typically visible to the user as media.
595     *
596     * <p>This is like {@link #getFilesDir()} in that these
597     * files will be deleted when the application is uninstalled, however there
598     * are some important differences:
599     *
600     * <ul>
601     * <li>External files are not always available: they will disappear if the
602     * user mounts the external storage on a computer or removes it.  See the
603     * APIs on {@link android.os.Environment} for information in the storage state.
604     * <li>There is no security enforced with these files.  All applications
605     * can read and write files placed here.
606     * </ul>
607     *
608     * <p>On devices with multiple users (as described by {@link UserManager}),
609     * each user has their own isolated external storage. Applications only
610     * have access to the external storage for the user they're running as.</p>
611     *
612     * <p>Here is an example of typical code to manipulate a file in
613     * an application's private storage:</p>
614     *
615     * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
616     * private_file}
617     *
618     * <p>If you supply a non-null <var>type</var> to this function, the returned
619     * file will be a path to a sub-directory of the given type.  Though these files
620     * are not automatically scanned by the media scanner, you can explicitly
621     * add them to the media database with
622     * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[],
623     *      OnScanCompletedListener) MediaScannerConnection.scanFile}.
624     * Note that this is not the same as
625     * {@link android.os.Environment#getExternalStoragePublicDirectory
626     * Environment.getExternalStoragePublicDirectory()}, which provides
627     * directories of media shared by all applications.  The
628     * directories returned here are
629     * owned by the application, and their contents will be removed when the
630     * application is uninstalled.  Unlike
631     * {@link android.os.Environment#getExternalStoragePublicDirectory
632     * Environment.getExternalStoragePublicDirectory()}, the directory
633     * returned here will be automatically created for you.
634     *
635     * <p>Here is an example of typical code to manipulate a picture in
636     * an application's private storage and add it to the media database:</p>
637     *
638     * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
639     * private_picture}
640     *
641     * <p>Writing to this path requires the
642     * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
643     *
644     * @param type The type of files directory to return.  May be null for
645     * the root of the files directory or one of
646     * the following Environment constants for a subdirectory:
647     * {@link android.os.Environment#DIRECTORY_MUSIC},
648     * {@link android.os.Environment#DIRECTORY_PODCASTS},
649     * {@link android.os.Environment#DIRECTORY_RINGTONES},
650     * {@link android.os.Environment#DIRECTORY_ALARMS},
651     * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS},
652     * {@link android.os.Environment#DIRECTORY_PICTURES}, or
653     * {@link android.os.Environment#DIRECTORY_MOVIES}.
654     *
655     * @return The path of the directory holding application files
656     * on external storage.  Returns null if external storage is not currently
657     * mounted so it could not ensure the path exists; you will need to call
658     * this method again when it is available.
659     *
660     * @see #getFilesDir
661     * @see android.os.Environment#getExternalStoragePublicDirectory
662     */
663    public abstract File getExternalFilesDir(String type);
664
665    /**
666     * Return the directory where this application's OBB files (if there
667     * are any) can be found.  Note if the application does not have any OBB
668     * files, this directory may not exist.
669     *
670     * <p>On devices with multiple users (as described by {@link UserManager}),
671     * multiple users may share the same OBB storage location. Applications
672     * should ensure that multiple instances running under different users
673     * don't interfere with each other.</p>
674     */
675    public abstract File getObbDir();
676
677    /**
678     * Returns the absolute path to the application specific cache directory
679     * on the filesystem. These files will be ones that get deleted first when the
680     * device runs low on storage.
681     * There is no guarantee when these files will be deleted.
682     *
683     * <strong>Note: you should not <em>rely</em> on the system deleting these
684     * files for you; you should always have a reasonable maximum, such as 1 MB,
685     * for the amount of space you consume with cache files, and prune those
686     * files when exceeding that space.</strong>
687     *
688     * @return The path of the directory holding application cache files.
689     *
690     * @see #openFileOutput
691     * @see #getFileStreamPath
692     * @see #getDir
693     */
694    public abstract File getCacheDir();
695
696    /**
697     * Returns the absolute path to the directory on the external filesystem
698     * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory()
699     * Environment.getExternalStorageDirectory()} where the application can
700     * place cache files it owns.
701     *
702     * <p>This is like {@link #getCacheDir()} in that these
703     * files will be deleted when the application is uninstalled, however there
704     * are some important differences:
705     *
706     * <ul>
707     * <li>The platform does not always monitor the space available in external
708     * storage, and thus may not automatically delete these files.  Currently
709     * the only time files here will be deleted by the platform is when running
710     * on {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and
711     * {@link android.os.Environment#isExternalStorageEmulated()
712     * Environment.isExternalStorageEmulated()} returns true.  Note that you should
713     * be managing the maximum space you will use for these anyway, just like
714     * with {@link #getCacheDir()}.
715     * <li>External files are not always available: they will disappear if the
716     * user mounts the external storage on a computer or removes it.  See the
717     * APIs on {@link android.os.Environment} for information in the storage state.
718     * <li>There is no security enforced with these files.  All applications
719     * can read and write files placed here.
720     * </ul>
721     *
722     * <p>On devices with multiple users (as described by {@link UserManager}),
723     * each user has their own isolated external storage. Applications only
724     * have access to the external storage for the user they're running as.</p>
725     *
726     * <p>Writing to this path requires the
727     * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
728     *
729     * @return The path of the directory holding application cache files
730     * on external storage.  Returns null if external storage is not currently
731     * mounted so it could not ensure the path exists; you will need to call
732     * this method again when it is available.
733     *
734     * @see #getCacheDir
735     */
736    public abstract File getExternalCacheDir();
737
738    /**
739     * Returns an array of strings naming the private files associated with
740     * this Context's application package.
741     *
742     * @return Array of strings naming the private files.
743     *
744     * @see #openFileInput
745     * @see #openFileOutput
746     * @see #deleteFile
747     */
748    public abstract String[] fileList();
749
750    /**
751     * Retrieve, creating if needed, a new directory in which the application
752     * can place its own custom data files.  You can use the returned File
753     * object to create and access files in this directory.  Note that files
754     * created through a File object will only be accessible by your own
755     * application; you can only set the mode of the entire directory, not
756     * of individual files.
757     *
758     * @param name Name of the directory to retrieve.  This is a directory
759     * that is created as part of your application data.
760     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
761     * default operation, {@link #MODE_WORLD_READABLE} and
762     * {@link #MODE_WORLD_WRITEABLE} to control permissions.
763     *
764     * @return A {@link File} object for the requested directory.  The directory
765     * will have been created if it does not already exist.
766     *
767     * @see #openFileOutput(String, int)
768     */
769    public abstract File getDir(String name, int mode);
770
771    /**
772     * Open a new private SQLiteDatabase associated with this Context's
773     * application package.  Create the database file if it doesn't exist.
774     *
775     * @param name The name (unique in the application package) of the database.
776     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
777     *     default operation, {@link #MODE_WORLD_READABLE}
778     *     and {@link #MODE_WORLD_WRITEABLE} to control permissions.
779     *     Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default.
780     * @param factory An optional factory class that is called to instantiate a
781     *     cursor when query is called.
782     *
783     * @return The contents of a newly created database with the given name.
784     * @throws android.database.sqlite.SQLiteException if the database file could not be opened.
785     *
786     * @see #MODE_PRIVATE
787     * @see #MODE_WORLD_READABLE
788     * @see #MODE_WORLD_WRITEABLE
789     * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
790     * @see #deleteDatabase
791     */
792    public abstract SQLiteDatabase openOrCreateDatabase(String name,
793            int mode, CursorFactory factory);
794
795    /**
796     * Open a new private SQLiteDatabase associated with this Context's
797     * application package.  Creates the database file if it doesn't exist.
798     *
799     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be
800     * used to handle corruption when sqlite reports database corruption.</p>
801     *
802     * @param name The name (unique in the application package) of the database.
803     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
804     *     default operation, {@link #MODE_WORLD_READABLE}
805     *     and {@link #MODE_WORLD_WRITEABLE} to control permissions.
806     *     Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default.
807     * @param factory An optional factory class that is called to instantiate a
808     *     cursor when query is called.
809     * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database
810     * corruption. if null, {@link android.database.DefaultDatabaseErrorHandler} is assumed.
811     * @return The contents of a newly created database with the given name.
812     * @throws android.database.sqlite.SQLiteException if the database file could not be opened.
813     *
814     * @see #MODE_PRIVATE
815     * @see #MODE_WORLD_READABLE
816     * @see #MODE_WORLD_WRITEABLE
817     * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
818     * @see #deleteDatabase
819     */
820    public abstract SQLiteDatabase openOrCreateDatabase(String name,
821            int mode, CursorFactory factory, DatabaseErrorHandler errorHandler);
822
823    /**
824     * Delete an existing private SQLiteDatabase associated with this Context's
825     * application package.
826     *
827     * @param name The name (unique in the application package) of the
828     *             database.
829     *
830     * @return {@code true} if the database was successfully deleted; else {@code false}.
831     *
832     * @see #openOrCreateDatabase
833     */
834    public abstract boolean deleteDatabase(String name);
835
836    /**
837     * Returns the absolute path on the filesystem where a database created with
838     * {@link #openOrCreateDatabase} is stored.
839     *
840     * @param name The name of the database for which you would like to get
841     *          its path.
842     *
843     * @return An absolute path to the given database.
844     *
845     * @see #openOrCreateDatabase
846     */
847    public abstract File getDatabasePath(String name);
848
849    /**
850     * Returns an array of strings naming the private databases associated with
851     * this Context's application package.
852     *
853     * @return Array of strings naming the private databases.
854     *
855     * @see #openOrCreateDatabase
856     * @see #deleteDatabase
857     */
858    public abstract String[] databaseList();
859
860    /**
861     * @deprecated Use {@link android.app.WallpaperManager#getDrawable
862     * WallpaperManager.get()} instead.
863     */
864    @Deprecated
865    public abstract Drawable getWallpaper();
866
867    /**
868     * @deprecated Use {@link android.app.WallpaperManager#peekDrawable
869     * WallpaperManager.peek()} instead.
870     */
871    @Deprecated
872    public abstract Drawable peekWallpaper();
873
874    /**
875     * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth()
876     * WallpaperManager.getDesiredMinimumWidth()} instead.
877     */
878    @Deprecated
879    public abstract int getWallpaperDesiredMinimumWidth();
880
881    /**
882     * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight()
883     * WallpaperManager.getDesiredMinimumHeight()} instead.
884     */
885    @Deprecated
886    public abstract int getWallpaperDesiredMinimumHeight();
887
888    /**
889     * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap)
890     * WallpaperManager.set()} instead.
891     * <p>This method requires the caller to hold the permission
892     * {@link android.Manifest.permission#SET_WALLPAPER}.
893     */
894    @Deprecated
895    public abstract void setWallpaper(Bitmap bitmap) throws IOException;
896
897    /**
898     * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream)
899     * WallpaperManager.set()} instead.
900     * <p>This method requires the caller to hold the permission
901     * {@link android.Manifest.permission#SET_WALLPAPER}.
902     */
903    @Deprecated
904    public abstract void setWallpaper(InputStream data) throws IOException;
905
906    /**
907     * @deprecated Use {@link android.app.WallpaperManager#clear
908     * WallpaperManager.clear()} instead.
909     * <p>This method requires the caller to hold the permission
910     * {@link android.Manifest.permission#SET_WALLPAPER}.
911     */
912    @Deprecated
913    public abstract void clearWallpaper() throws IOException;
914
915    /**
916     * Same as {@link #startActivity(Intent, Bundle)} with no options
917     * specified.
918     *
919     * @param intent The description of the activity to start.
920     *
921     * @throws ActivityNotFoundException &nbsp;
922     *
923     * @see #startActivity(Intent, Bundle)
924     * @see PackageManager#resolveActivity
925     */
926    public abstract void startActivity(Intent intent);
927
928    /**
929     * Version of {@link #startActivity(Intent)} that allows you to specify the
930     * user the activity will be started for.  This is not available to applications
931     * that are not pre-installed on the system image.  Using it requires holding
932     * the INTERACT_ACROSS_USERS_FULL permission.
933     * @param intent The description of the activity to start.
934     * @param user The UserHandle of the user to start this activity for.
935     * @throws ActivityNotFoundException &nbsp;
936     * @hide
937     */
938    public void startActivityAsUser(Intent intent, UserHandle user) {
939        throw new RuntimeException("Not implemented. Must override in a subclass.");
940    }
941
942    /**
943     * Launch a new activity.  You will not receive any information about when
944     * the activity exits.
945     *
946     * <p>Note that if this method is being called from outside of an
947     * {@link android.app.Activity} Context, then the Intent must include
948     * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag.  This is because,
949     * without being started from an existing Activity, there is no existing
950     * task in which to place the new activity and thus it needs to be placed
951     * in its own separate task.
952     *
953     * <p>This method throws {@link ActivityNotFoundException}
954     * if there was no Activity found to run the given Intent.
955     *
956     * @param intent The description of the activity to start.
957     * @param options Additional options for how the Activity should be started.
958     * May be null if there are no options.  See {@link android.app.ActivityOptions}
959     * for how to build the Bundle supplied here; there are no supported definitions
960     * for building it manually.
961     *
962     * @throws ActivityNotFoundException &nbsp;
963     *
964     * @see #startActivity(Intent)
965     * @see PackageManager#resolveActivity
966     */
967    public abstract void startActivity(Intent intent, Bundle options);
968
969    /**
970     * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the
971     * user the activity will be started for.  This is not available to applications
972     * that are not pre-installed on the system image.  Using it requires holding
973     * the INTERACT_ACROSS_USERS_FULL permission.
974     * @param intent The description of the activity to start.
975     * @param options Additional options for how the Activity should be started.
976     * May be null if there are no options.  See {@link android.app.ActivityOptions}
977     * for how to build the Bundle supplied here; there are no supported definitions
978     * for building it manually.
979     * @param user The UserHandle of the user to start this activity for.
980     * @throws ActivityNotFoundException &nbsp;
981     * @hide
982     */
983    public void startActivityAsUser(Intent intent, Bundle options, UserHandle userId) {
984        throw new RuntimeException("Not implemented. Must override in a subclass.");
985    }
986
987    /**
988     * Same as {@link #startActivities(Intent[], Bundle)} with no options
989     * specified.
990     *
991     * @param intents An array of Intents to be started.
992     *
993     * @throws ActivityNotFoundException &nbsp;
994     *
995     * @see #startActivities(Intent[], Bundle)
996     * @see PackageManager#resolveActivity
997     */
998    public abstract void startActivities(Intent[] intents);
999
1000    /**
1001     * Launch multiple new activities.  This is generally the same as calling
1002     * {@link #startActivity(Intent)} for the first Intent in the array,
1003     * that activity during its creation calling {@link #startActivity(Intent)}
1004     * for the second entry, etc.  Note that unlike that approach, generally
1005     * none of the activities except the last in the array will be created
1006     * at this point, but rather will be created when the user first visits
1007     * them (due to pressing back from the activity on top).
1008     *
1009     * <p>This method throws {@link ActivityNotFoundException}
1010     * if there was no Activity found for <em>any</em> given Intent.  In this
1011     * case the state of the activity stack is undefined (some Intents in the
1012     * list may be on it, some not), so you probably want to avoid such situations.
1013     *
1014     * @param intents An array of Intents to be started.
1015     * @param options Additional options for how the Activity should be started.
1016     * See {@link android.content.Context#startActivity(Intent, Bundle)
1017     * Context.startActivity(Intent, Bundle)} for more details.
1018     *
1019     * @throws ActivityNotFoundException &nbsp;
1020     *
1021     * @see #startActivities(Intent[])
1022     * @see PackageManager#resolveActivity
1023     */
1024    public abstract void startActivities(Intent[] intents, Bundle options);
1025
1026    /**
1027     * @hide
1028     * Launch multiple new activities.  This is generally the same as calling
1029     * {@link #startActivity(Intent)} for the first Intent in the array,
1030     * that activity during its creation calling {@link #startActivity(Intent)}
1031     * for the second entry, etc.  Note that unlike that approach, generally
1032     * none of the activities except the last in the array will be created
1033     * at this point, but rather will be created when the user first visits
1034     * them (due to pressing back from the activity on top).
1035     *
1036     * <p>This method throws {@link ActivityNotFoundException}
1037     * if there was no Activity found for <em>any</em> given Intent.  In this
1038     * case the state of the activity stack is undefined (some Intents in the
1039     * list may be on it, some not), so you probably want to avoid such situations.
1040     *
1041     * @param intents An array of Intents to be started.
1042     * @param options Additional options for how the Activity should be started.
1043     * @param userHandle The user for whom to launch the activities
1044     * See {@link android.content.Context#startActivity(Intent, Bundle)
1045     * Context.startActivity(Intent, Bundle)} for more details.
1046     *
1047     * @throws ActivityNotFoundException &nbsp;
1048     *
1049     * @see #startActivities(Intent[])
1050     * @see PackageManager#resolveActivity
1051     */
1052    public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
1053        throw new RuntimeException("Not implemented. Must override in a subclass.");
1054    }
1055
1056    /**
1057     * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
1058     * with no options specified.
1059     *
1060     * @param intent The IntentSender to launch.
1061     * @param fillInIntent If non-null, this will be provided as the
1062     * intent parameter to {@link IntentSender#sendIntent}.
1063     * @param flagsMask Intent flags in the original IntentSender that you
1064     * would like to change.
1065     * @param flagsValues Desired values for any bits set in
1066     * <var>flagsMask</var>
1067     * @param extraFlags Always set to 0.
1068     *
1069     * @see #startActivity(Intent)
1070     * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle)
1071     */
1072    public abstract void startIntentSender(IntentSender intent,
1073            Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
1074            throws IntentSender.SendIntentException;
1075
1076    /**
1077     * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
1078     * to start.  If the IntentSender is for an activity, that activity will be started
1079     * as if you had called the regular {@link #startActivity(Intent)}
1080     * here; otherwise, its associated action will be executed (such as
1081     * sending a broadcast) as if you had called
1082     * {@link IntentSender#sendIntent IntentSender.sendIntent} on it.
1083     *
1084     * @param intent The IntentSender to launch.
1085     * @param fillInIntent If non-null, this will be provided as the
1086     * intent parameter to {@link IntentSender#sendIntent}.
1087     * @param flagsMask Intent flags in the original IntentSender that you
1088     * would like to change.
1089     * @param flagsValues Desired values for any bits set in
1090     * <var>flagsMask</var>
1091     * @param extraFlags Always set to 0.
1092     * @param options Additional options for how the Activity should be started.
1093     * See {@link android.content.Context#startActivity(Intent, Bundle)
1094     * Context.startActivity(Intent, Bundle)} for more details.  If options
1095     * have also been supplied by the IntentSender, options given here will
1096     * override any that conflict with those given by the IntentSender.
1097     *
1098     * @see #startActivity(Intent, Bundle)
1099     * @see #startIntentSender(IntentSender, Intent, int, int, int)
1100     */
1101    public abstract void startIntentSender(IntentSender intent,
1102            Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
1103            Bundle options) throws IntentSender.SendIntentException;
1104
1105    /**
1106     * Broadcast the given intent to all interested BroadcastReceivers.  This
1107     * call is asynchronous; it returns immediately, and you will continue
1108     * executing while the receivers are run.  No results are propagated from
1109     * receivers and receivers can not abort the broadcast. If you want
1110     * to allow receivers to propagate results or abort the broadcast, you must
1111     * send an ordered broadcast using
1112     * {@link #sendOrderedBroadcast(Intent, String)}.
1113     *
1114     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1115     *
1116     * @param intent The Intent to broadcast; all receivers matching this
1117     *               Intent will receive the broadcast.
1118     *
1119     * @see android.content.BroadcastReceiver
1120     * @see #registerReceiver
1121     * @see #sendBroadcast(Intent, String)
1122     * @see #sendOrderedBroadcast(Intent, String)
1123     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1124     */
1125    public abstract void sendBroadcast(Intent intent);
1126
1127    /**
1128     * Broadcast the given intent to all interested BroadcastReceivers, allowing
1129     * an optional required permission to be enforced.  This
1130     * call is asynchronous; it returns immediately, and you will continue
1131     * executing while the receivers are run.  No results are propagated from
1132     * receivers and receivers can not abort the broadcast. If you want
1133     * to allow receivers to propagate results or abort the broadcast, you must
1134     * send an ordered broadcast using
1135     * {@link #sendOrderedBroadcast(Intent, String)}.
1136     *
1137     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1138     *
1139     * @param intent The Intent to broadcast; all receivers matching this
1140     *               Intent will receive the broadcast.
1141     * @param receiverPermission (optional) String naming a permission that
1142     *               a receiver must hold in order to receive your broadcast.
1143     *               If null, no permission is required.
1144     *
1145     * @see android.content.BroadcastReceiver
1146     * @see #registerReceiver
1147     * @see #sendBroadcast(Intent)
1148     * @see #sendOrderedBroadcast(Intent, String)
1149     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1150     */
1151    public abstract void sendBroadcast(Intent intent,
1152            String receiverPermission);
1153
1154    /**
1155     * Like {@link #sendBroadcast(Intent, String)}, but also allows specification
1156     * of an assocated app op as per {@link android.app.AppOpsManager}.
1157     * @hide
1158     */
1159    public abstract void sendBroadcast(Intent intent,
1160            String receiverPermission, int appOp);
1161
1162    /**
1163     * Broadcast the given intent to all interested BroadcastReceivers, delivering
1164     * them one at a time to allow more preferred receivers to consume the
1165     * broadcast before it is delivered to less preferred receivers.  This
1166     * call is asynchronous; it returns immediately, and you will continue
1167     * executing while the receivers are run.
1168     *
1169     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1170     *
1171     * @param intent The Intent to broadcast; all receivers matching this
1172     *               Intent will receive the broadcast.
1173     * @param receiverPermission (optional) String naming a permissions that
1174     *               a receiver must hold in order to receive your broadcast.
1175     *               If null, no permission is required.
1176     *
1177     * @see android.content.BroadcastReceiver
1178     * @see #registerReceiver
1179     * @see #sendBroadcast(Intent)
1180     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1181     */
1182    public abstract void sendOrderedBroadcast(Intent intent,
1183            String receiverPermission);
1184
1185    /**
1186     * Version of {@link #sendBroadcast(Intent)} that allows you to
1187     * receive data back from the broadcast.  This is accomplished by
1188     * supplying your own BroadcastReceiver when calling, which will be
1189     * treated as a final receiver at the end of the broadcast -- its
1190     * {@link BroadcastReceiver#onReceive} method will be called with
1191     * the result values collected from the other receivers.  The broadcast will
1192     * be serialized in the same way as calling
1193     * {@link #sendOrderedBroadcast(Intent, String)}.
1194     *
1195     * <p>Like {@link #sendBroadcast(Intent)}, this method is
1196     * asynchronous; it will return before
1197     * resultReceiver.onReceive() is called.
1198     *
1199     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1200     *
1201     * @param intent The Intent to broadcast; all receivers matching this
1202     *               Intent will receive the broadcast.
1203     * @param receiverPermission String naming a permissions that
1204     *               a receiver must hold in order to receive your broadcast.
1205     *               If null, no permission is required.
1206     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1207     *                       receiver of the broadcast.
1208     * @param scheduler A custom Handler with which to schedule the
1209     *                  resultReceiver callback; if null it will be
1210     *                  scheduled in the Context's main thread.
1211     * @param initialCode An initial value for the result code.  Often
1212     *                    Activity.RESULT_OK.
1213     * @param initialData An initial value for the result data.  Often
1214     *                    null.
1215     * @param initialExtras An initial value for the result extras.  Often
1216     *                      null.
1217     *
1218     * @see #sendBroadcast(Intent)
1219     * @see #sendBroadcast(Intent, String)
1220     * @see #sendOrderedBroadcast(Intent, String)
1221     * @see #sendStickyBroadcast(Intent)
1222     * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
1223     * @see android.content.BroadcastReceiver
1224     * @see #registerReceiver
1225     * @see android.app.Activity#RESULT_OK
1226     */
1227    public abstract void sendOrderedBroadcast(Intent intent,
1228            String receiverPermission, BroadcastReceiver resultReceiver,
1229            Handler scheduler, int initialCode, String initialData,
1230            Bundle initialExtras);
1231
1232    /**
1233     * Like {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, android.os.Handler,
1234     * int, String, android.os.Bundle)}, but also allows specification
1235     * of an assocated app op as per {@link android.app.AppOpsManager}.
1236     * @hide
1237     */
1238    public abstract void sendOrderedBroadcast(Intent intent,
1239            String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
1240            Handler scheduler, int initialCode, String initialData,
1241            Bundle initialExtras);
1242
1243    /**
1244     * Version of {@link #sendBroadcast(Intent)} that allows you to specify the
1245     * user the broadcast will be sent to.  This is not available to applications
1246     * that are not pre-installed on the system image.  Using it requires holding
1247     * the INTERACT_ACROSS_USERS permission.
1248     * @param intent The intent to broadcast
1249     * @param user UserHandle to send the intent to.
1250     * @see #sendBroadcast(Intent)
1251     */
1252    public abstract void sendBroadcastAsUser(Intent intent, UserHandle user);
1253
1254    /**
1255     * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
1256     * user the broadcast will be sent to.  This is not available to applications
1257     * that are not pre-installed on the system image.  Using it requires holding
1258     * the INTERACT_ACROSS_USERS permission.
1259     *
1260     * @param intent The Intent to broadcast; all receivers matching this
1261     *               Intent will receive the broadcast.
1262     * @param user UserHandle to send the intent to.
1263     * @param receiverPermission (optional) String naming a permission that
1264     *               a receiver must hold in order to receive your broadcast.
1265     *               If null, no permission is required.
1266     *
1267     * @see #sendBroadcast(Intent, String)
1268     */
1269    public abstract void sendBroadcastAsUser(Intent intent, UserHandle user,
1270            String receiverPermission);
1271
1272    /**
1273     * Version of
1274     * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)}
1275     * that allows you to specify the
1276     * user the broadcast will be sent to.  This is not available to applications
1277     * that are not pre-installed on the system image.  Using it requires holding
1278     * the INTERACT_ACROSS_USERS permission.
1279     *
1280     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1281     *
1282     * @param intent The Intent to broadcast; all receivers matching this
1283     *               Intent will receive the broadcast.
1284     * @param user UserHandle to send the intent to.
1285     * @param receiverPermission String naming a permissions that
1286     *               a receiver must hold in order to receive your broadcast.
1287     *               If null, no permission is required.
1288     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1289     *                       receiver of the broadcast.
1290     * @param scheduler A custom Handler with which to schedule the
1291     *                  resultReceiver callback; if null it will be
1292     *                  scheduled in the Context's main thread.
1293     * @param initialCode An initial value for the result code.  Often
1294     *                    Activity.RESULT_OK.
1295     * @param initialData An initial value for the result data.  Often
1296     *                    null.
1297     * @param initialExtras An initial value for the result extras.  Often
1298     *                      null.
1299     *
1300     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1301     */
1302    public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
1303            String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler,
1304            int initialCode, String initialData, Bundle initialExtras);
1305
1306    /**
1307     * Perform a {@link #sendBroadcast(Intent)} that is "sticky," meaning the
1308     * Intent you are sending stays around after the broadcast is complete,
1309     * so that others can quickly retrieve that data through the return
1310     * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}.  In
1311     * all other ways, this behaves the same as
1312     * {@link #sendBroadcast(Intent)}.
1313     *
1314     * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
1315     * permission in order to use this API.  If you do not hold that
1316     * permission, {@link SecurityException} will be thrown.
1317     *
1318     * @param intent The Intent to broadcast; all receivers matching this
1319     * Intent will receive the broadcast, and the Intent will be held to
1320     * be re-broadcast to future receivers.
1321     *
1322     * @see #sendBroadcast(Intent)
1323     * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
1324     */
1325    public abstract void sendStickyBroadcast(Intent intent);
1326
1327    /**
1328     * Version of {@link #sendStickyBroadcast} that allows you to
1329     * receive data back from the broadcast.  This is accomplished by
1330     * supplying your own BroadcastReceiver when calling, which will be
1331     * treated as a final receiver at the end of the broadcast -- its
1332     * {@link BroadcastReceiver#onReceive} method will be called with
1333     * the result values collected from the other receivers.  The broadcast will
1334     * be serialized in the same way as calling
1335     * {@link #sendOrderedBroadcast(Intent, String)}.
1336     *
1337     * <p>Like {@link #sendBroadcast(Intent)}, this method is
1338     * asynchronous; it will return before
1339     * resultReceiver.onReceive() is called.  Note that the sticky data
1340     * stored is only the data you initially supply to the broadcast, not
1341     * the result of any changes made by the receivers.
1342     *
1343     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1344     *
1345     * @param intent The Intent to broadcast; all receivers matching this
1346     *               Intent will receive the broadcast.
1347     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1348     *                       receiver of the broadcast.
1349     * @param scheduler A custom Handler with which to schedule the
1350     *                  resultReceiver callback; if null it will be
1351     *                  scheduled in the Context's main thread.
1352     * @param initialCode An initial value for the result code.  Often
1353     *                    Activity.RESULT_OK.
1354     * @param initialData An initial value for the result data.  Often
1355     *                    null.
1356     * @param initialExtras An initial value for the result extras.  Often
1357     *                      null.
1358     *
1359     * @see #sendBroadcast(Intent)
1360     * @see #sendBroadcast(Intent, String)
1361     * @see #sendOrderedBroadcast(Intent, String)
1362     * @see #sendStickyBroadcast(Intent)
1363     * @see android.content.BroadcastReceiver
1364     * @see #registerReceiver
1365     * @see android.app.Activity#RESULT_OK
1366     */
1367    public abstract void sendStickyOrderedBroadcast(Intent intent,
1368            BroadcastReceiver resultReceiver,
1369            Handler scheduler, int initialCode, String initialData,
1370            Bundle initialExtras);
1371
1372    /**
1373     * Remove the data previously sent with {@link #sendStickyBroadcast},
1374     * so that it is as if the sticky broadcast had never happened.
1375     *
1376     * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
1377     * permission in order to use this API.  If you do not hold that
1378     * permission, {@link SecurityException} will be thrown.
1379     *
1380     * @param intent The Intent that was previously broadcast.
1381     *
1382     * @see #sendStickyBroadcast
1383     */
1384    public abstract void removeStickyBroadcast(Intent intent);
1385
1386    /**
1387     * Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the
1388     * user the broadcast will be sent to.  This is not available to applications
1389     * that are not pre-installed on the system image.  Using it requires holding
1390     * the INTERACT_ACROSS_USERS permission.
1391     *
1392     * @param intent The Intent to broadcast; all receivers matching this
1393     * Intent will receive the broadcast, and the Intent will be held to
1394     * be re-broadcast to future receivers.
1395     * @param user UserHandle to send the intent to.
1396     *
1397     * @see #sendBroadcast(Intent)
1398     */
1399    public abstract void sendStickyBroadcastAsUser(Intent intent, UserHandle user);
1400
1401    /**
1402     * Version of
1403     * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)}
1404     * that allows you to specify the
1405     * user the broadcast will be sent to.  This is not available to applications
1406     * that are not pre-installed on the system image.  Using it requires holding
1407     * the INTERACT_ACROSS_USERS permission.
1408     *
1409     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1410     *
1411     * @param intent The Intent to broadcast; all receivers matching this
1412     *               Intent will receive the broadcast.
1413     * @param user UserHandle to send the intent to.
1414     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1415     *                       receiver of the broadcast.
1416     * @param scheduler A custom Handler with which to schedule the
1417     *                  resultReceiver callback; if null it will be
1418     *                  scheduled in the Context's main thread.
1419     * @param initialCode An initial value for the result code.  Often
1420     *                    Activity.RESULT_OK.
1421     * @param initialData An initial value for the result data.  Often
1422     *                    null.
1423     * @param initialExtras An initial value for the result extras.  Often
1424     *                      null.
1425     *
1426     * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
1427     */
1428    public abstract void sendStickyOrderedBroadcastAsUser(Intent intent,
1429            UserHandle user, BroadcastReceiver resultReceiver,
1430            Handler scheduler, int initialCode, String initialData,
1431            Bundle initialExtras);
1432
1433    /**
1434     * Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the
1435     * user the broadcast will be sent to.  This is not available to applications
1436     * that are not pre-installed on the system image.  Using it requires holding
1437     * the INTERACT_ACROSS_USERS permission.
1438     *
1439     * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
1440     * permission in order to use this API.  If you do not hold that
1441     * permission, {@link SecurityException} will be thrown.
1442     *
1443     * @param intent The Intent that was previously broadcast.
1444     * @param user UserHandle to remove the sticky broadcast from.
1445     *
1446     * @see #sendStickyBroadcastAsUser
1447     */
1448    public abstract void removeStickyBroadcastAsUser(Intent intent, UserHandle user);
1449
1450    /**
1451     * Register a BroadcastReceiver to be run in the main activity thread.  The
1452     * <var>receiver</var> will be called with any broadcast Intent that
1453     * matches <var>filter</var>, in the main application thread.
1454     *
1455     * <p>The system may broadcast Intents that are "sticky" -- these stay
1456     * around after the broadcast as finished, to be sent to any later
1457     * registrations. If your IntentFilter matches one of these sticky
1458     * Intents, that Intent will be returned by this function
1459     * <strong>and</strong> sent to your <var>receiver</var> as if it had just
1460     * been broadcast.
1461     *
1462     * <p>There may be multiple sticky Intents that match <var>filter</var>,
1463     * in which case each of these will be sent to <var>receiver</var>.  In
1464     * this case, only one of these can be returned directly by the function;
1465     * which of these that is returned is arbitrarily decided by the system.
1466     *
1467     * <p>If you know the Intent your are registering for is sticky, you can
1468     * supply null for your <var>receiver</var>.  In this case, no receiver is
1469     * registered -- the function simply returns the sticky Intent that
1470     * matches <var>filter</var>.  In the case of multiple matches, the same
1471     * rules as described above apply.
1472     *
1473     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1474     *
1475     * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers
1476     * registered with this method will correctly respect the
1477     * {@link Intent#setPackage(String)} specified for an Intent being broadcast.
1478     * Prior to that, it would be ignored and delivered to all matching registered
1479     * receivers.  Be careful if using this for security.</p>
1480     *
1481     * <p class="note">Note: this method <em>cannot be called from a
1482     * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver
1483     * that is declared in an application's manifest.  It is okay, however, to call
1484     * this method from another BroadcastReceiver that has itself been registered
1485     * at run time with {@link #registerReceiver}, since the lifetime of such a
1486     * registered BroadcastReceiver is tied to the object that registered it.</p>
1487     *
1488     * @param receiver The BroadcastReceiver to handle the broadcast.
1489     * @param filter Selects the Intent broadcasts to be received.
1490     *
1491     * @return The first sticky intent found that matches <var>filter</var>,
1492     *         or null if there are none.
1493     *
1494     * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
1495     * @see #sendBroadcast
1496     * @see #unregisterReceiver
1497     */
1498    public abstract Intent registerReceiver(BroadcastReceiver receiver,
1499                                            IntentFilter filter);
1500
1501    /**
1502     * Register to receive intent broadcasts, to run in the context of
1503     * <var>scheduler</var>.  See
1504     * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more
1505     * information.  This allows you to enforce permissions on who can
1506     * broadcast intents to your receiver, or have the receiver run in
1507     * a different thread than the main application thread.
1508     *
1509     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1510     *
1511     * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers
1512     * registered with this method will correctly respect the
1513     * {@link Intent#setPackage(String)} specified for an Intent being broadcast.
1514     * Prior to that, it would be ignored and delivered to all matching registered
1515     * receivers.  Be careful if using this for security.</p>
1516     *
1517     * @param receiver The BroadcastReceiver to handle the broadcast.
1518     * @param filter Selects the Intent broadcasts to be received.
1519     * @param broadcastPermission String naming a permissions that a
1520     *      broadcaster must hold in order to send an Intent to you.  If null,
1521     *      no permission is required.
1522     * @param scheduler Handler identifying the thread that will receive
1523     *      the Intent.  If null, the main thread of the process will be used.
1524     *
1525     * @return The first sticky intent found that matches <var>filter</var>,
1526     *         or null if there are none.
1527     *
1528     * @see #registerReceiver(BroadcastReceiver, IntentFilter)
1529     * @see #sendBroadcast
1530     * @see #unregisterReceiver
1531     */
1532    public abstract Intent registerReceiver(BroadcastReceiver receiver,
1533            IntentFilter filter, String broadcastPermission, Handler scheduler);
1534
1535    /**
1536     * @hide
1537     * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
1538     * but for a specific user.  This receiver will receiver broadcasts that
1539     * are sent to the requested user.  It
1540     * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL}
1541     * permission.
1542     *
1543     * @param receiver The BroadcastReceiver to handle the broadcast.
1544     * @param user UserHandle to send the intent to.
1545     * @param filter Selects the Intent broadcasts to be received.
1546     * @param broadcastPermission String naming a permissions that a
1547     *      broadcaster must hold in order to send an Intent to you.  If null,
1548     *      no permission is required.
1549     * @param scheduler Handler identifying the thread that will receive
1550     *      the Intent.  If null, the main thread of the process will be used.
1551     *
1552     * @return The first sticky intent found that matches <var>filter</var>,
1553     *         or null if there are none.
1554     *
1555     * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler
1556     * @see #sendBroadcast
1557     * @see #unregisterReceiver
1558     */
1559    public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver,
1560            UserHandle user, IntentFilter filter, String broadcastPermission,
1561            Handler scheduler);
1562
1563    /**
1564     * Unregister a previously registered BroadcastReceiver.  <em>All</em>
1565     * filters that have been registered for this BroadcastReceiver will be
1566     * removed.
1567     *
1568     * @param receiver The BroadcastReceiver to unregister.
1569     *
1570     * @see #registerReceiver
1571     */
1572    public abstract void unregisterReceiver(BroadcastReceiver receiver);
1573
1574    /**
1575     * Request that a given application service be started.  The Intent
1576     * can either contain the complete class name of a specific service
1577     * implementation to start, or an abstract definition through the
1578     * action and other fields of the kind of service to start.  If this service
1579     * is not already running, it will be instantiated and started (creating a
1580     * process for it if needed); if it is running then it remains running.
1581     *
1582     * <p>Every call to this method will result in a corresponding call to
1583     * the target service's {@link android.app.Service#onStartCommand} method,
1584     * with the <var>intent</var> given here.  This provides a convenient way
1585     * to submit jobs to a service without having to bind and call on to its
1586     * interface.
1587     *
1588     * <p>Using startService() overrides the default service lifetime that is
1589     * managed by {@link #bindService}: it requires the service to remain
1590     * running until {@link #stopService} is called, regardless of whether
1591     * any clients are connected to it.  Note that calls to startService()
1592     * are not nesting: no matter how many times you call startService(),
1593     * a single call to {@link #stopService} will stop it.
1594     *
1595     * <p>The system attempts to keep running services around as much as
1596     * possible.  The only time they should be stopped is if the current
1597     * foreground application is using so many resources that the service needs
1598     * to be killed.  If any errors happen in the service's process, it will
1599     * automatically be restarted.
1600     *
1601     * <p>This function will throw {@link SecurityException} if you do not
1602     * have permission to start the given service.
1603     *
1604     * @param service Identifies the service to be started.  The Intent may
1605     *      specify either an explicit component name to start, or a logical
1606     *      description (action, category, etc) to match an
1607     *      {@link IntentFilter} published by a service.  Additional values
1608     *      may be included in the Intent extras to supply arguments along with
1609     *      this specific start call.
1610     *
1611     * @return If the service is being started or is already running, the
1612     * {@link ComponentName} of the actual service that was started is
1613     * returned; else if the service does not exist null is returned.
1614     *
1615     * @throws SecurityException &nbsp;
1616     *
1617     * @see #stopService
1618     * @see #bindService
1619     */
1620    public abstract ComponentName startService(Intent service);
1621
1622    /**
1623     * Request that a given application service be stopped.  If the service is
1624     * not running, nothing happens.  Otherwise it is stopped.  Note that calls
1625     * to startService() are not counted -- this stops the service no matter
1626     * how many times it was started.
1627     *
1628     * <p>Note that if a stopped service still has {@link ServiceConnection}
1629     * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will
1630     * not be destroyed until all of these bindings are removed.  See
1631     * the {@link android.app.Service} documentation for more details on a
1632     * service's lifecycle.
1633     *
1634     * <p>This function will throw {@link SecurityException} if you do not
1635     * have permission to stop the given service.
1636     *
1637     * @param service Description of the service to be stopped.  The Intent may
1638     *      specify either an explicit component name to start, or a logical
1639     *      description (action, category, etc) to match an
1640     *      {@link IntentFilter} published by a service.
1641     *
1642     * @return If there is a service matching the given Intent that is already
1643     * running, then it is stopped and {@code true} is returned; else {@code false} is returned.
1644     *
1645     * @throws SecurityException &nbsp;
1646     *
1647     * @see #startService
1648     */
1649    public abstract boolean stopService(Intent service);
1650
1651    /**
1652     * @hide like {@link #startService(Intent)} but for a specific user.
1653     */
1654    public abstract ComponentName startServiceAsUser(Intent service, UserHandle user);
1655
1656    /**
1657     * @hide like {@link #stopService(Intent)} but for a specific user.
1658     */
1659    public abstract boolean stopServiceAsUser(Intent service, UserHandle user);
1660
1661    /**
1662     * Connect to an application service, creating it if needed.  This defines
1663     * a dependency between your application and the service.  The given
1664     * <var>conn</var> will receive the service object when it is created and be
1665     * told if it dies and restarts.  The service will be considered required
1666     * by the system only for as long as the calling context exists.  For
1667     * example, if this Context is an Activity that is stopped, the service will
1668     * not be required to continue running until the Activity is resumed.
1669     *
1670     * <p>This function will throw {@link SecurityException} if you do not
1671     * have permission to bind to the given service.
1672     *
1673     * <p class="note">Note: this method <em>can not be called from a
1674     * {@link BroadcastReceiver} component</em>.  A pattern you can use to
1675     * communicate from a BroadcastReceiver to a Service is to call
1676     * {@link #startService} with the arguments containing the command to be
1677     * sent, with the service calling its
1678     * {@link android.app.Service#stopSelf(int)} method when done executing
1679     * that command.  See the API demo App/Service/Service Start Arguments
1680     * Controller for an illustration of this.  It is okay, however, to use
1681     * this method from a BroadcastReceiver that has been registered with
1682     * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver
1683     * is tied to another object (the one that registered it).</p>
1684     *
1685     * @param service Identifies the service to connect to.  The Intent may
1686     *      specify either an explicit component name, or a logical
1687     *      description (action, category, etc) to match an
1688     *      {@link IntentFilter} published by a service.
1689     * @param conn Receives information as the service is started and stopped.
1690     *      This must be a valid ServiceConnection object; it must not be null.
1691     * @param flags Operation options for the binding.  May be 0,
1692     *          {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND},
1693     *          {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT},
1694     *          {@link #BIND_ALLOW_OOM_MANAGEMENT}, or
1695     *          {@link #BIND_WAIVE_PRIORITY}.
1696     * @return If you have successfully bound to the service, {@code true} is returned;
1697     *         {@code false} is returned if the connection is not made so you will not
1698     *         receive the service object.
1699     *
1700     * @throws SecurityException &nbsp;
1701     *
1702     * @see #unbindService
1703     * @see #startService
1704     * @see #BIND_AUTO_CREATE
1705     * @see #BIND_DEBUG_UNBIND
1706     * @see #BIND_NOT_FOREGROUND
1707     */
1708    public abstract boolean bindService(Intent service, ServiceConnection conn,
1709            int flags);
1710
1711    /**
1712     * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle
1713     * argument for use by system server and other multi-user aware code.
1714     * @hide
1715     */
1716    public boolean bindServiceAsUser(Intent service, ServiceConnection conn, int flags, UserHandle user) {
1717        throw new RuntimeException("Not implemented. Must override in a subclass.");
1718    }
1719
1720    /**
1721     * Disconnect from an application service.  You will no longer receive
1722     * calls as the service is restarted, and the service is now allowed to
1723     * stop at any time.
1724     *
1725     * @param conn The connection interface previously supplied to
1726     *             bindService().  This parameter must not be null.
1727     *
1728     * @see #bindService
1729     */
1730    public abstract void unbindService(ServiceConnection conn);
1731
1732    /**
1733     * Start executing an {@link android.app.Instrumentation} class.  The given
1734     * Instrumentation component will be run by killing its target application
1735     * (if currently running), starting the target process, instantiating the
1736     * instrumentation component, and then letting it drive the application.
1737     *
1738     * <p>This function is not synchronous -- it returns as soon as the
1739     * instrumentation has started and while it is running.
1740     *
1741     * <p>Instrumentation is normally only allowed to run against a package
1742     * that is either unsigned or signed with a signature that the
1743     * the instrumentation package is also signed with (ensuring the target
1744     * trusts the instrumentation).
1745     *
1746     * @param className Name of the Instrumentation component to be run.
1747     * @param profileFile Optional path to write profiling data as the
1748     * instrumentation runs, or null for no profiling.
1749     * @param arguments Additional optional arguments to pass to the
1750     * instrumentation, or null.
1751     *
1752     * @return {@code true} if the instrumentation was successfully started,
1753     * else {@code false} if it could not be found.
1754     */
1755    public abstract boolean startInstrumentation(ComponentName className,
1756            String profileFile, Bundle arguments);
1757
1758    /**
1759     * Return the handle to a system-level service by name. The class of the
1760     * returned object varies by the requested name. Currently available names
1761     * are:
1762     *
1763     * <dl>
1764     *  <dt> {@link #WINDOW_SERVICE} ("window")
1765     *  <dd> The top-level window manager in which you can place custom
1766     *  windows.  The returned object is a {@link android.view.WindowManager}.
1767     *  <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater")
1768     *  <dd> A {@link android.view.LayoutInflater} for inflating layout resources
1769     *  in this context.
1770     *  <dt> {@link #ACTIVITY_SERVICE} ("activity")
1771     *  <dd> A {@link android.app.ActivityManager} for interacting with the
1772     *  global activity state of the system.
1773     *  <dt> {@link #POWER_SERVICE} ("power")
1774     *  <dd> A {@link android.os.PowerManager} for controlling power
1775     *  management.
1776     *  <dt> {@link #ALARM_SERVICE} ("alarm")
1777     *  <dd> A {@link android.app.AlarmManager} for receiving intents at the
1778     *  time of your choosing.
1779     *  <dt> {@link #NOTIFICATION_SERVICE} ("notification")
1780     *  <dd> A {@link android.app.NotificationManager} for informing the user
1781     *   of background events.
1782     *  <dt> {@link #KEYGUARD_SERVICE} ("keyguard")
1783     *  <dd> A {@link android.app.KeyguardManager} for controlling keyguard.
1784     *  <dt> {@link #LOCATION_SERVICE} ("location")
1785     *  <dd> A {@link android.location.LocationManager} for controlling location
1786     *   (e.g., GPS) updates.
1787     *  <dt> {@link #SEARCH_SERVICE} ("search")
1788     *  <dd> A {@link android.app.SearchManager} for handling search.
1789     *  <dt> {@link #VIBRATOR_SERVICE} ("vibrator")
1790     *  <dd> A {@link android.os.Vibrator} for interacting with the vibrator
1791     *  hardware.
1792     *  <dt> {@link #CONNECTIVITY_SERVICE} ("connection")
1793     *  <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for
1794     *  handling management of network connections.
1795     *  <dt> {@link #WIFI_SERVICE} ("wifi")
1796     *  <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of
1797     * Wi-Fi connectivity.
1798     * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method")
1799     * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager}
1800     * for management of input methods.
1801     * <dt> {@link #UI_MODE_SERVICE} ("uimode")
1802     * <dd> An {@link android.app.UiModeManager} for controlling UI modes.
1803     * <dt> {@link #DOWNLOAD_SERVICE} ("download")
1804     * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads
1805     * </dl>
1806     *
1807     * <p>Note:  System services obtained via this API may be closely associated with
1808     * the Context in which they are obtained from.  In general, do not share the
1809     * service objects between various different contexts (Activities, Applications,
1810     * Services, Providers, etc.)
1811     *
1812     * @param name The name of the desired service.
1813     *
1814     * @return The service or null if the name does not exist.
1815     *
1816     * @see #WINDOW_SERVICE
1817     * @see android.view.WindowManager
1818     * @see #LAYOUT_INFLATER_SERVICE
1819     * @see android.view.LayoutInflater
1820     * @see #ACTIVITY_SERVICE
1821     * @see android.app.ActivityManager
1822     * @see #POWER_SERVICE
1823     * @see android.os.PowerManager
1824     * @see #ALARM_SERVICE
1825     * @see android.app.AlarmManager
1826     * @see #NOTIFICATION_SERVICE
1827     * @see android.app.NotificationManager
1828     * @see #KEYGUARD_SERVICE
1829     * @see android.app.KeyguardManager
1830     * @see #LOCATION_SERVICE
1831     * @see android.location.LocationManager
1832     * @see #SEARCH_SERVICE
1833     * @see android.app.SearchManager
1834     * @see #SENSOR_SERVICE
1835     * @see android.hardware.SensorManager
1836     * @see #STORAGE_SERVICE
1837     * @see android.os.storage.StorageManager
1838     * @see #VIBRATOR_SERVICE
1839     * @see android.os.Vibrator
1840     * @see #CONNECTIVITY_SERVICE
1841     * @see android.net.ConnectivityManager
1842     * @see #WIFI_SERVICE
1843     * @see android.net.wifi.WifiManager
1844     * @see #AUDIO_SERVICE
1845     * @see android.media.AudioManager
1846     * @see #MEDIA_ROUTER_SERVICE
1847     * @see android.media.MediaRouter
1848     * @see #TELEPHONY_SERVICE
1849     * @see android.telephony.TelephonyManager
1850     * @see #INPUT_METHOD_SERVICE
1851     * @see android.view.inputmethod.InputMethodManager
1852     * @see #UI_MODE_SERVICE
1853     * @see android.app.UiModeManager
1854     * @see #DOWNLOAD_SERVICE
1855     * @see android.app.DownloadManager
1856     */
1857    public abstract Object getSystemService(String name);
1858
1859    /**
1860     * Use with {@link #getSystemService} to retrieve a
1861     * {@link android.os.PowerManager} for controlling power management,
1862     * including "wake locks," which let you keep the device on while
1863     * you're running long tasks.
1864     */
1865    public static final String POWER_SERVICE = "power";
1866
1867    /**
1868     * Use with {@link #getSystemService} to retrieve a
1869     * {@link android.view.WindowManager} for accessing the system's window
1870     * manager.
1871     *
1872     * @see #getSystemService
1873     * @see android.view.WindowManager
1874     */
1875    public static final String WINDOW_SERVICE = "window";
1876
1877    /**
1878     * Use with {@link #getSystemService} to retrieve a
1879     * {@link android.view.LayoutInflater} for inflating layout resources in this
1880     * context.
1881     *
1882     * @see #getSystemService
1883     * @see android.view.LayoutInflater
1884     */
1885    public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater";
1886
1887    /**
1888     * Use with {@link #getSystemService} to retrieve a
1889     * {@link android.accounts.AccountManager} for receiving intents at a
1890     * time of your choosing.
1891     *
1892     * @see #getSystemService
1893     * @see android.accounts.AccountManager
1894     */
1895    public static final String ACCOUNT_SERVICE = "account";
1896
1897    /**
1898     * Use with {@link #getSystemService} to retrieve a
1899     * {@link android.app.ActivityManager} for interacting with the global
1900     * system state.
1901     *
1902     * @see #getSystemService
1903     * @see android.app.ActivityManager
1904     */
1905    public static final String ACTIVITY_SERVICE = "activity";
1906
1907    /**
1908     * Use with {@link #getSystemService} to retrieve a
1909     * {@link android.app.AlarmManager} for receiving intents at a
1910     * time of your choosing.
1911     *
1912     * @see #getSystemService
1913     * @see android.app.AlarmManager
1914     */
1915    public static final String ALARM_SERVICE = "alarm";
1916
1917    /**
1918     * Use with {@link #getSystemService} to retrieve a
1919     * {@link android.app.NotificationManager} for informing the user of
1920     * background events.
1921     *
1922     * @see #getSystemService
1923     * @see android.app.NotificationManager
1924     */
1925    public static final String NOTIFICATION_SERVICE = "notification";
1926
1927    /**
1928     * Use with {@link #getSystemService} to retrieve a
1929     * {@link android.view.accessibility.AccessibilityManager} for giving the user
1930     * feedback for UI events through the registered event listeners.
1931     *
1932     * @see #getSystemService
1933     * @see android.view.accessibility.AccessibilityManager
1934     */
1935    public static final String ACCESSIBILITY_SERVICE = "accessibility";
1936
1937    /**
1938     * Use with {@link #getSystemService} to retrieve a
1939     * {@link android.app.NotificationManager} for controlling keyguard.
1940     *
1941     * @see #getSystemService
1942     * @see android.app.KeyguardManager
1943     */
1944    public static final String KEYGUARD_SERVICE = "keyguard";
1945
1946    /**
1947     * Use with {@link #getSystemService} to retrieve a {@link
1948     * android.location.LocationManager} for controlling location
1949     * updates.
1950     *
1951     * @see #getSystemService
1952     * @see android.location.LocationManager
1953     */
1954    public static final String LOCATION_SERVICE = "location";
1955
1956    /**
1957     * Use with {@link #getSystemService} to retrieve a
1958     * {@link android.location.CountryDetector} for detecting the country that
1959     * the user is in.
1960     *
1961     * @hide
1962     */
1963    public static final String COUNTRY_DETECTOR = "country_detector";
1964
1965    /**
1966     * Use with {@link #getSystemService} to retrieve a {@link
1967     * android.app.SearchManager} for handling searches.
1968     *
1969     * @see #getSystemService
1970     * @see android.app.SearchManager
1971     */
1972    public static final String SEARCH_SERVICE = "search";
1973
1974    /**
1975     * Use with {@link #getSystemService} to retrieve a {@link
1976     * android.hardware.SensorManager} for accessing sensors.
1977     *
1978     * @see #getSystemService
1979     * @see android.hardware.SensorManager
1980     */
1981    public static final String SENSOR_SERVICE = "sensor";
1982
1983    /**
1984     * Use with {@link #getSystemService} to retrieve a {@link
1985     * android.os.storage.StorageManager} for accessing system storage
1986     * functions.
1987     *
1988     * @see #getSystemService
1989     * @see android.os.storage.StorageManager
1990     */
1991    public static final String STORAGE_SERVICE = "storage";
1992
1993    /**
1994     * Use with {@link #getSystemService} to retrieve a
1995     * com.android.server.WallpaperService for accessing wallpapers.
1996     *
1997     * @see #getSystemService
1998     */
1999    public static final String WALLPAPER_SERVICE = "wallpaper";
2000
2001    /**
2002     * Use with {@link #getSystemService} to retrieve a {@link
2003     * android.os.Vibrator} for interacting with the vibration hardware.
2004     *
2005     * @see #getSystemService
2006     * @see android.os.Vibrator
2007     */
2008    public static final String VIBRATOR_SERVICE = "vibrator";
2009
2010    /**
2011     * Use with {@link #getSystemService} to retrieve a {@link
2012     * android.app.StatusBarManager} for interacting with the status bar.
2013     *
2014     * @see #getSystemService
2015     * @see android.app.StatusBarManager
2016     * @hide
2017     */
2018    public static final String STATUS_BAR_SERVICE = "statusbar";
2019
2020    /**
2021     * Use with {@link #getSystemService} to retrieve a {@link
2022     * android.net.ConnectivityManager} for handling management of
2023     * network connections.
2024     *
2025     * @see #getSystemService
2026     * @see android.net.ConnectivityManager
2027     */
2028    public static final String CONNECTIVITY_SERVICE = "connectivity";
2029
2030    /**
2031     * Use with {@link #getSystemService} to retrieve a {@link
2032     * android.os.IUpdateLock} for managing runtime sequences that
2033     * must not be interrupted by headless OTA application or similar.
2034     *
2035     * @hide
2036     * @see #getSystemService
2037     * @see android.os.UpdateLock
2038     */
2039    public static final String UPDATE_LOCK_SERVICE = "updatelock";
2040
2041    /**
2042     * Use with {@link #getSystemService} to retrieve a {@link
2043     * android.net.NetworkManagementService} for handling management of
2044     * system network services
2045     *
2046     * @hide
2047     * @see #getSystemService
2048     * @see android.net.NetworkManagementService
2049     */
2050    public static final String NETWORKMANAGEMENT_SERVICE = "network_management";
2051
2052    /** {@hide} */
2053    public static final String NETWORK_STATS_SERVICE = "netstats";
2054    /** {@hide} */
2055    public static final String NETWORK_POLICY_SERVICE = "netpolicy";
2056
2057    /**
2058     * Use with {@link #getSystemService} to retrieve a {@link
2059     * android.net.wifi.WifiManager} for handling management of
2060     * Wi-Fi access.
2061     *
2062     * @see #getSystemService
2063     * @see android.net.wifi.WifiManager
2064     */
2065    public static final String WIFI_SERVICE = "wifi";
2066
2067    /**
2068     * Use with {@link #getSystemService} to retrieve a {@link
2069     * android.net.wifi.p2p.WifiP2pManager} for handling management of
2070     * Wi-Fi peer-to-peer connections.
2071     *
2072     * @see #getSystemService
2073     * @see android.net.wifi.p2p.WifiP2pManager
2074     */
2075    public static final String WIFI_P2P_SERVICE = "wifip2p";
2076
2077    /**
2078     * Use with {@link #getSystemService} to retrieve a {@link
2079     * android.net.nsd.NsdManager} for handling management of network service
2080     * discovery
2081     *
2082     * @see #getSystemService
2083     * @see android.net.nsd.NsdManager
2084     */
2085    public static final String NSD_SERVICE = "servicediscovery";
2086
2087    /**
2088     * Use with {@link #getSystemService} to retrieve a
2089     * {@link android.media.AudioManager} for handling management of volume,
2090     * ringer modes and audio routing.
2091     *
2092     * @see #getSystemService
2093     * @see android.media.AudioManager
2094     */
2095    public static final String AUDIO_SERVICE = "audio";
2096
2097    /**
2098     * Use with {@link #getSystemService} to retrieve a
2099     * {@link android.media.MediaRouter} for controlling and managing
2100     * routing of media.
2101     *
2102     * @see #getSystemService
2103     * @see android.media.MediaRouter
2104     */
2105    public static final String MEDIA_ROUTER_SERVICE = "media_router";
2106
2107    /**
2108     * Use with {@link #getSystemService} to retrieve a
2109     * {@link android.telephony.TelephonyManager} for handling management the
2110     * telephony features of the device.
2111     *
2112     * @see #getSystemService
2113     * @see android.telephony.TelephonyManager
2114     */
2115    public static final String TELEPHONY_SERVICE = "phone";
2116
2117    /**
2118     * Use with {@link #getSystemService} to retrieve a
2119     * {@link android.text.ClipboardManager} for accessing and modifying
2120     * the contents of the global clipboard.
2121     *
2122     * @see #getSystemService
2123     * @see android.text.ClipboardManager
2124     */
2125    public static final String CLIPBOARD_SERVICE = "clipboard";
2126
2127    /**
2128     * Use with {@link #getSystemService} to retrieve a
2129     * {@link android.view.inputmethod.InputMethodManager} for accessing input
2130     * methods.
2131     *
2132     * @see #getSystemService
2133     */
2134    public static final String INPUT_METHOD_SERVICE = "input_method";
2135
2136    /**
2137     * Use with {@link #getSystemService} to retrieve a
2138     * {@link android.view.textservice.TextServicesManager} for accessing
2139     * text services.
2140     *
2141     * @see #getSystemService
2142     */
2143    public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices";
2144
2145    /**
2146     * Use with {@link #getSystemService} to retrieve a
2147     * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets.
2148     *
2149     * @hide
2150     * @see #getSystemService
2151     */
2152    public static final String APPWIDGET_SERVICE = "appwidget";
2153
2154    /**
2155     * Use with {@link #getSystemService} to retrieve an
2156     * {@link android.app.backup.IBackupManager IBackupManager} for communicating
2157     * with the backup mechanism.
2158     * @hide
2159     *
2160     * @see #getSystemService
2161     */
2162    public static final String BACKUP_SERVICE = "backup";
2163
2164    /**
2165     * Use with {@link #getSystemService} to retrieve a
2166     * {@link android.os.DropBoxManager} instance for recording
2167     * diagnostic logs.
2168     * @see #getSystemService
2169     */
2170    public static final String DROPBOX_SERVICE = "dropbox";
2171
2172    /**
2173     * Use with {@link #getSystemService} to retrieve a
2174     * {@link android.app.admin.DevicePolicyManager} for working with global
2175     * device policy management.
2176     *
2177     * @see #getSystemService
2178     */
2179    public static final String DEVICE_POLICY_SERVICE = "device_policy";
2180
2181    /**
2182     * Use with {@link #getSystemService} to retrieve a
2183     * {@link android.app.UiModeManager} for controlling UI modes.
2184     *
2185     * @see #getSystemService
2186     */
2187    public static final String UI_MODE_SERVICE = "uimode";
2188
2189    /**
2190     * Use with {@link #getSystemService} to retrieve a
2191     * {@link android.app.DownloadManager} for requesting HTTP downloads.
2192     *
2193     * @see #getSystemService
2194     */
2195    public static final String DOWNLOAD_SERVICE = "download";
2196
2197    /**
2198     * Use with {@link #getSystemService} to retrieve a
2199     * {@link android.nfc.NfcManager} for using NFC.
2200     *
2201     * @see #getSystemService
2202     */
2203    public static final String NFC_SERVICE = "nfc";
2204
2205    /**
2206     * Use with {@link #getSystemService} to retrieve a
2207     * {@link android.bluetooth.BluetoothAdapter} for using Bluetooth.
2208     *
2209     * @see #getSystemService
2210     */
2211    public static final String BLUETOOTH_SERVICE = "bluetooth";
2212
2213    /**
2214     * Use with {@link #getSystemService} to retrieve a
2215     * {@link android.net.sip.SipManager} for accessing the SIP related service.
2216     *
2217     * @see #getSystemService
2218     */
2219    /** @hide */
2220    public static final String SIP_SERVICE = "sip";
2221
2222    /**
2223     * Use with {@link #getSystemService} to retrieve a {@link
2224     * android.hardware.usb.UsbManager} for access to USB devices (as a USB host)
2225     * and for controlling this device's behavior as a USB device.
2226     *
2227     * @see #getSystemService
2228     * @see android.hardware.usb.UsbManager
2229     */
2230    public static final String USB_SERVICE = "usb";
2231
2232    /**
2233     * Use with {@link #getSystemService} to retrieve a {@link
2234     * android.hardware.SerialManager} for access to serial ports.
2235     *
2236     * @see #getSystemService
2237     * @see android.harware.SerialManager
2238     *
2239     * @hide
2240     */
2241    public static final String SERIAL_SERVICE = "serial";
2242
2243    /**
2244     * Use with {@link #getSystemService} to retrieve a
2245     * {@link android.hardware.input.InputManager} for interacting with input devices.
2246     *
2247     * @see #getSystemService
2248     * @see android.hardware.input.InputManager
2249     */
2250    public static final String INPUT_SERVICE = "input";
2251
2252    /**
2253     * Use with {@link #getSystemService} to retrieve a
2254     * {@link android.hardware.display.DisplayManager} for interacting with display devices.
2255     *
2256     * @see #getSystemService
2257     * @see android.hardware.display.DisplayManager
2258     */
2259    public static final String DISPLAY_SERVICE = "display";
2260
2261    /**
2262     * Use with {@link #getSystemService} to retrieve a
2263     * {@link android.os.SchedulingPolicyService} for managing scheduling policy.
2264     *
2265     * @see #getSystemService
2266     * @see android.os.SchedulingPolicyService
2267     *
2268     * @hide
2269     */
2270    public static final String SCHEDULING_POLICY_SERVICE = "scheduling_policy";
2271
2272    /**
2273     * Use with {@link #getSystemService} to retrieve a
2274     * {@link android.os.UserManager} for managing users on devices that support multiple users.
2275     *
2276     * @see #getSystemService
2277     * @see android.os.UserManager
2278     */
2279    public static final String USER_SERVICE = "user";
2280
2281    /**
2282     * Use with {@link #getSystemService} to retrieve a
2283     * {@link android.app.AppOpsManager} for tracking application operations
2284     * on the device.
2285     *
2286     * @see #getSystemService
2287     * @see android.app.AppOpsManager
2288     *
2289     * @hide
2290     */
2291    public static final String APP_OPS_SERVICE = "appops";
2292
2293    /**
2294     * Use with {@link #getSystemService} to retrieve a
2295     * {@link android.hardware.camera2.CameraManager} for interacting with
2296     * camera devices.
2297     *
2298     * @see #getSystemService
2299     * @see android.hardware.camera.CameraManager
2300     */
2301    public static final String CAMERA_SERVICE = "camera";
2302
2303    /**
2304     * {@link android.print.PrintManager} for printing and managing
2305     * printers and print taks.
2306     *
2307     * @see #getSystemService
2308     * @see android.print.PrintManager
2309     */
2310    public static final String PRINT_SERVICE = "print";
2311
2312    /**
2313     * Determine whether the given permission is allowed for a particular
2314     * process and user ID running in the system.
2315     *
2316     * @param permission The name of the permission being checked.
2317     * @param pid The process ID being checked against.  Must be > 0.
2318     * @param uid The user ID being checked against.  A uid of 0 is the root
2319     * user, which will pass every permission check.
2320     *
2321     * @return {@link PackageManager#PERMISSION_GRANTED} if the given
2322     * pid/uid is allowed that permission, or
2323     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2324     *
2325     * @see PackageManager#checkPermission(String, String)
2326     * @see #checkCallingPermission
2327     */
2328    public abstract int checkPermission(String permission, int pid, int uid);
2329
2330    /**
2331     * Determine whether the calling process of an IPC you are handling has been
2332     * granted a particular permission.  This is basically the same as calling
2333     * {@link #checkPermission(String, int, int)} with the pid and uid returned
2334     * by {@link android.os.Binder#getCallingPid} and
2335     * {@link android.os.Binder#getCallingUid}.  One important difference
2336     * is that if you are not currently processing an IPC, this function
2337     * will always fail.  This is done to protect against accidentally
2338     * leaking permissions; you can use {@link #checkCallingOrSelfPermission}
2339     * to avoid this protection.
2340     *
2341     * @param permission The name of the permission being checked.
2342     *
2343     * @return {@link PackageManager#PERMISSION_GRANTED} if the calling
2344     * pid/uid is allowed that permission, or
2345     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2346     *
2347     * @see PackageManager#checkPermission(String, String)
2348     * @see #checkPermission
2349     * @see #checkCallingOrSelfPermission
2350     */
2351    public abstract int checkCallingPermission(String permission);
2352
2353    /**
2354     * Determine whether the calling process of an IPC <em>or you</em> have been
2355     * granted a particular permission.  This is the same as
2356     * {@link #checkCallingPermission}, except it grants your own permissions
2357     * if you are not currently processing an IPC.  Use with care!
2358     *
2359     * @param permission The name of the permission being checked.
2360     *
2361     * @return {@link PackageManager#PERMISSION_GRANTED} if the calling
2362     * pid/uid is allowed that permission, or
2363     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2364     *
2365     * @see PackageManager#checkPermission(String, String)
2366     * @see #checkPermission
2367     * @see #checkCallingPermission
2368     */
2369    public abstract int checkCallingOrSelfPermission(String permission);
2370
2371    /**
2372     * If the given permission is not allowed for a particular process
2373     * and user ID running in the system, throw a {@link SecurityException}.
2374     *
2375     * @param permission The name of the permission being checked.
2376     * @param pid The process ID being checked against.  Must be &gt; 0.
2377     * @param uid The user ID being checked against.  A uid of 0 is the root
2378     * user, which will pass every permission check.
2379     * @param message A message to include in the exception if it is thrown.
2380     *
2381     * @see #checkPermission(String, int, int)
2382     */
2383    public abstract void enforcePermission(
2384            String permission, int pid, int uid, String message);
2385
2386    /**
2387     * If the calling process of an IPC you are handling has not been
2388     * granted a particular permission, throw a {@link
2389     * SecurityException}.  This is basically the same as calling
2390     * {@link #enforcePermission(String, int, int, String)} with the
2391     * pid and uid returned by {@link android.os.Binder#getCallingPid}
2392     * and {@link android.os.Binder#getCallingUid}.  One important
2393     * difference is that if you are not currently processing an IPC,
2394     * this function will always throw the SecurityException.  This is
2395     * done to protect against accidentally leaking permissions; you
2396     * can use {@link #enforceCallingOrSelfPermission} to avoid this
2397     * protection.
2398     *
2399     * @param permission The name of the permission being checked.
2400     * @param message A message to include in the exception if it is thrown.
2401     *
2402     * @see #checkCallingPermission(String)
2403     */
2404    public abstract void enforceCallingPermission(
2405            String permission, String message);
2406
2407    /**
2408     * If neither you nor the calling process of an IPC you are
2409     * handling has been granted a particular permission, throw a
2410     * {@link SecurityException}.  This is the same as {@link
2411     * #enforceCallingPermission}, except it grants your own
2412     * permissions if you are not currently processing an IPC.  Use
2413     * with care!
2414     *
2415     * @param permission The name of the permission being checked.
2416     * @param message A message to include in the exception if it is thrown.
2417     *
2418     * @see #checkCallingOrSelfPermission(String)
2419     */
2420    public abstract void enforceCallingOrSelfPermission(
2421            String permission, String message);
2422
2423    /**
2424     * Grant permission to access a specific Uri to another package, regardless
2425     * of whether that package has general permission to access the Uri's
2426     * content provider.  This can be used to grant specific, temporary
2427     * permissions, typically in response to user interaction (such as the
2428     * user opening an attachment that you would like someone else to
2429     * display).
2430     *
2431     * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION
2432     * Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2433     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION
2434     * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to
2435     * start an activity instead of this function directly.  If you use this
2436     * function directly, you should be sure to call
2437     * {@link #revokeUriPermission} when the target should no longer be allowed
2438     * to access it.
2439     *
2440     * <p>To succeed, the content provider owning the Uri must have set the
2441     * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
2442     * grantUriPermissions} attribute in its manifest or included the
2443     * {@link android.R.styleable#AndroidManifestGrantUriPermission
2444     * &lt;grant-uri-permissions&gt;} tag.
2445     *
2446     * @param toPackage The package you would like to allow to access the Uri.
2447     * @param uri The Uri you would like to grant access to.
2448     * @param modeFlags The desired access modes.  Any combination of
2449     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION
2450     * Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2451     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION
2452     * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2453     *
2454     * @see #revokeUriPermission
2455     */
2456    public abstract void grantUriPermission(String toPackage, Uri uri,
2457            int modeFlags);
2458
2459    /**
2460     * Remove all permissions to access a particular content provider Uri
2461     * that were previously added with {@link #grantUriPermission}.  The given
2462     * Uri will match all previously granted Uris that are the same or a
2463     * sub-path of the given Uri.  That is, revoking "content://foo/target" will
2464     * revoke both "content://foo/target" and "content://foo/target/sub", but not
2465     * "content://foo".
2466     *
2467     * @param uri The Uri you would like to revoke access to.
2468     * @param modeFlags The desired access modes.  Any combination of
2469     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION
2470     * Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2471     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION
2472     * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2473     *
2474     * @see #grantUriPermission
2475     */
2476    public abstract void revokeUriPermission(Uri uri, int modeFlags);
2477
2478    /**
2479     * Determine whether a particular process and user ID has been granted
2480     * permission to access a specific URI.  This only checks for permissions
2481     * that have been explicitly granted -- if the given process/uid has
2482     * more general access to the URI's content provider then this check will
2483     * always fail.
2484     *
2485     * @param uri The uri that is being checked.
2486     * @param pid The process ID being checked against.  Must be &gt; 0.
2487     * @param uid The user ID being checked against.  A uid of 0 is the root
2488     * user, which will pass every permission check.
2489     * @param modeFlags The type of access to grant.  May be one or both of
2490     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2491     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2492     *
2493     * @return {@link PackageManager#PERMISSION_GRANTED} if the given
2494     * pid/uid is allowed to access that uri, or
2495     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2496     *
2497     * @see #checkCallingUriPermission
2498     */
2499    public abstract int checkUriPermission(Uri uri, int pid, int uid, int modeFlags);
2500
2501    /**
2502     * Determine whether the calling process and user ID has been
2503     * granted permission to access a specific URI.  This is basically
2504     * the same as calling {@link #checkUriPermission(Uri, int, int,
2505     * int)} with the pid and uid returned by {@link
2506     * android.os.Binder#getCallingPid} and {@link
2507     * android.os.Binder#getCallingUid}.  One important difference is
2508     * that if you are not currently processing an IPC, this function
2509     * will always fail.
2510     *
2511     * @param uri The uri that is being checked.
2512     * @param modeFlags The type of access to grant.  May be one or both of
2513     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2514     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2515     *
2516     * @return {@link PackageManager#PERMISSION_GRANTED} if the caller
2517     * is allowed to access that uri, or
2518     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2519     *
2520     * @see #checkUriPermission(Uri, int, int, int)
2521     */
2522    public abstract int checkCallingUriPermission(Uri uri, int modeFlags);
2523
2524    /**
2525     * Determine whether the calling process of an IPC <em>or you</em> has been granted
2526     * permission to access a specific URI.  This is the same as
2527     * {@link #checkCallingUriPermission}, except it grants your own permissions
2528     * if you are not currently processing an IPC.  Use with care!
2529     *
2530     * @param uri The uri that is being checked.
2531     * @param modeFlags The type of access to grant.  May be one or both of
2532     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2533     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2534     *
2535     * @return {@link PackageManager#PERMISSION_GRANTED} if the caller
2536     * is allowed to access that uri, or
2537     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2538     *
2539     * @see #checkCallingUriPermission
2540     */
2541    public abstract int checkCallingOrSelfUriPermission(Uri uri, int modeFlags);
2542
2543    /**
2544     * Check both a Uri and normal permission.  This allows you to perform
2545     * both {@link #checkPermission} and {@link #checkUriPermission} in one
2546     * call.
2547     *
2548     * @param uri The Uri whose permission is to be checked, or null to not
2549     * do this check.
2550     * @param readPermission The permission that provides overall read access,
2551     * or null to not do this check.
2552     * @param writePermission The permission that provides overall write
2553     * acess, or null to not do this check.
2554     * @param pid The process ID being checked against.  Must be &gt; 0.
2555     * @param uid The user ID being checked against.  A uid of 0 is the root
2556     * user, which will pass every permission check.
2557     * @param modeFlags The type of access to grant.  May be one or both of
2558     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2559     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2560     *
2561     * @return {@link PackageManager#PERMISSION_GRANTED} if the caller
2562     * is allowed to access that uri or holds one of the given permissions, or
2563     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2564     */
2565    public abstract int checkUriPermission(Uri uri, String readPermission,
2566            String writePermission, int pid, int uid, int modeFlags);
2567
2568    /**
2569     * If a particular process and user ID has not been granted
2570     * permission to access a specific URI, throw {@link
2571     * SecurityException}.  This only checks for permissions that have
2572     * been explicitly granted -- if the given process/uid has more
2573     * general access to the URI's content provider then this check
2574     * will always fail.
2575     *
2576     * @param uri The uri that is being checked.
2577     * @param pid The process ID being checked against.  Must be &gt; 0.
2578     * @param uid The user ID being checked against.  A uid of 0 is the root
2579     * user, which will pass every permission check.
2580     * @param modeFlags The type of access to grant.  May be one or both of
2581     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2582     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2583     * @param message A message to include in the exception if it is thrown.
2584     *
2585     * @see #checkUriPermission(Uri, int, int, int)
2586     */
2587    public abstract void enforceUriPermission(
2588            Uri uri, int pid, int uid, int modeFlags, String message);
2589
2590    /**
2591     * If the calling process and user ID has not been granted
2592     * permission to access a specific URI, throw {@link
2593     * SecurityException}.  This is basically the same as calling
2594     * {@link #enforceUriPermission(Uri, int, int, int, String)} with
2595     * the pid and uid returned by {@link
2596     * android.os.Binder#getCallingPid} and {@link
2597     * android.os.Binder#getCallingUid}.  One important difference is
2598     * that if you are not currently processing an IPC, this function
2599     * will always throw a SecurityException.
2600     *
2601     * @param uri The uri that is being checked.
2602     * @param modeFlags The type of access to grant.  May be one or both of
2603     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2604     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2605     * @param message A message to include in the exception if it is thrown.
2606     *
2607     * @see #checkCallingUriPermission(Uri, int)
2608     */
2609    public abstract void enforceCallingUriPermission(
2610            Uri uri, int modeFlags, String message);
2611
2612    /**
2613     * If the calling process of an IPC <em>or you</em> has not been
2614     * granted permission to access a specific URI, throw {@link
2615     * SecurityException}.  This is the same as {@link
2616     * #enforceCallingUriPermission}, except it grants your own
2617     * permissions if you are not currently processing an IPC.  Use
2618     * with care!
2619     *
2620     * @param uri The uri that is being checked.
2621     * @param modeFlags The type of access to grant.  May be one or both of
2622     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2623     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2624     * @param message A message to include in the exception if it is thrown.
2625     *
2626     * @see #checkCallingOrSelfUriPermission(Uri, int)
2627     */
2628    public abstract void enforceCallingOrSelfUriPermission(
2629            Uri uri, int modeFlags, String message);
2630
2631    /**
2632     * Enforce both a Uri and normal permission.  This allows you to perform
2633     * both {@link #enforcePermission} and {@link #enforceUriPermission} in one
2634     * call.
2635     *
2636     * @param uri The Uri whose permission is to be checked, or null to not
2637     * do this check.
2638     * @param readPermission The permission that provides overall read access,
2639     * or null to not do this check.
2640     * @param writePermission The permission that provides overall write
2641     * acess, or null to not do this check.
2642     * @param pid The process ID being checked against.  Must be &gt; 0.
2643     * @param uid The user ID being checked against.  A uid of 0 is the root
2644     * user, which will pass every permission check.
2645     * @param modeFlags The type of access to grant.  May be one or both of
2646     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2647     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2648     * @param message A message to include in the exception if it is thrown.
2649     *
2650     * @see #checkUriPermission(Uri, String, String, int, int, int)
2651     */
2652    public abstract void enforceUriPermission(
2653            Uri uri, String readPermission, String writePermission,
2654            int pid, int uid, int modeFlags, String message);
2655
2656    /**
2657     * Flag for use with {@link #createPackageContext}: include the application
2658     * code with the context.  This means loading code into the caller's
2659     * process, so that {@link #getClassLoader()} can be used to instantiate
2660     * the application's classes.  Setting this flags imposes security
2661     * restrictions on what application context you can access; if the
2662     * requested application can not be safely loaded into your process,
2663     * java.lang.SecurityException will be thrown.  If this flag is not set,
2664     * there will be no restrictions on the packages that can be loaded,
2665     * but {@link #getClassLoader} will always return the default system
2666     * class loader.
2667     */
2668    public static final int CONTEXT_INCLUDE_CODE = 0x00000001;
2669
2670    /**
2671     * Flag for use with {@link #createPackageContext}: ignore any security
2672     * restrictions on the Context being requested, allowing it to always
2673     * be loaded.  For use with {@link #CONTEXT_INCLUDE_CODE} to allow code
2674     * to be loaded into a process even when it isn't safe to do so.  Use
2675     * with extreme care!
2676     */
2677    public static final int CONTEXT_IGNORE_SECURITY = 0x00000002;
2678
2679    /**
2680     * Flag for use with {@link #createPackageContext}: a restricted context may
2681     * disable specific features. For instance, a View associated with a restricted
2682     * context would ignore particular XML attributes.
2683     */
2684    public static final int CONTEXT_RESTRICTED = 0x00000004;
2685
2686    /**
2687     * Return a new Context object for the given application name.  This
2688     * Context is the same as what the named application gets when it is
2689     * launched, containing the same resources and class loader.  Each call to
2690     * this method returns a new instance of a Context object; Context objects
2691     * are not shared, however they share common state (Resources, ClassLoader,
2692     * etc) so the Context instance itself is fairly lightweight.
2693     *
2694     * <p>Throws {@link PackageManager.NameNotFoundException} if there is no
2695     * application with the given package name.
2696     *
2697     * <p>Throws {@link java.lang.SecurityException} if the Context requested
2698     * can not be loaded into the caller's process for security reasons (see
2699     * {@link #CONTEXT_INCLUDE_CODE} for more information}.
2700     *
2701     * @param packageName Name of the application's package.
2702     * @param flags Option flags, one of {@link #CONTEXT_INCLUDE_CODE}
2703     *              or {@link #CONTEXT_IGNORE_SECURITY}.
2704     *
2705     * @return A {@link Context} for the application.
2706     *
2707     * @throws SecurityException &nbsp;
2708     * @throws PackageManager.NameNotFoundException if there is no application with
2709     * the given package name.
2710     */
2711    public abstract Context createPackageContext(String packageName,
2712            int flags) throws PackageManager.NameNotFoundException;
2713
2714    /**
2715     * Similar to {@link #createPackageContext(String, int)}, but with a
2716     * different {@link UserHandle}. For example, {@link #getContentResolver()}
2717     * will open any {@link Uri} as the given user.
2718     *
2719     * @hide
2720     */
2721    public abstract Context createPackageContextAsUser(
2722            String packageName, int flags, UserHandle user)
2723            throws PackageManager.NameNotFoundException;
2724
2725    /**
2726     * Get the userId associated with this context
2727     * @return user id
2728     *
2729     * @hide
2730     */
2731    public abstract int getUserId();
2732
2733    /**
2734     * Return a new Context object for the current Context but whose resources
2735     * are adjusted to match the given Configuration.  Each call to this method
2736     * returns a new instance of a Context object; Context objects are not
2737     * shared, however common state (ClassLoader, other Resources for the
2738     * same configuration) may be so the Context itself can be fairly lightweight.
2739     *
2740     * @param overrideConfiguration A {@link Configuration} specifying what
2741     * values to modify in the base Configuration of the original Context's
2742     * resources.  If the base configuration changes (such as due to an
2743     * orientation change), the resources of this context will also change except
2744     * for those that have been explicitly overridden with a value here.
2745     *
2746     * @return A {@link Context} with the given configuration override.
2747     */
2748    public abstract Context createConfigurationContext(Configuration overrideConfiguration);
2749
2750    /**
2751     * Return a new Context object for the current Context but whose resources
2752     * are adjusted to match the metrics of the given Display.  Each call to this method
2753     * returns a new instance of a Context object; Context objects are not
2754     * shared, however common state (ClassLoader, other Resources for the
2755     * same configuration) may be so the Context itself can be fairly lightweight.
2756     *
2757     * The returned display Context provides a {@link WindowManager}
2758     * (see {@link #getSystemService(String)}) that is configured to show windows
2759     * on the given display.  The WindowManager's {@link WindowManager#getDefaultDisplay}
2760     * method can be used to retrieve the Display from the returned Context.
2761     *
2762     * @param display A {@link Display} object specifying the display
2763     * for whose metrics the Context's resources should be tailored and upon which
2764     * new windows should be shown.
2765     *
2766     * @return A {@link Context} for the display.
2767     */
2768    public abstract Context createDisplayContext(Display display);
2769
2770    /**
2771     * Gets the display adjustments holder for this context.  This information
2772     * is provided on a per-application or activity basis and is used to simulate lower density
2773     * display metrics for legacy applications and restricted screen sizes.
2774     *
2775     * @param displayId The display id for which to get compatibility info.
2776     * @return The compatibility info holder, or null if not required by the application.
2777     * @hide
2778     */
2779    public abstract DisplayAdjustments getDisplayAdjustments(int displayId);
2780
2781    /**
2782     * Indicates whether this Context is restricted.
2783     *
2784     * @return {@code true} if this Context is restricted, {@code false} otherwise.
2785     *
2786     * @see #CONTEXT_RESTRICTED
2787     */
2788    public boolean isRestricted() {
2789        return false;
2790    }
2791}
2792