Context.java revision 6b0fb368707a2d47dd3fbeaf01c214de5227baa0
13ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar/*
23ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar * Copyright (C) 2006 The Android Open Source Project
33ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar *
43ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar * Licensed under the Apache License, Version 2.0 (the "License");
53ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar * you may not use this file except in compliance with the License.
63ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar * You may obtain a copy of the License at
73ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar *
83ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar *      http://www.apache.org/licenses/LICENSE-2.0
93ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar *
103ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar * Unless required by applicable law or agreed to in writing, software
113ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar * distributed under the License is distributed on an "AS IS" BASIS,
1253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131b3bb6efc59a21f794b534078f9ae7e95393f510Daniel Dunbar * See the License for the specific language governing permissions and
141b3bb6efc59a21f794b534078f9ae7e95393f510Daniel Dunbar * limitations under the License.
151b3bb6efc59a21f794b534078f9ae7e95393f510Daniel Dunbar */
164ad4b3ebbe5769143389dccfcfadb666a4ba5940Daniel Dunbar
17dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbarpackage android.content;
18f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar
1927e738d0d3f781672a5999d2a9e2827b00a97d0cDaniel Dunbarimport android.content.pm.ApplicationInfo;
200648262df75d97b464c2be0ed867da3615659785Daniel Dunbarimport android.content.pm.PackageManager;
211b3bb6efc59a21f794b534078f9ae7e95393f510Daniel Dunbarimport android.content.res.AssetManager;
22f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbarimport android.content.res.Configuration;
23f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbarimport android.content.res.Resources;
2453ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbarimport android.content.res.TypedArray;
250648262df75d97b464c2be0ed867da3615659785Daniel Dunbarimport android.database.DatabaseErrorHandler;
26ab41e63821dc60ad144d0684df8d79a9eef86b75Douglas Gregorimport android.database.sqlite.SQLiteDatabase;
27ab41e63821dc60ad144d0684df8d79a9eef86b75Douglas Gregorimport android.database.sqlite.SQLiteDatabase.CursorFactory;
281368954db9ce2989ed8f03f5c65e8ee775a5229aDaniel Dunbarimport android.graphics.Bitmap;
298f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbarimport android.graphics.drawable.Drawable;
300648262df75d97b464c2be0ed867da3615659785Daniel Dunbarimport android.media.MediaScannerConnection.OnScanCompletedListener;
3153ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbarimport android.net.Uri;
32632f50edc08c76ebc643a0d4871bae33a55d7b4eDaniel Dunbarimport android.os.Bundle;
33ba1021388e6839b76c8968b931189361c7286674Daniel Dunbarimport android.os.Handler;
34f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbarimport android.os.Looper;
35f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbarimport android.os.UserHandle;
36ba1021388e6839b76c8968b931189361c7286674Daniel Dunbarimport android.os.UserManager;
37ba1021388e6839b76c8968b931189361c7286674Daniel Dunbarimport android.util.AttributeSet;
381b3bb6efc59a21f794b534078f9ae7e95393f510Daniel Dunbarimport android.view.CompatibilityInfoHolder;
3992b369928b8e9ad156fb6eec2bf9f21d657bd69bChris Lattnerimport android.view.Display;
401b3bb6efc59a21f794b534078f9ae7e95393f510Daniel Dunbarimport android.view.WindowManager;
414a1240825acceab51facaa0dd9e8c344dca70155Daniel Dunbar
428bde505fad92a44a853f5697a4fd8d2b52f20119Daniel Dunbarimport java.io.File;
434a1240825acceab51facaa0dd9e8c344dca70155Daniel Dunbarimport java.io.FileInputStream;
44dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbarimport java.io.FileNotFoundException;
454ad4b3ebbe5769143389dccfcfadb666a4ba5940Daniel Dunbarimport java.io.FileOutputStream;
46f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbarimport java.io.IOException;
47f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbarimport java.io.InputStream;
48a79a2b5bf23d1422eed9be3793186ebbba7532ecDaniel Dunbar
49dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar/**
50f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar * Interface to global information about an application environment.  This is
51dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar * an abstract class whose implementation is provided by
525c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar * the Android system.  It
534a1240825acceab51facaa0dd9e8c344dca70155Daniel Dunbar * allows access to application-specific resources and classes, as well as
54f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar * up-calls for application-level operations such as launching activities,
551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump * broadcasting and receiving intents, etc.
56f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar */
57f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbarpublic abstract class Context {
58f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar    /**
59f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     * File creation mode: the default mode, where the created file can only
60f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     * be accessed by the calling application (or all applications sharing the
61f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     * same user ID).
62f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     * @see #MODE_WORLD_READABLE
63f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     * @see #MODE_WORLD_WRITEABLE
64f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     */
65f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar    public static final int MODE_PRIVATE = 0x0000;
66f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar    /**
67f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     * @deprecated Creating world-readable files is very dangerous, and likely
68f44c58563286bb448a72ed9c9af5f21718633230Daniel Dunbar     * to cause security holes in applications.  It is strongly discouraged;
693ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar     * instead, applications should use more formal mechanism for interactions
703ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar     * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
713ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar     * {@link android.app.Service}.  There are no guarantees that this
721b3bb6efc59a21f794b534078f9ae7e95393f510Daniel Dunbar     * access mode will remain on a file, such as when it goes through a
737e4534d9c14febcdea30c057bb2a36e245776865Daniel Dunbar     * backup and restore.
743ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar     * File creation mode: allow all other applications to have read access
753ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar     * to the created file.
76a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @see #MODE_PRIVATE
77f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar     * @see #MODE_WORLD_WRITEABLE
788f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar     */
79f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    @Deprecated
80a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public static final int MODE_WORLD_READABLE = 0x0001;
81ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
82ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @deprecated Creating world-writable files is very dangerous, and likely
830648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * to cause security holes in applications.  It is strongly discouraged;
840648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * instead, applications should use more formal mechanism for interactions
85a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
86a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link android.app.Service}.  There are no guarantees that this
874139340644a0a41c2529c183c4b60bb55c3fdc79Daniel Dunbar     * access mode will remain on a file, such as when it goes through a
88a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * backup and restore.
89a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * File creation mode: allow all other applications to have write access
904139340644a0a41c2529c183c4b60bb55c3fdc79Daniel Dunbar     * to the created file.
914139340644a0a41c2529c183c4b60bb55c3fdc79Daniel Dunbar     * @see #MODE_PRIVATE
924139340644a0a41c2529c183c4b60bb55c3fdc79Daniel Dunbar     * @see #MODE_WORLD_READABLE
934139340644a0a41c2529c183c4b60bb55c3fdc79Daniel Dunbar     */
944139340644a0a41c2529c183c4b60bb55c3fdc79Daniel Dunbar    @Deprecated
950648262df75d97b464c2be0ed867da3615659785Daniel Dunbar    public static final int MODE_WORLD_WRITEABLE = 0x0002;
96b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar    /**
97b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * File creation mode: for use with {@link #openFileOutput}, if the file
98b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * already exists then write data to the end of the existing file
99b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * instead of erasing it.
100b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * @see #openFileOutput
101b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     */
102b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar    public static final int MODE_APPEND = 0x8000;
103b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar
104b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar    /**
105b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * SharedPreference loading flag: when set, the file on disk will
10653ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * be checked for modification even if the shared preferences
1070648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * instance is already loaded in this process.  This behavior is
108b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * sometimes desired in cases where the application has multiple
109b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * processes, all writing to the same SharedPreferences file.
110b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * Generally there are better forms of communication between
111b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     * processes, though.
112b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar     *
1130648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * <p>This was the legacy (but undocumented) behavior in and
1140648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * before Gingerbread (Android 2.3) and this flag is implied when
1150648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * targetting such releases.  For applications targetting SDK
1160648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * versions <em>greater than</em> Android 2.3, this flag must be
1170648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * explicitly set if desired.
1183ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar     *
1198f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar     * @see #getSharedPreferences
1208f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar     */
121a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public static final int MODE_MULTI_PROCESS = 0x0004;
122a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar
123a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
124cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * Database open flag: when set, the database is opened with write-ahead
125cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * logging enabled by default.
126cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     *
127a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @see #openOrCreateDatabase(String, int, CursorFactory)
12853ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #openOrCreateDatabase(String, int, CursorFactory, DatabaseErrorHandler)
1290648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * @see SQLiteDatabase#enableWriteAheadLogging
130365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     */
131dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar    public static final int MODE_ENABLE_WRITE_AHEAD_LOGGING = 0x0008;
132365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar
133a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
134365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * Flag for {@link #bindService}: automatically create the service as long
135a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * as the binding exists.  Note that while this will create the service,
136a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * its {@link android.app.Service#onStartCommand}
137a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * method will still only be called due to an
138a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * explicit call to {@link #startService}.  Even without that, though,
139365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * this still provides you with access to the service object while the
140365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * service is created.
141a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
142365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * <p>Note that prior to {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH},
143365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * not supplying this flag would also impact how important the system
144365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * consider's the target service's process to be.  When set, the only way
14553ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * for it to be raised was by binding from a service in which case it will
1465c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * only be important when that activity is in the foreground.  Now to
1475c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * achieve this behavior you must explicitly supply the new flag
148365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * {@link #BIND_ADJUST_WITH_ACTIVITY}.  For compatibility, old applications
149365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * that don't specify {@link #BIND_AUTO_CREATE} will automatically have
150365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * the flags {@link #BIND_WAIVE_PRIORITY} and
151365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * {@link #BIND_ADJUST_WITH_ACTIVITY} set for them in order to achieve
152a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * the same result.
15378d8a089c8f124ba6f47bb37e2c4a36986f60e23Daniel Dunbar     */
15478d8a089c8f124ba6f47bb37e2c4a36986f60e23Daniel Dunbar    public static final int BIND_AUTO_CREATE = 0x0001;
15578d8a089c8f124ba6f47bb37e2c4a36986f60e23Daniel Dunbar
15678d8a089c8f124ba6f47bb37e2c4a36986f60e23Daniel Dunbar    /**
1570f99d2e57d8e3cf2508e7f9f868d41eccdc229c9Daniel Dunbar     * Flag for {@link #bindService}: include debugging help for mismatched
1580f99d2e57d8e3cf2508e7f9f868d41eccdc229c9Daniel Dunbar     * calls to unbind.  When this flag is set, the callstack of the following
159dfaf4b3ac898bc40d928af693990769e98738793Daniel Dunbar     * {@link #unbindService} call is retained, to be printed if a later
160dfaf4b3ac898bc40d928af693990769e98738793Daniel Dunbar     * incorrect unbind call is made.  Note that doing this requires retaining
161df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor     * information about the binding that was made for the lifetime of the app,
162df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor     * resulting in a leak -- this should only be used for debugging.
163df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor     */
164df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor    public static final int BIND_DEBUG_UNBIND = 0x0002;
165365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar
1660f99d2e57d8e3cf2508e7f9f868d41eccdc229c9Daniel Dunbar    /**
167365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * Flag for {@link #bindService}: don't allow this binding to raise
1680f99d2e57d8e3cf2508e7f9f868d41eccdc229c9Daniel Dunbar     * the target service's process to the foreground scheduling priority.
169365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * It will still be raised to at least the same memory priority
170365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * as the client (so that its process will not be killable in any
171a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * situation where the client is not killable), but for CPU scheduling
172a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * purposes it may be left in the background.  This only has an impact
1730f99d2e57d8e3cf2508e7f9f868d41eccdc229c9Daniel Dunbar     * in the situation where the binding client is a foreground process
174a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * and the target service is in a background process.
175a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     */
176365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar    public static final int BIND_NOT_FOREGROUND = 0x0004;
177a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar
178a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar    /**
179a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * Flag for {@link #bindService}: indicates that the client application
180a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * binding to this service considers the service to be more important than
181a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * the app itself.  When set, the platform will try to have the out of
182a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * memory killer kill the app before it kills the service it is bound to, though
183a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * this is not guaranteed to be the case.
184a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     */
185a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar    public static final int BIND_ABOVE_CLIENT = 0x0008;
186a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar
187a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar    /**
188365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * Flag for {@link #bindService}: allow the process hosting the bound
189365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * service to go through its normal memory management.  It will be
190a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * treated more like a running service, allowing the system to
191a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * (temporarily) expunge the process if low on memory or for some other
192dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar     * whim it may have, and being more aggressive about making it a candidate
193365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * to be killed (and restarted) if running for a long time.
194dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar     */
195365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar    public static final int BIND_ALLOW_OOM_MANAGEMENT = 0x0010;
196da64141338da59bf477b5db5e333d6eade8e5fa1Daniel Dunbar
197da64141338da59bf477b5db5e333d6eade8e5fa1Daniel Dunbar    /**
198da64141338da59bf477b5db5e333d6eade8e5fa1Daniel Dunbar     * Flag for {@link #bindService}: don't impact the scheduling or
199da64141338da59bf477b5db5e333d6eade8e5fa1Daniel Dunbar     * memory management priority of the target service's hosting process.
200365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * Allows the service's process to be managed on the background LRU list
201365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * just like a regular application process in the background.
202365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     */
203365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar    public static final int BIND_WAIVE_PRIORITY = 0x0020;
204365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar
205365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar    /**
206dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar     * Flag for {@link #bindService}: this service is very important to
207f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar     * the client, so should be brought to the foreground process level
208365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * when the client is.  Normally a process can only be raised to the
209e504952bc89f79fc9ff54d5641ab30bb07ec435eDaniel Dunbar     * visibility level by a client, even if that client is in the foreground.
210cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     */
21121549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar    public static final int BIND_IMPORTANT = 0x0040;
212d7502d0a662b5c299125aba04245aefce67cbc22Daniel Dunbar
21321549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar    /**
214365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * Flag for {@link #bindService}: If binding from an activity, allow the
215365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * target service's process importance to be raised based on whether the
21621549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * activity is visible to the user, regardless whether another flag is
21721549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * used to reduce the amount that the client process's overall importance
218365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar     * is used to impact it.
21953ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     */
22021549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar    public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080;
22121549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar
222cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar    /**
223a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @hide An idea that is not yet implemented.
224a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Flag for {@link #bindService}: If binding from an activity, consider
225a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * this service to be visible like the binding activity is.  That is,
226a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * it will be treated as something more important to keep around than
22753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * invisible background activities.  This will impact the number of
22821549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * recent activities the user can switch between without having them
22953ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * restart.  There is no guarantee this will be respected, as the system
23021549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * tries to balance such requests from one app vs. the importantance of
23153ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * keeping other apps around.
23253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     */
23310ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar    public static final int BIND_VISIBLE = 0x0100;
23421549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar
23553ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar    /**
236ab835430b4f758dd49903251c7c7f21b95933c89Daniel Dunbar     * Flag for {@link #bindService}: Don't consider the bound service to be
23721549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * visible, even if the caller is visible.
2388d2554a2c3201aa664cbf2108cf9d57aa0aa4b0aDaniel Dunbar     * @hide
2398d2554a2c3201aa664cbf2108cf9d57aa0aa4b0aDaniel Dunbar     */
240365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar    public static final int BIND_NOT_VISIBLE = 0x40000000;
241365c02f65be026f90e67a8e00e7b827cee60e228Daniel Dunbar
242c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    /** Return an AssetManager instance for your application's package. */
243c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    public abstract AssetManager getAssets();
244c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar
245c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    /** Return a Resources instance for your application's package. */
246c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    public abstract Resources getResources();
247c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar
248c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    /** Return PackageManager instance to find global package information. */
249c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    public abstract PackageManager getPackageManager();
250c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar
251c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    /** Return a ContentResolver instance for your application's package. */
252c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    public abstract ContentResolver getContentResolver();
253c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar
254c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    /**
255a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Return the Looper for the main thread of the current process.  This is
256c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * the thread used to dispatch calls to application components (activities,
257c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * services, etc).
258c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     */
259c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    public abstract Looper getMainLooper();
260c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar
261c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    /**
262c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * Return the context of the single, global Application object of the
263c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * current process.  This generally should only be used if you need a
264c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * Context whose lifecycle is separate from the current context, that is
265c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * tied to the lifetime of the process rather than the current component.
266c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     *
267c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * <p>Consider for example how this interacts with
268c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * {@link #registerReceiver(BroadcastReceiver, IntentFilter)}:
269c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * <ul>
270c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * <li> <p>If used from an Activity context, the receiver is being registered
271c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * within that activity.  This means that you are expected to unregister
272c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * before the activity is done being destroyed; in fact if you do not do
273c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * so, the framework will clean up your leaked registration as it removes
274c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * the activity and log an error.  Thus, if you use the Activity context
275c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * to register a receiver that is static (global to the process, not
276c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * associated with an Activity instance) then that registration will be
277c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * removed on you at whatever point the activity you used is destroyed.
278c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * <li> <p>If used from the Context returned here, the receiver is being
279a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * registered with the global state associated with your application.  Thus
280c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * it will never be unregistered for you.  This is necessary if the receiver
281c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * is associated with static data, not a particular component.  However
282a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * using the ApplicationContext elsewhere can easily lead to serious leaks
283c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * if you forget to unregister, unbind, etc.
284c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * </ul>
285c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     */
286c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    public abstract Context getApplicationContext();
287c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar
288c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar    /**
289c88a88f6f7672b6bb831dce9da4acfa0c846975fDaniel Dunbar     * Add a new {@link ComponentCallbacks} to the base application of the
290d65bddcbe1385a4de212ecbbdc8919c54b3efeb0Daniel Dunbar     * Context, which will be called at the same times as the ComponentCallbacks
2910648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * methods of activities and other components are called.  Note that you
292a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <em>must</em> be sure to use {@link #unregisterComponentCallbacks} when
2930648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * appropriate in the future; this will not be removed for you.
2940648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     *
2950648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * @param callback The interface to call.  This can be either a
2960648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * {@link ComponentCallbacks} or {@link ComponentCallbacks2} interface.
2970648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     */
2980648262df75d97b464c2be0ed867da3615659785Daniel Dunbar    public void registerComponentCallbacks(ComponentCallbacks callback) {
2990648262df75d97b464c2be0ed867da3615659785Daniel Dunbar        getApplicationContext().registerComponentCallbacks(callback);
3000648262df75d97b464c2be0ed867da3615659785Daniel Dunbar    }
30153ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar
3020648262df75d97b464c2be0ed867da3615659785Daniel Dunbar    /**
3030648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * Remove a {@link ComponentCallbacks} objec that was previously registered
3040648262df75d97b464c2be0ed867da3615659785Daniel Dunbar     * with {@link #registerComponentCallbacks(ComponentCallbacks)}.
3053ede8d0a7d1813f678ccc6011a99a0834b1b6116Daniel Dunbar     */
306dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar    public void unregisterComponentCallbacks(ComponentCallbacks callback) {
30791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar        getApplicationContext().unregisterComponentCallbacks(callback);
30891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    }
309a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar
31091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    /**
31191e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * Return a localized, styled CharSequence from the application's package's
312a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * default string table.
31391e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     *
31491e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * @param resId Resource id for the CharSequence text
31591e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     */
31691e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    public final CharSequence getText(int resId) {
31791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar        return getResources().getText(resId);
31891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    }
31991e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar
32091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    /**
32191e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * Return a localized string from the application's package's
32291e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * default string table.
32391e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     *
32491e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * @param resId Resource id for the string
32591e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     */
32691e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    public final String getString(int resId) {
32791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar        return getResources().getString(resId);
32891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    }
32991e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar
33091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    /**
33191e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * Return a localized formatted string from the application's package's
332c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * default string table, substituting the format arguments as defined in
33391e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * {@link java.util.Formatter} and {@link java.lang.String#format}.
33491e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     *
33591e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * @param resId Resource id for the format string
33691e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * @param formatArgs The format arguments that will be used for substitution.
33791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     */
33891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar
33991e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    public final String getString(int resId, Object... formatArgs) {
34091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar        return getResources().getString(resId, formatArgs);
34191e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    }
34291e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar
34391e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     /**
34491e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * Set the base theme for this context.  Note that this should be called
34591e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * before any views are instantiated in the Context (for example before
34691e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * calling {@link android.app.Activity#setContentView} or
34791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * {@link android.view.LayoutInflater#inflate}).
34891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     *
34991e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * @param resid The style resource describing the theme.
35091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     */
351c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    public abstract void setTheme(int resid);
352c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar
353c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    /** @hide Needed for some internal implementation...  not public because
354c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * you can't assume this actually means anything. */
355c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    public int getThemeResId() {
356c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar        return 0;
357c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    }
3585915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar
3595915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar    /**
3605915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar     * Return the Theme object associated with this Context.
361c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     */
3625915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar    public abstract Resources.Theme getTheme();
363c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar
3645915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar    /**
365c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * Retrieve styled attribute information in this Context's theme.  See
366c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * {@link Resources.Theme#obtainStyledAttributes(int[])}
367c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * for more information.
368df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor     *
369df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor     * @see Resources.Theme#obtainStyledAttributes(int[])
370df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor     */
371df91ef3d6c55692a0236f67b6c6b134a3bf84098Douglas Gregor    public final TypedArray obtainStyledAttributes(
372c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar            int[] attrs) {
373c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar        return getTheme().obtainStyledAttributes(attrs);
374c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    }
375da64141338da59bf477b5db5e333d6eade8e5fa1Daniel Dunbar
376da64141338da59bf477b5db5e333d6eade8e5fa1Daniel Dunbar    /**
377da64141338da59bf477b5db5e333d6eade8e5fa1Daniel Dunbar     * Retrieve styled attribute information in this Context's theme.  See
378c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * {@link Resources.Theme#obtainStyledAttributes(int, int[])}
379c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * for more information.
380c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     *
381c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * @see Resources.Theme#obtainStyledAttributes(int, int[])
382c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     */
383c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    public final TypedArray obtainStyledAttributes(
384c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar            int resid, int[] attrs) throws Resources.NotFoundException {
385c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar        return getTheme().obtainStyledAttributes(resid, attrs);
386c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    }
387c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar
388c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    /**
389a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Retrieve styled attribute information in this Context's theme.  See
39091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)}
39191e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * for more information.
392c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     *
393c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)
394c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     */
395c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar    public final TypedArray obtainStyledAttributes(
396a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar            AttributeSet set, int[] attrs) {
39791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar        return getTheme().obtainStyledAttributes(set, attrs, 0, 0);
39891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    }
39991e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar
40091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    /**
40191e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * Retrieve styled attribute information in this Context's theme.  See
40291e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * {@link Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)}
40391e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * for more information.
40491e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     *
40591e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * @see Resources.Theme#obtainStyledAttributes(AttributeSet, int[], int, int)
40691e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     */
40791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    public final TypedArray obtainStyledAttributes(
40891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar            AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) {
40991e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar        return getTheme().obtainStyledAttributes(
41091e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar            set, attrs, defStyleAttr, defStyleRes);
41191e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    }
41291e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar
413793007242ba209b68ce14ec7547ac70ee981303aDaniel Dunbar    /**
414a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Return a class loader you can use to retrieve classes in this package.
415a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     */
4165b8cdb524fb06a5c35ba0d9dd9cdd437a50fd2f5Mike Stump    public abstract ClassLoader getClassLoader();
4175b8cdb524fb06a5c35ba0d9dd9cdd437a50fd2f5Mike Stump
4185b8cdb524fb06a5c35ba0d9dd9cdd437a50fd2f5Mike Stump    /** Return the name of this application's package. */
419a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract String getPackageName();
420b8d1191fdeb4eec9bc5cf9bf4b027add0fb467b3Douglas Gregor
421b8d1191fdeb4eec9bc5cf9bf4b027add0fb467b3Douglas Gregor    /** Return the full application info for this context's package. */
422b8d1191fdeb4eec9bc5cf9bf4b027add0fb467b3Douglas Gregor    public abstract ApplicationInfo getApplicationInfo();
423b8d1191fdeb4eec9bc5cf9bf4b027add0fb467b3Douglas Gregor
42470c8db1003af49d3627aeef41fcdd7c6c6a7df79Daniel Dunbar    /**
42570c8db1003af49d3627aeef41fcdd7c6c6a7df79Daniel Dunbar     * Return the full path to this context's primary Android package.
426793007242ba209b68ce14ec7547ac70ee981303aDaniel Dunbar     * The Android package is a ZIP file which contains the application's
4273ee96baa3fff269e145855a6f7526c36e59a7f4bDaniel Dunbar     * primary resources.
4283ee96baa3fff269e145855a6f7526c36e59a7f4bDaniel Dunbar     *
4293ee96baa3fff269e145855a6f7526c36e59a7f4bDaniel Dunbar     * <p>Note: this is not generally useful for applications, since they should
4303ee96baa3fff269e145855a6f7526c36e59a7f4bDaniel Dunbar     * not be directly accessing the file system.
431793007242ba209b68ce14ec7547ac70ee981303aDaniel Dunbar     *
432cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @return String Path to the resources.
433cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     */
43421549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar    public abstract String getPackageResourcePath();
435a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar
436a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
43791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * Return the full path to this context's primary Android package.
438e06dc219a869d73b6c9a398a2dee0aa2d4e2dcf0Daniel Dunbar     * The Android package is a ZIP file which contains application's
439ab41e63821dc60ad144d0684df8d79a9eef86b75Douglas Gregor     * primary code and assets.
440e06dc219a869d73b6c9a398a2dee0aa2d4e2dcf0Daniel Dunbar     *
441e06dc219a869d73b6c9a398a2dee0aa2d4e2dcf0Daniel Dunbar     * <p>Note: this is not generally useful for applications, since they should
442e06dc219a869d73b6c9a398a2dee0aa2d4e2dcf0Daniel Dunbar     * not be directly accessing the file system.
443a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
444c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     * @return String Path to the code and assets.
445c35d71f1e0a0c72fd43a73ddecd408bf43d501deDaniel Dunbar     */
44691e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    public abstract String getPackageCodePath();
44791e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar
44891e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar    /**
4496cc73de6ebb3eb00af7dd5149f6778318f1fb76fDaniel Dunbar     * {@hide}
450a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Return the full path to the shared prefs file for the given prefs group name.
451793007242ba209b68ce14ec7547ac70ee981303aDaniel Dunbar     *
4526cc73de6ebb3eb00af7dd5149f6778318f1fb76fDaniel Dunbar     * <p>Note: this is not generally useful for applications, since they should
4536cc73de6ebb3eb00af7dd5149f6778318f1fb76fDaniel Dunbar     * not be directly accessing the file system.
4546cc73de6ebb3eb00af7dd5149f6778318f1fb76fDaniel Dunbar     */
455a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract File getSharedPrefsFile(String name);
45621549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar
457793007242ba209b68ce14ec7547ac70ee981303aDaniel Dunbar    /**
458cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * Retrieve and hold the contents of the preferences file 'name', returning
459cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * a SharedPreferences through which you can retrieve and modify its
460cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * values.  Only one instance of the SharedPreferences object is returned
46121549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * to any callers for the same name, meaning they will see each other's
462ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * edits as soon as they are made.
463ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     *
464ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * @param name Desired preferences file. If a preferences file by this name
465ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * does not exist, it will be created when you retrieve an
466ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
467ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
468ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * default operation, {@link #MODE_WORLD_READABLE}
469ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * and {@link #MODE_WORLD_WRITEABLE} to control permissions.  The bit
470ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * {@link #MODE_MULTI_PROCESS} can also be used if multiple processes
471ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * are mutating the same SharedPreferences file.  {@link #MODE_MULTI_PROCESS}
472a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * is always on in apps targetting Gingerbread (Android 2.3) and below, and
473ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * off by default in later versions.
474ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     *
475ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * @return Returns the single SharedPreferences instance that can be used
476ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     *         to retrieve and modify the preference values.
477ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     *
478ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * @see #MODE_PRIVATE
47991e28afe3503893c69afd71877f11e3bf03fa4ceDaniel Dunbar     * @see #MODE_WORLD_READABLE
480ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * @see #MODE_WORLD_WRITEABLE
481ca3459e95f552cfae6c9c5fb4ed161e3a662c25eDaniel Dunbar     * @see #MODE_MULTI_PROCESS
482a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     */
483a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract SharedPreferences getSharedPreferences(String name,
48421549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar            int mode);
4855ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar
486cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar    /**
487cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * Open a private file associated with this Context's application package
488cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * for reading.
48921549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     *
4905ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     * @param name The name of the file to open; can not contain path
491cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     *             separators.
492cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     *
493cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @return FileInputStream Resulting input stream.
49421549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     *
4955ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     * @see #openFileOutput
496cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @see #fileList
497cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @see #deleteFile
498cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @see java.io.FileInputStream#FileInputStream(String)
49912cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     */
50012cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar    public abstract FileInputStream openFileInput(String name)
50112cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar        throws FileNotFoundException;
50212cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar
50312cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar    /**
50412cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * Open a private file associated with this Context's application package
50512cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * for writing.  Creates the file if it doesn't already exist.
506a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
50712cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @param name The name of the file to open; can not contain path
50812cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *             separators.
50912cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
51012cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * default operation, {@link #MODE_APPEND} to append to an existing file,
51112cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * {@link #MODE_WORLD_READABLE} and {@link #MODE_WORLD_WRITEABLE} to control
51212cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * permissions.
51312cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *
51412cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @return FileOutputStream Resulting output stream.
51512cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *
51612cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #MODE_APPEND
51712cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #MODE_PRIVATE
51812cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #MODE_WORLD_READABLE
51912cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #MODE_WORLD_WRITEABLE
52012cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #openFileInput
52112cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #fileList
52212cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #deleteFile
52312cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see java.io.FileOutputStream#FileOutputStream(String)
52412cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     */
52512cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar    public abstract FileOutputStream openFileOutput(String name, int mode)
52612cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar        throws FileNotFoundException;
52712cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar
528a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
52912cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * Delete the given private file associated with this Context's
53012cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * application package.
53112cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *
53212cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @param name The name of the file to delete; can not contain path
53312cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *             separators.
53412cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *
53512cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @return True if the file was successfully deleted; else
53612cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *         false.
53712cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     *
53812cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #openFileInput
53912cfe036d809173a25af0104844d4bb66a92252bDaniel Dunbar     * @see #openFileOutput
540cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @see #fileList
541cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @see java.io.File#delete()
542cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     */
543a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract boolean deleteFile(String name);
544ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar
545ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar    /**
546ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * Returns the absolute path on the filesystem where a file created with
547a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link #openFileOutput} is stored.
548ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     *
549ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * @param name The name of the file for which you would like to get
550a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *          its path.
551ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     *
552a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @return Returns an absolute path to the given file.
55310ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     *
554ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * @see #openFileOutput
555a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @see #getFilesDir
55610ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     * @see #getDir
55710ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     */
558ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar    public abstract File getFileStreamPath(String name);
559ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar
560ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar    /**
56110ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     * Returns the absolute path to the directory on the filesystem where
562ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * files created with {@link #openFileOutput} are stored.
563ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     *
564ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * @return Returns the path of the directory holding application files.
565ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     *
566ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * @see #openFileOutput
567ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * @see #getFileStreamPath
568ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * @see #getDir
569ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     */
570ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar    public abstract File getFilesDir();
571a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar
572ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar    /**
573ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * Returns the absolute path to the directory on the external filesystem
574ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory()
575ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * Environment.getExternalStorageDirectory()}) where the application can
576ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     * place persistent files it owns.  These files are private to the
57710ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     * applications, and not typically visible to the user as media.
578ba1021388e6839b76c8968b931189361c7286674Daniel Dunbar     *
579a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <p>This is like {@link #getFilesDir()} in that these
58010ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     * files will be deleted when the application is uninstalled, however there
58110ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     * are some important differences:
58253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
58353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * <ul>
584a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <li>External files are not always available: they will disappear if the
58521549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * user mounts the external storage on a computer or removes it.  See the
586a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * APIs on {@link android.os.Environment} for information in the storage state.
587a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <li>There is no security enforced with these files.  All applications
588a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * can read and write files placed here.
5891368954db9ce2989ed8f03f5c65e8ee775a5229aDaniel Dunbar     * </ul>
5901368954db9ce2989ed8f03f5c65e8ee775a5229aDaniel Dunbar     *
591a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <p>On devices with multiple users (as described by {@link UserManager}),
5922fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * each user has their own isolated external storage. Applications only
5932fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * have access to the external storage for the user they're running as.</p>
5942fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     *
5952fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * <p>Here is an example of typical code to manipulate a file in
59636df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * an application's private storage:</p>
59736df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     *
59836df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
59936df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * private_file}
60036df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     *
60136df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * <p>If you supply a non-null <var>type</var> to this function, the returned
60236df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * file will be a path to a sub-directory of the given type.  Though these files
60336df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * are not automatically scanned by the media scanner, you can explicitly
60436df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * add them to the media database with
60536df2904354ac150500ec16238a1ec3cce4ba83eDaniel Dunbar     * {@link android.media.MediaScannerConnection#scanFile(Context, String[], String[],
6067587719c40ebf02bf11e5e66c30bd20e98edebc2Daniel Dunbar     *      OnScanCompletedListener) MediaScannerConnection.scanFile}.
6073f30ddf680df44e0c5c43b8db0a22166dcd7066bDaniel Dunbar     * Note that this is not the same as
6083f30ddf680df44e0c5c43b8db0a22166dcd7066bDaniel Dunbar     * {@link android.os.Environment#getExternalStoragePublicDirectory
6092fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * Environment.getExternalStoragePublicDirectory()}, which provides
6102fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * directories of media shared by all applications.  The
6112fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * directories returned here are
612a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * owned by the application, and their contents will be removed when the
613a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * application is uninstalled.  Unlike
61410ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     * {@link android.os.Environment#getExternalStoragePublicDirectory
61510ffa9a4887d9376e3eb3598e40523d1b58773c9Daniel Dunbar     * Environment.getExternalStoragePublicDirectory()}, the directory
6162fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * returned here will be automatically created for you.
617a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
618a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <p>Here is an example of typical code to manipulate a picture in
619a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * an application's private storage and add it to the media database:</p>
6202fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     *
6212fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * {@sample development/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
6222fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * private_picture}
6232fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     *
624a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <p>Writing to this path requires the
62538dd3d54186cf44ea9d37f463c3f2800ab526b82Daniel Dunbar     * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
6262fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     *
6272fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * @param type The type of files directory to return.  May be null for
6282fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * the root of the files directory or one of
6292fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * the following Environment constants for a subdirectory:
6302fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * {@link android.os.Environment#DIRECTORY_MUSIC},
631a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link android.os.Environment#DIRECTORY_PODCASTS},
6322fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * {@link android.os.Environment#DIRECTORY_RINGTONES},
6332fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * {@link android.os.Environment#DIRECTORY_ALARMS},
6342fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * {@link android.os.Environment#DIRECTORY_NOTIFICATIONS},
635a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link android.os.Environment#DIRECTORY_PICTURES}, or
636a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link android.os.Environment#DIRECTORY_MOVIES}.
637a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
638a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @return Returns the path of the directory holding application files
6392fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * on external storage.  Returns null if external storage is not currently
6402fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * mounted so it could not ensure the path exists; you will need to call
6413dbd6c51bcd8a730c3fe58e29d7e0d999a94fa91Daniel Dunbar     * this method again when it is available.
6422fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     *
6432fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * @see #getFilesDir
6442fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * @see android.os.Environment#getExternalStoragePublicDirectory
6452fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     */
6467587719c40ebf02bf11e5e66c30bd20e98edebc2Daniel Dunbar    public abstract File getExternalFilesDir(String type);
6471368954db9ce2989ed8f03f5c65e8ee775a5229aDaniel Dunbar
6482fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar    /**
649a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Return the directory where this application's OBB files (if there
650a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * are any) can be found.  Note if the application does not have any OBB
6512fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * files, this directory may not exist.
6522fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     *
6532fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * <p>On devices with multiple users (as described by {@link UserManager}),
6542fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * multiple users may share the same OBB storage location. Applications
6552fe63e6adac0b9e5f52bcc3100b545e379417e6eDaniel Dunbar     * should ensure that multiple instances running under different users
65653ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * don't interfere with each other.</p>
65753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     */
65821549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar    public abstract File getObbDir();
6598f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar
660af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar    /**
661af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * Returns the absolute path to the application specific cache directory
662a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * on the filesystem. These files will be ones that get deleted first when the
663a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * device runs low on storage.
664a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * There is no guarantee when these files will be deleted.
66583dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar     *
66683dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar     * <strong>Note: you should not <em>rely</em> on the system deleting these
66783dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar     * files for you; you should always have a reasonable maximum, such as 1 MB,
66853ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * for the amount of space you consume with cache files, and prune those
669a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * files when exceeding that space.</strong>
67053ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
67153ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @return Returns the path of the directory holding application cache files.
67253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
67353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #openFileOutput
67453ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #getFileStreamPath
67553ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #getDir
67653ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     */
67753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar    public abstract File getCacheDir();
67883dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar
67983dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar    /**
68083dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar     * Returns the absolute path to the directory on the external filesystem
68183dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar     * (that is somewhere on {@link android.os.Environment#getExternalStorageDirectory()
68283dd21f6b4e6e109b893c0d42bc81e4883c342f7Daniel Dunbar     * Environment.getExternalStorageDirectory()} where the application can
68353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * place cache files it owns.
68453ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
685a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <p>This is like {@link #getCacheDir()} in that these
686a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * files will be deleted when the application is uninstalled, however there
68753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * are some important differences:
688a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
689a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <ul>
6908022fd46d45005de63306a7513aece20a1be16edDaniel Dunbar     * <li>The platform does not always monitor the space available in external
691b897f5d3ebfb62c2745e2e2af7faa9920c882438Daniel Dunbar     * storage, and thus may not automatically delete these files.  Currently
69253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * the only time files here will be deleted by the platform is when running
69353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * on {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} or later and
694a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link android.os.Environment#isExternalStorageEmulated()
695a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Environment.isExternalStorageEmulated()} returns true.  Note that you should
696a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * be managing the maximum space you will use for these anyway, just like
69753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * with {@link #getCacheDir()}.
698e33bea4ef34598e7a4a6a3a117392268998552d4Daniel Dunbar     * <li>External files are not always available: they will disappear if the
699e33bea4ef34598e7a4a6a3a117392268998552d4Daniel Dunbar     * user mounts the external storage on a computer or removes it.  See the
70053ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * APIs on {@link android.os.Environment} for information in the storage state.
70153ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * <li>There is no security enforced with these files.  All applications
70253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * can read and write files placed here.
70353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * </ul>
704683ca381bf2b8dffab535c89d25250518bbec3a0Daniel Dunbar     *
705683ca381bf2b8dffab535c89d25250518bbec3a0Daniel Dunbar     * <p>On devices with multiple users (as described by {@link UserManager}),
706683ca381bf2b8dffab535c89d25250518bbec3a0Daniel Dunbar     * each user has their own isolated external storage. Applications only
707a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * have access to the external storage for the user they're running as.</p>
708683ca381bf2b8dffab535c89d25250518bbec3a0Daniel Dunbar     *
70953ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * <p>Writing to this path requires the
71053ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission.</p>
71153ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
71253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @return Returns the path of the directory holding application cache files
71353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * on external storage.  Returns null if external storage is not currently
71453ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * mounted so it could not ensure the path exists; you will need to call
71553ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * this method again when it is available.
71653ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
71753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #getCacheDir
71853ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     */
71953ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar    public abstract File getExternalCacheDir();
72053ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar
721a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
722a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Returns an array of strings naming the private files associated with
723a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * this Context's application package.
72453ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
725b897f5d3ebfb62c2745e2e2af7faa9920c882438Daniel Dunbar     * @return Array of strings naming the private files.
72653ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
72753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #openFileInput
72853ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #openFileOutput
72953ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @see #deleteFile
730a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     */
731a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract String[] fileList();
73253ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar
73353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar    /**
73453ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * Retrieve, creating if needed, a new directory in which the application
735a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * can place its own custom data files.  You can use the returned File
73653ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * object to create and access files in this directory.  Note that files
73753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * created through a File object will only be accessible by your own
73853ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * application; you can only set the mode of the entire directory, not
739a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * of individual files.
740a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
74153ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @param name Name of the directory to retrieve.  This is a directory
742b897f5d3ebfb62c2745e2e2af7faa9920c882438Daniel Dunbar     * that is created as part of your application data.
74353ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
74453ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * default operation, {@link #MODE_WORLD_READABLE} and
74553ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * {@link #MODE_WORLD_WRITEABLE} to control permissions.
74653ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *
74753ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * @return Returns a File object for the requested directory.  The directory
7488b1604ece7bf6dc2ba811cd7d8767557e55e2ec2Daniel Dunbar     * will have been created if it does not already exist.
749af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     *
750af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * @see #openFileOutput(String, int)
751af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     */
752af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar    public abstract File getDir(String name, int mode);
753a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar
754a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
755a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Open a new private SQLiteDatabase associated with this Context's
756ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * application package.  Create the database file if it doesn't exist.
757ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *
758af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * @param name The name (unique in the application package) of the database.
759af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
760ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *     default operation, {@link #MODE_WORLD_READABLE}
761ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *     and {@link #MODE_WORLD_WRITEABLE} to control permissions.
762ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *     Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default.
763ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @param factory An optional factory class that is called to instantiate a
764a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *     cursor when query is called.
7655915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar     *
7668022fd46d45005de63306a7513aece20a1be16edDaniel Dunbar     * @return The contents of a newly created database with the given name.
76763be57a832b2dab70592d1d9b37a5cd9a627356eDaniel Dunbar     * @throws android.database.sqlite.SQLiteException if the database file could not be opened.
76863be57a832b2dab70592d1d9b37a5cd9a627356eDaniel Dunbar     *
7695915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar     * @see #MODE_PRIVATE
770ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @see #MODE_WORLD_READABLE
771ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @see #MODE_WORLD_WRITEABLE
772af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
773af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * @see #deleteDatabase
774ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
775ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract SQLiteDatabase openOrCreateDatabase(String name,
776a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar            int mode, CursorFactory factory);
777af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar
778af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar    /**
779ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * Open a new private SQLiteDatabase associated with this Context's
780af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * application package.  Creates the database file if it doesn't exist.
781a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
782a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be
783d7b88c2cb8986217f164203747d35c8f596e38c2Daniel Dunbar     * used to handle corruption when sqlite reports database corruption.</p>
78438dd3d54186cf44ea9d37f463c3f2800ab526b82Daniel Dunbar     *
785af61c71137d1f7239d6b9d7425ce083db7ba31dfDaniel Dunbar     * @param name The name (unique in the application package) of the database.
786ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
787ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *     default operation, {@link #MODE_WORLD_READABLE}
78853ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     *     and {@link #MODE_WORLD_WRITEABLE} to control permissions.
789ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *     Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default.
790ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @param factory An optional factory class that is called to instantiate a
791ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *     cursor when query is called.
792ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database
793ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * corruption. if null, {@link android.database.DefaultDatabaseErrorHandler} is assumed.
794ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @return The contents of a newly created database with the given name.
795a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @throws android.database.sqlite.SQLiteException if the database file could not be opened.
796a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
797ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @see #MODE_PRIVATE
798ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @see #MODE_WORLD_READABLE
79905494a78c3746a360e81fc1d1797ce52df415b54Daniel Dunbar     * @see #MODE_WORLD_WRITEABLE
80005494a78c3746a360e81fc1d1797ce52df415b54Daniel Dunbar     * @see #MODE_ENABLE_WRITE_AHEAD_LOGGING
801634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     * @see #deleteDatabase
802634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     */
803634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar    public abstract SQLiteDatabase openOrCreateDatabase(String name,
804634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar            int mode, CursorFactory factory, DatabaseErrorHandler errorHandler);
805634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar
806634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar    /**
807634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     * Delete an existing private SQLiteDatabase associated with this Context's
808634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     * application package.
809634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     *
810634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     * @param name The name (unique in the application package) of the
811634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     *             database.
812634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     *
813634b24563be901f8adc37c07ffba3eeac1f1d4ccDaniel Dunbar     * @return True if the database was successfully deleted; else false.
814ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *
815ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @see #openOrCreateDatabase
816a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     */
817ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract boolean deleteDatabase(String name);
818ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar
819ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
820ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * Returns the absolute path on the filesystem where a database created with
821ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * {@link #openOrCreateDatabase} is stored.
822ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *
823ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @param name The name of the database for which you would like to get
824ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *          its path.
825ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *
826ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @return Returns an absolute path to the given database.
827ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     *
828ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @see #openOrCreateDatabase
829ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
830ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract File getDatabasePath(String name);
831ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar
832ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
833ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * Returns an array of strings naming the private databases associated with
834a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * this Context's application package.
835a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
836a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @return Array of strings naming the private databases.
837337a6271b98c4c183f7eaad1563a75260b4f2871Daniel Dunbar     *
838337a6271b98c4c183f7eaad1563a75260b4f2871Daniel Dunbar     * @see #openOrCreateDatabase
839337a6271b98c4c183f7eaad1563a75260b4f2871Daniel Dunbar     * @see #deleteDatabase
840ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
841ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract String[] databaseList();
842ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar
843ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
844ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @deprecated Use {@link android.app.WallpaperManager#getDrawable
845ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * WallpaperManager.get()} instead.
846ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
847ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    @Deprecated
848ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract Drawable getWallpaper();
84953ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar
850ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
851ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @deprecated Use {@link android.app.WallpaperManager#peekDrawable
852ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * WallpaperManager.peek()} instead.
853ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
854ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    @Deprecated
855ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract Drawable peekWallpaper();
856ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar
857ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
8588f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar     * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumWidth()
859ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * WallpaperManager.getDesiredMinimumWidth()} instead.
860ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
861ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    @Deprecated
862ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract int getWallpaperDesiredMinimumWidth();
863cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar
864cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar    /**
865cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar     * @deprecated Use {@link android.app.WallpaperManager#getDesiredMinimumHeight()
866cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar     * WallpaperManager.getDesiredMinimumHeight()} instead.
867cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar     */
868cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar    @Deprecated
869cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar    public abstract int getWallpaperDesiredMinimumHeight();
870cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar
871cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar    /**
872ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @deprecated Use {@link android.app.WallpaperManager#setBitmap(Bitmap)
873ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * WallpaperManager.set()} instead.
874ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * <p>This method requires the caller to hold the permission
875a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link android.Manifest.permission#SET_WALLPAPER}.
876ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
877ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    @Deprecated
878ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract void setWallpaper(Bitmap bitmap) throws IOException;
87963be57a832b2dab70592d1d9b37a5cd9a627356eDaniel Dunbar
880ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
8815915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar     * @deprecated Use {@link android.app.WallpaperManager#setStream(InputStream)
8825915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar     * WallpaperManager.set()} instead.
883337a6271b98c4c183f7eaad1563a75260b4f2871Daniel Dunbar     * <p>This method requires the caller to hold the permission
884337a6271b98c4c183f7eaad1563a75260b4f2871Daniel Dunbar     * {@link android.Manifest.permission#SET_WALLPAPER}.
885337a6271b98c4c183f7eaad1563a75260b4f2871Daniel Dunbar     */
886a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    @Deprecated
887ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract void setWallpaper(InputStream data) throws IOException;
888ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar
889ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
890ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * @deprecated Use {@link android.app.WallpaperManager#clear
891ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * WallpaperManager.clear()} instead.
892ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * <p>This method requires the caller to hold the permission
893ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     * {@link android.Manifest.permission#SET_WALLPAPER}.
894ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar     */
895ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    @Deprecated
896ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    public abstract void clearWallpaper() throws IOException;
897ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar
898ad2a9af666efdd9afe3bb5f886bcb0d1c9a0f0c3Daniel Dunbar    /**
89953ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * Same as {@link #startActivity(Intent, Bundle)} with no options
90053ec55215075c8f4ddd47ca6ed7d382f16beb670Daniel Dunbar     * specified.
90121549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     *
9028f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar     * @param intent The description of the activity to start.
903f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
904f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @throws ActivityNotFoundException
90560ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     *
906a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @see {@link #startActivity(Intent, Bundle)}
90760ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     * @see PackageManager#resolveActivity
90860ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     */
909a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract void startActivity(Intent intent);
910f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar
911f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    /**
912f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * Version of {@link #startActivity(Intent)} that allows you to specify the
913f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * user the activity will be started for.  This is not available to applications
914f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * that are not pre-installed on the system image.  Using it requires holding
915f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * the INTERACT_ACROSS_USERS_FULL permission.
916f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param intent The description of the activity to start.
917f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param user The UserHandle of the user to start this activity for.
918a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @throws ActivityNotFoundException
919a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @hide
920f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     */
921f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    public void startActivityAsUser(Intent intent, UserHandle user) {
922a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar        throw new RuntimeException("Not implemented. Must override in a subclass.");
92321549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar    }
924f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar
925f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    /**
926a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Launch a new activity.  You will not receive any information about when
927f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * the activity exits.
928f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
929f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * <p>Note that if this method is being called from outside of an
930f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * {@link android.app.Activity} Context, then the Intent must include
931f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * the {@link Intent#FLAG_ACTIVITY_NEW_TASK} launch flag.  This is because,
932f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * without being started from an existing Activity, there is no existing
933a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * task in which to place the new activity and thus it needs to be placed
93421549237f14505cfc2a18a06416372a36229d0ceDaniel Dunbar     * in its own separate task.
935f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
936f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * <p>This method throws {@link ActivityNotFoundException}
937a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * if there was no Activity found to run the given Intent.
938a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
939a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @param intent The description of the activity to start.
940f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param options Additional options for how the Activity should be started.
941a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * May be null if there are no options.  See {@link android.app.ActivityOptions}
942a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * for how to build the Bundle supplied here; there are no supported definitions
943f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * for building it manually.
944d7b88c2cb8986217f164203747d35c8f596e38c2Daniel Dunbar     *
945f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @throws ActivityNotFoundException
946f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
947f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see #startActivity(Intent)
948f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see PackageManager#resolveActivity
949f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     */
950f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    public abstract void startActivity(Intent intent, Bundle options);
951f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar
952a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
9534954018954bbc97363eef02d0c83bea19ce9b329Daniel Dunbar     * Version of {@link #startActivity(Intent, Bundle)} that allows you to specify the
954f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * user the activity will be started for.  This is not available to applications
955f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * that are not pre-installed on the system image.  Using it requires holding
956f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * the INTERACT_ACROSS_USERS_FULL permission.
957f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param intent The description of the activity to start.
958f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param options Additional options for how the Activity should be started.
959586dc233bb88f2920c9f3638f69cef0ccd55dcedDaniel Dunbar     * May be null if there are no options.  See {@link android.app.ActivityOptions}
960a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * for how to build the Bundle supplied here; there are no supported definitions
961a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * for building it manually.
962a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @param user The UserHandle of the user to start this activity for.
9631e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar     * @throws ActivityNotFoundException
964af2e4baa2a75471e820030701225a1ca02c7308fDaniel Dunbar     * @hide
965af2e4baa2a75471e820030701225a1ca02c7308fDaniel Dunbar     */
966a2094e76fc545b9e17c851c3d2c46b719c5f17ebDaniel Dunbar    public void startActivityAsUser(Intent intent, Bundle options, UserHandle userId) {
967a2094e76fc545b9e17c851c3d2c46b719c5f17ebDaniel Dunbar        throw new RuntimeException("Not implemented. Must override in a subclass.");
968a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    }
969586dc233bb88f2920c9f3638f69cef0ccd55dcedDaniel Dunbar
970586dc233bb88f2920c9f3638f69cef0ccd55dcedDaniel Dunbar    /**
971586dc233bb88f2920c9f3638f69cef0ccd55dcedDaniel Dunbar     * Same as {@link #startActivities(Intent[], Bundle)} with no options
972a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * specified.
973586dc233bb88f2920c9f3638f69cef0ccd55dcedDaniel Dunbar     *
974a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @param intents An array of Intents to be started.
9754f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     *
9761e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar     * @throws ActivityNotFoundException
9771e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar     *
9781e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar     * @see {@link #startActivities(Intent[], Bundle)}
979a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @see PackageManager#resolveActivity
980a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     */
9814f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar    public abstract void startActivities(Intent[] intents);
9824f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar
9834f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar    /**
9844f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * Launch multiple new activities.  This is generally the same as calling
9854f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * {@link #startActivity(Intent)} for the first Intent in the array,
986a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * that activity during its creation calling {@link #startActivity(Intent)}
9874f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * for the second entry, etc.  Note that unlike that approach, generally
9884f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * none of the activities except the last in the array will be created
9894f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * at this point, but rather will be created when the user first visits
9904f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * them (due to pressing back from the activity on top).
9914f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     *
9924f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * <p>This method throws {@link ActivityNotFoundException}
9934f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * if there was no Activity found for <em>any</em> given Intent.  In this
9944f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * case the state of the activity stack is undefined (some Intents in the
9954f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * list may be on it, some not), so you probably want to avoid such situations.
9964f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     *
9974f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * @param intents An array of Intents to be started.
998a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @param options Additional options for how the Activity should be started.
99938dd3d54186cf44ea9d37f463c3f2800ab526b82Daniel Dunbar     * See {@link android.content.Context#startActivity(Intent, Bundle)
10004f53b298846d720fbb906373f3f28d92f2121f35Daniel Dunbar     * Context.startActivity(Intent, Bundle)} for more details.
1001586dc233bb88f2920c9f3638f69cef0ccd55dcedDaniel Dunbar     *
100257b704d8d8f49bcaf856a3e37941d5ac6456eb50Daniel Dunbar     * @throws ActivityNotFoundException
100357b704d8d8f49bcaf856a3e37941d5ac6456eb50Daniel Dunbar     *
1004f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see {@link #startActivities(Intent[])}
1005f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see PackageManager#resolveActivity
1006f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     */
10074954018954bbc97363eef02d0c83bea19ce9b329Daniel Dunbar    public abstract void startActivities(Intent[] intents, Bundle options);
1008f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar
1009f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    /**
1010f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @hide
1011f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * Launch multiple new activities.  This is generally the same as calling
1012a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * {@link #startActivity(Intent)} for the first Intent in the array,
101360ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     * that activity during its creation calling {@link #startActivity(Intent)}
101460ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     * for the second entry, etc.  Note that unlike that approach, generally
1015a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * none of the activities except the last in the array will be created
101660ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     * at this point, but rather will be created when the user first visits
101760ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     * them (due to pressing back from the activity on top).
101860ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     *
1019f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * <p>This method throws {@link ActivityNotFoundException}
1020a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * if there was no Activity found for <em>any</em> given Intent.  In this
1021a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * case the state of the activity stack is undefined (some Intents in the
1022115a79277edababaf1b26e3654044ae983197679Daniel Dunbar     * list may be on it, some not), so you probably want to avoid such situations.
1023115a79277edababaf1b26e3654044ae983197679Daniel Dunbar     *
1024115a79277edababaf1b26e3654044ae983197679Daniel Dunbar     * @param intents An array of Intents to be started.
1025115a79277edababaf1b26e3654044ae983197679Daniel Dunbar     * @param options Additional options for how the Activity should be started.
1026115a79277edababaf1b26e3654044ae983197679Daniel Dunbar     * @param userHandle The user for whom to launch the activities
1027115a79277edababaf1b26e3654044ae983197679Daniel Dunbar     * See {@link android.content.Context#startActivity(Intent, Bundle)
1028115a79277edababaf1b26e3654044ae983197679Daniel Dunbar     * Context.startActivity(Intent, Bundle)} for more details.
1029f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
1030f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @throws ActivityNotFoundException
1031f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
1032f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see {@link #startActivities(Intent[])}
1033d7502d0a662b5c299125aba04245aefce67cbc22Daniel Dunbar     * @see PackageManager#resolveActivity
1034d7502d0a662b5c299125aba04245aefce67cbc22Daniel Dunbar     */
1035cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar    public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
1036d7502d0a662b5c299125aba04245aefce67cbc22Daniel Dunbar        throw new RuntimeException("Not implemented. Must override in a subclass.");
1037d7502d0a662b5c299125aba04245aefce67cbc22Daniel Dunbar    }
1038d7502d0a662b5c299125aba04245aefce67cbc22Daniel Dunbar
10394954018954bbc97363eef02d0c83bea19ce9b329Daniel Dunbar    /**
10404954018954bbc97363eef02d0c83bea19ce9b329Daniel Dunbar     * Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
1041f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * with no options specified.
1042f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
1043f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param intent The IntentSender to launch.
1044f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param fillInIntent If non-null, this will be provided as the
1045f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * intent parameter to {@link IntentSender#sendIntent}.
1046a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @param flagsMask Intent flags in the original IntentSender that you
1047a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * would like to change.
1048a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @param flagsValues Desired values for any bits set in
1049a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <var>flagsMask</var>
1050f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param extraFlags Always set to 0.
1051f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
1052f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see #startActivity(Intent)
1053f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle)
1054f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     */
1055f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    public abstract void startIntentSender(IntentSender intent,
1056f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar            Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
1057f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar            throws IntentSender.SendIntentException;
1058f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar
1059f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    /**
1060f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
1061f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * to start.  If the IntentSender is for an activity, that activity will be started
1062f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * as if you had called the regular {@link #startActivity(Intent)}
1063f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * here; otherwise, its associated action will be executed (such as
106447ac7d27c44bd64a7d0fc03d4babc196cf2b8230Daniel Dunbar     * sending a broadcast) as if you had called
1065f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * {@link IntentSender#sendIntent IntentSender.sendIntent} on it.
1066f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
1067f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param intent The IntentSender to launch.
10684954018954bbc97363eef02d0c83bea19ce9b329Daniel Dunbar     * @param fillInIntent If non-null, this will be provided as the
10694954018954bbc97363eef02d0c83bea19ce9b329Daniel Dunbar     * intent parameter to {@link IntentSender#sendIntent}.
1070f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param flagsMask Intent flags in the original IntentSender that you
1071f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * would like to change.
1072f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param flagsValues Desired values for any bits set in
1073f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * <var>flagsMask</var>
1074f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param extraFlags Always set to 0.
1075f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @param options Additional options for how the Activity should be started.
1076a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * See {@link android.content.Context#startActivity(Intent, Bundle)
1077a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Context.startActivity(Intent, Bundle)} for more details.  If options
1078f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * have also been supplied by the IntentSender, options given here will
1079f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * override any that conflict with those given by the IntentSender.
1080f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
1081f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see #startActivity(Intent, Bundle)
1082f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see #startIntentSender(IntentSender, Intent, int, int, int)
108360ccc7677a5416df3a8f8bde79ab35f85cb66e14Daniel Dunbar     */
1084f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    public abstract void startIntentSender(IntentSender intent,
1085f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar            Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
1086f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar            Bundle options) throws IntentSender.SendIntentException;
1087f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar
1088f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar    /**
1089f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * Broadcast the given intent to all interested BroadcastReceivers.  This
1090441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * call is asynchronous; it returns immediately, and you will continue
1091f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * executing while the receivers are run.  No results are propagated from
1092f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * receivers and receivers can not abort the broadcast. If you want
1093f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * to allow receivers to propagate results or abort the broadcast, you must
1094f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * send an ordered broadcast using
1095f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * {@link #sendOrderedBroadcast(Intent, String)}.
1096f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     *
1097441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1098a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
1099a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
1100441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *               Intent will receive the broadcast.
11015c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     *
1102441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @see android.content.BroadcastReceiver
1103441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @see #registerReceiver
11045c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * @see #sendBroadcast(Intent, String)
11055c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * @see #sendOrderedBroadcast(Intent, String)
11065c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1107a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     */
1108a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract void sendBroadcast(Intent intent);
1109b7b61b26868a09dc1471895d0d39ed6c28245207Daniel Dunbar
1110b7b61b26868a09dc1471895d0d39ed6c28245207Daniel Dunbar    /**
1111871adcf4e41285e3f4c3b62eaa1b2e05b60b92daDaniel Dunbar     * Broadcast the given intent to all interested BroadcastReceivers, allowing
1112441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * an optional required permission to be enforced.  This
11135c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * call is asynchronous; it returns immediately, and you will continue
1114441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * executing while the receivers are run.  No results are propagated from
11155c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * receivers and receivers can not abort the broadcast. If you want
11165c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * to allow receivers to propagate results or abort the broadcast, you must
1117441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * send an ordered broadcast using
1118441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * {@link #sendOrderedBroadcast(Intent, String)}.
11195c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     *
1120cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1121cd8e4c44dd068956e9181381be3ee2d49a0fac52Daniel Dunbar     *
11225c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
11235c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     *               Intent will receive the broadcast.
11245c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * @param receiverPermission (optional) String naming a permission that
11255c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     *               a receiver must hold in order to receive your broadcast.
11265c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     *               If null, no permission is required.
11275c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     *
11285c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * @see android.content.BroadcastReceiver
1129a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @see #registerReceiver
11304954018954bbc97363eef02d0c83bea19ce9b329Daniel Dunbar     * @see #sendBroadcast(Intent)
11315c3c1d7b494660ba5e8983ee4584622750725ac2Daniel Dunbar     * @see #sendOrderedBroadcast(Intent, String)
1132f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1133f353c8cc2ee1cc16ff194b399a8d951f707fb129Daniel Dunbar     */
1134a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract void sendBroadcast(Intent intent,
1135441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar            String receiverPermission);
1136441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar
1137441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar    /**
11388f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar     * Broadcast the given intent to all interested BroadcastReceivers, delivering
1139441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * them one at a time to allow more preferred receivers to consume the
1140441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * broadcast before it is delivered to less preferred receivers.  This
1141441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * call is asynchronous; it returns immediately, and you will continue
1142441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * executing while the receivers are run.
1143441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *
1144441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1145441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *
1146441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
1147a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *               Intent will receive the broadcast.
1148214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     * @param receiverPermission (optional) String naming a permissions that
1149214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     *               a receiver must hold in order to receive your broadcast.
1150441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *               If null, no permission is required.
1151441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *
1152441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @see android.content.BroadcastReceiver
11535796bf4913832bd1165c3ff5e04838d150de1c4cDaniel Dunbar     * @see #registerReceiver
1154441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @see #sendBroadcast(Intent)
1155441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1156441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     */
1157441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar    public abstract void sendOrderedBroadcast(Intent intent,
1158441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar            String receiverPermission);
1159441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar
1160441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar    /**
1161441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * Version of {@link #sendBroadcast(Intent)} that allows you to
1162441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * receive data back from the broadcast.  This is accomplished by
1163441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * supplying your own BroadcastReceiver when calling, which will be
1164441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * treated as a final receiver at the end of the broadcast -- its
1165441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * {@link BroadcastReceiver#onReceive} method will be called with
1166441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * the result values collected from the other receivers.  The broadcast will
1167441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * be serialized in the same way as calling
1168441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * {@link #sendOrderedBroadcast(Intent, String)}.
1169441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *
1170441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * <p>Like {@link #sendBroadcast(Intent)}, this method is
1171441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * asynchronous; it will return before
1172a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * resultReceiver.onReceive() is called.
1173441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *
1174441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
117556c5594515571eab0e02368ed05416b9dac20837Daniel Dunbar     *
117656c5594515571eab0e02368ed05416b9dac20837Daniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
117756c5594515571eab0e02368ed05416b9dac20837Daniel Dunbar     *               Intent will receive the broadcast.
117856c5594515571eab0e02368ed05416b9dac20837Daniel Dunbar     * @param receiverPermission String naming a permissions that
1179441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *               a receiver must hold in order to receive your broadcast.
1180441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *               If null, no permission is required.
1181441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1182441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *                       receiver of the broadcast.
1183441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     * @param scheduler A custom Handler with which to schedule the
1184441d060838a5797691777dfcc992ff836b73dcd1Daniel Dunbar     *                  resultReceiver callback; if null it will be
11855ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     *                  scheduled in the Context's main thread.
11860edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     * @param initialCode An initial value for the result code.  Often
1187a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *                    Activity.RESULT_OK.
11880edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     * @param initialData An initial value for the result data.  Often
11890edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     *                    null.
11900edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     * @param initialExtras An initial value for the result extras.  Often
11910edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     *                      null.
11925ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     *
11930edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     * @see #sendBroadcast(Intent)
11940edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     * @see #sendBroadcast(Intent, String)
11955ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     * @see #sendOrderedBroadcast(Intent, String)
1196cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @see #sendStickyBroadcast(Intent)
1197cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
11985ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     * @see android.content.BroadcastReceiver
11995ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     * @see #registerReceiver
12000edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     * @see android.app.Activity#RESULT_OK
1201a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     */
12020edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar    public abstract void sendOrderedBroadcast(Intent intent,
12030edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar            String receiverPermission, BroadcastReceiver resultReceiver,
12040edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar            Handler scheduler, int initialCode, String initialData,
1205950bedd8a9f00caabd2f1fc6812d70e08103f847Mike Stump            Bundle initialExtras);
12065ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar
12070edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar    /**
12080edefebc10fbc627d55d53936fc66178d1c08da1Daniel Dunbar     * Version of {@link #sendBroadcast(Intent)} that allows you to specify the
1209c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar     * user the broadcast will be sent to.  This is not available to applications
1210c50b00dbd843cd929b5f220d4a8699852249f64cDaniel Dunbar     * that are not pre-installed on the system image.  Using it requires holding
1211632f50edc08c76ebc643a0d4871bae33a55d7b4eDaniel Dunbar     * the INTERACT_ACROSS_USERS permission.
12125ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     * @param intent The intent to broadcast
1213632f50edc08c76ebc643a0d4871bae33a55d7b4eDaniel Dunbar     * @param user UserHandle to send the intent to.
12145ed34f4c58b6ad4e21038d713c1fae31a6146ff5Daniel Dunbar     * @see #sendBroadcast(Intent)
1215cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar     */
1216cb881672c2c46142ec1bdfa401c9818ae805db0fDaniel Dunbar    public abstract void sendBroadcastAsUser(Intent intent, UserHandle user);
1217214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar
1218a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
1219a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Version of {@link #sendBroadcast(Intent, String)} that allows you to specify the
1220214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     * user the broadcast will be sent to.  This is not available to applications
1221b03417fdc42ae19d2deb2ee1e5d2c3e9896a2a04Daniel Dunbar     * that are not pre-installed on the system image.  Using it requires holding
1222b03417fdc42ae19d2deb2ee1e5d2c3e9896a2a04Daniel Dunbar     * the INTERACT_ACROSS_USERS permission.
1223b03417fdc42ae19d2deb2ee1e5d2c3e9896a2a04Daniel Dunbar     *
1224b03417fdc42ae19d2deb2ee1e5d2c3e9896a2a04Daniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
12253ca7ee9a40532167f67bde17fff5e678f183f3f2Daniel Dunbar     *               Intent will receive the broadcast.
12263ca7ee9a40532167f67bde17fff5e678f183f3f2Daniel Dunbar     * @param user UserHandle to send the intent to.
1227b03417fdc42ae19d2deb2ee1e5d2c3e9896a2a04Daniel Dunbar     * @param receiverPermission (optional) String naming a permission that
1228b03417fdc42ae19d2deb2ee1e5d2c3e9896a2a04Daniel Dunbar     *               a receiver must hold in order to receive your broadcast.
1229f60c63af0ed33ab890600ee6146e7685901f46dfDaniel Dunbar     *               If null, no permission is required.
1230214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     *
1231214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     * @see #sendBroadcast(Intent, String)
1232214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     */
1233214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar    public abstract void sendBroadcastAsUser(Intent intent, UserHandle user,
1234214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar            String receiverPermission);
1235a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar
123684603bc4ed98caca9b82c1a68e63939927d8cd6dDaniel Dunbar    /**
123784603bc4ed98caca9b82c1a68e63939927d8cd6dDaniel Dunbar     * Version of
1238214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     * {@link #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)}
1239d57a7ef9252964bc6c8471451d7bd395b0520cb8Chris Lattner     * that allows you to specify the
1240214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     * user the broadcast will be sent to.  This is not available to applications
1241214399ebd73545dde02b4a45872e7ca9e1d9e742Daniel Dunbar     * that are not pre-installed on the system image.  Using it requires holding
1242cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     * the INTERACT_ACROSS_USERS permission.
12438f25c79e59d88df41c5a3cabba1c58035d384a6eDaniel Dunbar     *
1244cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1245dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar     *
1246cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
1247e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan     *               Intent will receive the broadcast.
1248e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan     * @param user UserHandle to send the intent to.
1249cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     * @param receiverPermission String naming a permissions that
1250cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     *               a receiver must hold in order to receive your broadcast.
1251cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     *               If null, no permission is required.
1252cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1253f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar     *                       receiver of the broadcast.
1254f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar     * @param scheduler A custom Handler with which to schedule the
1255cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     *                  resultReceiver callback; if null it will be
1256cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     *                  scheduled in the Context's main thread.
12576b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman     * @param initialCode An initial value for the result code.  Often
12586b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman     *                    Activity.RESULT_OK.
1259cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     * @param initialData An initial value for the result data.  Often
1260cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     *                    null.
1261cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar     * @param initialExtras An initial value for the result extras.  Often
1262dd98e2cad165ca73c769e4f105a4e47c2216387aDaniel Dunbar     *                      null.
1263af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     *
1264af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * @see #sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
1265a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     */
1266a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    public abstract void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
1267a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar            String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler,
12685915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar            int initialCode, String initialData, Bundle initialExtras);
1269af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar
1270af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar    /**
1271af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * Perform a {@link #sendBroadcast(Intent)} that is "sticky," meaning the
12720f99d2e57d8e3cf2508e7f9f868d41eccdc229c9Daniel Dunbar     * Intent you are sending stays around after the broadcast is complete,
1273af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * so that others can quickly retrieve that data through the return
12746256d3654533547a7996170647c21a859cb441e1Daniel Dunbar     * value of {@link #registerReceiver(BroadcastReceiver, IntentFilter)}.  In
12756256d3654533547a7996170647c21a859cb441e1Daniel Dunbar     * all other ways, this behaves the same as
1276af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * {@link #sendBroadcast(Intent)}.
12776256d3654533547a7996170647c21a859cb441e1Daniel Dunbar     *
1278af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
1279af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * permission in order to use this API.  If you do not hold that
1280af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * permission, {@link SecurityException} will be thrown.
12810f99d2e57d8e3cf2508e7f9f868d41eccdc229c9Daniel Dunbar     *
12826256d3654533547a7996170647c21a859cb441e1Daniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
12836256d3654533547a7996170647c21a859cb441e1Daniel Dunbar     * Intent will receive the broadcast, and the Intent will be held to
1284af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * be re-broadcast to future receivers.
12856256d3654533547a7996170647c21a859cb441e1Daniel Dunbar     *
1286af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * @see #sendBroadcast(Intent)
1287a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
12885915fbf310e171c4cd3c2af05e9de360c0fa988aDaniel Dunbar     */
1289fec26bd1f4681db8c253fb86529e52bcad28a3ffDaniel Dunbar    public abstract void sendStickyBroadcast(Intent intent);
1290fec26bd1f4681db8c253fb86529e52bcad28a3ffDaniel Dunbar
1291a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar    /**
1292a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * Version of {@link #sendStickyBroadcast} that allows you to
1293a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * receive data back from the broadcast.  This is accomplished by
1294a6046bec7fc835186dde134fb81aa1b7d45cd9f0Daniel Dunbar     * supplying your own BroadcastReceiver when calling, which will be
1295af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * treated as a final receiver at the end of the broadcast -- its
12966256d3654533547a7996170647c21a859cb441e1Daniel Dunbar     * {@link BroadcastReceiver#onReceive} method will be called with
1297af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * the result values collected from the other receivers.  The broadcast will
1298af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * be serialized in the same way as calling
1299af80e1ffafeb77929cc0b9ba8940a7f1c0b80d51Daniel Dunbar     * {@link #sendOrderedBroadcast(Intent, String)}.
1300d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *
1301a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * <p>Like {@link #sendBroadcast(Intent)}, this method is
1302a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * asynchronous; it will return before
1303d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * resultReceiver.onReceive() is called.  Note that the sticky data
1304a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * stored is only the data you initially supply to the broadcast, not
1305a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     * the result of any changes made by the receivers.
1306a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *
1307d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1308d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *
1309d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @param intent The Intent to broadcast; all receivers matching this
1310d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *               Intent will receive the broadcast.
1311d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1312a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *                       receiver of the broadcast.
1313d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @param scheduler A custom Handler with which to schedule the
1314d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *                  resultReceiver callback; if null it will be
1315d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *                  scheduled in the Context's main thread.
1316d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @param initialCode An initial value for the result code.  Often
1317d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *                    Activity.RESULT_OK.
1318d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @param initialData An initial value for the result data.  Often
1319d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *                    null.
1320d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @param initialExtras An initial value for the result extras.  Often
1321a82318332c9e9b61d3d17371e675ca2859877ee5Daniel Dunbar     *                      null.
1322d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     *
1323d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @see #sendBroadcast(Intent)
1324d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @see #sendBroadcast(Intent, String)
1325d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @see #sendOrderedBroadcast(Intent, String)
1326d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @see #sendStickyBroadcast(Intent)
1327d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @see android.content.BroadcastReceiver
1328d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @see #registerReceiver
1329d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * @see android.app.Activity#RESULT_OK
1330d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     */
1331d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar    public abstract void sendStickyOrderedBroadcast(Intent intent,
1332d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar            BroadcastReceiver resultReceiver,
1333d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar            Handler scheduler, int initialCode, String initialData,
1334d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar            Bundle initialExtras);
1335d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar
1336d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar    /**
1337d73fe9b70c5f6738d004744562287a62831f39bfDaniel Dunbar     * Remove the data previously sent with {@link #sendStickyBroadcast},
1338     * so that it is as if the sticky broadcast had never happened.
1339     *
1340     * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
1341     * permission in order to use this API.  If you do not hold that
1342     * permission, {@link SecurityException} will be thrown.
1343     *
1344     * @param intent The Intent that was previously broadcast.
1345     *
1346     * @see #sendStickyBroadcast
1347     */
1348    public abstract void removeStickyBroadcast(Intent intent);
1349
1350    /**
1351     * Version of {@link #sendStickyBroadcast(Intent)} that allows you to specify the
1352     * user the broadcast will be sent to.  This is not available to applications
1353     * that are not pre-installed on the system image.  Using it requires holding
1354     * the INTERACT_ACROSS_USERS permission.
1355     *
1356     * @param intent The Intent to broadcast; all receivers matching this
1357     * Intent will receive the broadcast, and the Intent will be held to
1358     * be re-broadcast to future receivers.
1359     * @param user UserHandle to send the intent to.
1360     *
1361     * @see #sendBroadcast(Intent)
1362     */
1363    public abstract void sendStickyBroadcastAsUser(Intent intent, UserHandle user);
1364
1365    /**
1366     * Version of
1367     * {@link #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)}
1368     * that allows you to specify the
1369     * user the broadcast will be sent to.  This is not available to applications
1370     * that are not pre-installed on the system image.  Using it requires holding
1371     * the INTERACT_ACROSS_USERS permission.
1372     *
1373     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1374     *
1375     * @param intent The Intent to broadcast; all receivers matching this
1376     *               Intent will receive the broadcast.
1377     * @param user UserHandle to send the intent to.
1378     * @param resultReceiver Your own BroadcastReceiver to treat as the final
1379     *                       receiver of the broadcast.
1380     * @param scheduler A custom Handler with which to schedule the
1381     *                  resultReceiver callback; if null it will be
1382     *                  scheduled in the Context's main thread.
1383     * @param initialCode An initial value for the result code.  Often
1384     *                    Activity.RESULT_OK.
1385     * @param initialData An initial value for the result data.  Often
1386     *                    null.
1387     * @param initialExtras An initial value for the result extras.  Often
1388     *                      null.
1389     *
1390     * @see #sendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, int, String, Bundle)
1391     */
1392    public abstract void sendStickyOrderedBroadcastAsUser(Intent intent,
1393            UserHandle user, BroadcastReceiver resultReceiver,
1394            Handler scheduler, int initialCode, String initialData,
1395            Bundle initialExtras);
1396
1397    /**
1398     * Version of {@link #removeStickyBroadcast(Intent)} that allows you to specify the
1399     * user the broadcast will be sent to.  This is not available to applications
1400     * that are not pre-installed on the system image.  Using it requires holding
1401     * the INTERACT_ACROSS_USERS permission.
1402     *
1403     * <p>You must hold the {@link android.Manifest.permission#BROADCAST_STICKY}
1404     * permission in order to use this API.  If you do not hold that
1405     * permission, {@link SecurityException} will be thrown.
1406     *
1407     * @param intent The Intent that was previously broadcast.
1408     * @param user UserHandle to remove the sticky broadcast from.
1409     *
1410     * @see #sendStickyBroadcastAsUser
1411     */
1412    public abstract void removeStickyBroadcastAsUser(Intent intent, UserHandle user);
1413
1414    /**
1415     * Register a BroadcastReceiver to be run in the main activity thread.  The
1416     * <var>receiver</var> will be called with any broadcast Intent that
1417     * matches <var>filter</var>, in the main application thread.
1418     *
1419     * <p>The system may broadcast Intents that are "sticky" -- these stay
1420     * around after the broadcast as finished, to be sent to any later
1421     * registrations. If your IntentFilter matches one of these sticky
1422     * Intents, that Intent will be returned by this function
1423     * <strong>and</strong> sent to your <var>receiver</var> as if it had just
1424     * been broadcast.
1425     *
1426     * <p>There may be multiple sticky Intents that match <var>filter</var>,
1427     * in which case each of these will be sent to <var>receiver</var>.  In
1428     * this case, only one of these can be returned directly by the function;
1429     * which of these that is returned is arbitrarily decided by the system.
1430     *
1431     * <p>If you know the Intent your are registering for is sticky, you can
1432     * supply null for your <var>receiver</var>.  In this case, no receiver is
1433     * registered -- the function simply returns the sticky Intent that
1434     * matches <var>filter</var>.  In the case of multiple matches, the same
1435     * rules as described above apply.
1436     *
1437     * <p>See {@link BroadcastReceiver} for more information on Intent broadcasts.
1438     *
1439     * <p>As of {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH}, receivers
1440     * registered with this method will correctly respect the
1441     * {@link Intent#setPackage(String)} specified for an Intent being broadcast.
1442     * Prior to that, it would be ignored and delivered to all matching registered
1443     * receivers.  Be careful if using this for security.</p>
1444     *
1445     * <p class="note">Note: this method <em>cannot be called from a
1446     * {@link BroadcastReceiver} component;</em> that is, from a BroadcastReceiver
1447     * that is declared in an application's manifest.  It is okay, however, to call
1448     * this method from another BroadcastReceiver that has itself been registered
1449     * at run time with {@link #registerReceiver}, since the lifetime of such a
1450     * registered BroadcastReceiver is tied to the object that registered it.</p>
1451     *
1452     * @param receiver The BroadcastReceiver to handle the broadcast.
1453     * @param filter Selects the Intent broadcasts to be received.
1454     *
1455     * @return The first sticky intent found that matches <var>filter</var>,
1456     *         or null if there are none.
1457     *
1458     * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
1459     * @see #sendBroadcast
1460     * @see #unregisterReceiver
1461     */
1462    public abstract Intent registerReceiver(BroadcastReceiver receiver,
1463                                            IntentFilter filter);
1464
1465    /**
1466     * Register to receive intent broadcasts, to run in the context of
1467     * <var>scheduler</var>.  See
1468     * {@link #registerReceiver(BroadcastReceiver, IntentFilter)} for more
1469     * information.  This allows you to enforce permissions on who can
1470     * broadcast intents to your receiver, or have the receiver run in
1471     * a different thread than the main application thread.
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     * @param receiver The BroadcastReceiver to handle the broadcast.
1482     * @param filter Selects the Intent broadcasts to be received.
1483     * @param broadcastPermission String naming a permissions that a
1484     *      broadcaster must hold in order to send an Intent to you.  If null,
1485     *      no permission is required.
1486     * @param scheduler Handler identifying the thread that will receive
1487     *      the Intent.  If null, the main thread of the process will be used.
1488     *
1489     * @return The first sticky intent found that matches <var>filter</var>,
1490     *         or null if there are none.
1491     *
1492     * @see #registerReceiver(BroadcastReceiver, IntentFilter)
1493     * @see #sendBroadcast
1494     * @see #unregisterReceiver
1495     */
1496    public abstract Intent registerReceiver(BroadcastReceiver receiver,
1497            IntentFilter filter, String broadcastPermission, Handler scheduler);
1498
1499    /**
1500     * @hide
1501     * Same as {@link #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
1502     * but for a specific user.  This receiver will receiver broadcasts that
1503     * are sent to the requested user.  It
1504     * requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL}
1505     * permission.
1506     *
1507     * @param receiver The BroadcastReceiver to handle the broadcast.
1508     * @param user UserHandle to send the intent to.
1509     * @param filter Selects the Intent broadcasts to be received.
1510     * @param broadcastPermission String naming a permissions that a
1511     *      broadcaster must hold in order to send an Intent to you.  If null,
1512     *      no permission is required.
1513     * @param scheduler Handler identifying the thread that will receive
1514     *      the Intent.  If null, the main thread of the process will be used.
1515     *
1516     * @return The first sticky intent found that matches <var>filter</var>,
1517     *         or null if there are none.
1518     *
1519     * @see #registerReceiver(BroadcastReceiver, IntentFilter, String, Handler
1520     * @see #sendBroadcast
1521     * @see #unregisterReceiver
1522     */
1523    public abstract Intent registerReceiverAsUser(BroadcastReceiver receiver,
1524            UserHandle user, IntentFilter filter, String broadcastPermission,
1525            Handler scheduler);
1526
1527    /**
1528     * Unregister a previously registered BroadcastReceiver.  <em>All</em>
1529     * filters that have been registered for this BroadcastReceiver will be
1530     * removed.
1531     *
1532     * @param receiver The BroadcastReceiver to unregister.
1533     *
1534     * @see #registerReceiver
1535     */
1536    public abstract void unregisterReceiver(BroadcastReceiver receiver);
1537
1538    /**
1539     * Request that a given application service be started.  The Intent
1540     * can either contain the complete class name of a specific service
1541     * implementation to start, or an abstract definition through the
1542     * action and other fields of the kind of service to start.  If this service
1543     * is not already running, it will be instantiated and started (creating a
1544     * process for it if needed); if it is running then it remains running.
1545     *
1546     * <p>Every call to this method will result in a corresponding call to
1547     * the target service's {@link android.app.Service#onStartCommand} method,
1548     * with the <var>intent</var> given here.  This provides a convenient way
1549     * to submit jobs to a service without having to bind and call on to its
1550     * interface.
1551     *
1552     * <p>Using startService() overrides the default service lifetime that is
1553     * managed by {@link #bindService}: it requires the service to remain
1554     * running until {@link #stopService} is called, regardless of whether
1555     * any clients are connected to it.  Note that calls to startService()
1556     * are not nesting: no matter how many times you call startService(),
1557     * a single call to {@link #stopService} will stop it.
1558     *
1559     * <p>The system attempts to keep running services around as much as
1560     * possible.  The only time they should be stopped is if the current
1561     * foreground application is using so many resources that the service needs
1562     * to be killed.  If any errors happen in the service's process, it will
1563     * automatically be restarted.
1564     *
1565     * <p>This function will throw {@link SecurityException} if you do not
1566     * have permission to start the given service.
1567     *
1568     * @param service Identifies the service to be started.  The Intent may
1569     *      specify either an explicit component name to start, or a logical
1570     *      description (action, category, etc) to match an
1571     *      {@link IntentFilter} published by a service.  Additional values
1572     *      may be included in the Intent extras to supply arguments along with
1573     *      this specific start call.
1574     *
1575     * @return If the service is being started or is already running, the
1576     * {@link ComponentName} of the actual service that was started is
1577     * returned; else if the service does not exist null is returned.
1578     *
1579     * @throws SecurityException
1580     *
1581     * @see #stopService
1582     * @see #bindService
1583     */
1584    public abstract ComponentName startService(Intent service);
1585
1586    /**
1587     * Request that a given application service be stopped.  If the service is
1588     * not running, nothing happens.  Otherwise it is stopped.  Note that calls
1589     * to startService() are not counted -- this stops the service no matter
1590     * how many times it was started.
1591     *
1592     * <p>Note that if a stopped service still has {@link ServiceConnection}
1593     * objects bound to it with the {@link #BIND_AUTO_CREATE} set, it will
1594     * not be destroyed until all of these bindings are removed.  See
1595     * the {@link android.app.Service} documentation for more details on a
1596     * service's lifecycle.
1597     *
1598     * <p>This function will throw {@link SecurityException} if you do not
1599     * have permission to stop the given service.
1600     *
1601     * @param service Description of the service to be stopped.  The Intent may
1602     *      specify either an explicit component name to start, or a logical
1603     *      description (action, category, etc) to match an
1604     *      {@link IntentFilter} published by a service.
1605     *
1606     * @return If there is a service matching the given Intent that is already
1607     * running, then it is stopped and true is returned; else false is returned.
1608     *
1609     * @throws SecurityException
1610     *
1611     * @see #startService
1612     */
1613    public abstract boolean stopService(Intent service);
1614
1615    /**
1616     * @hide like {@link #startService(Intent)} but for a specific user.
1617     */
1618    public abstract ComponentName startServiceAsUser(Intent service, UserHandle user);
1619
1620    /**
1621     * @hide like {@link #stopService(Intent)} but for a specific user.
1622     */
1623    public abstract boolean stopServiceAsUser(Intent service, UserHandle user);
1624
1625    /**
1626     * Connect to an application service, creating it if needed.  This defines
1627     * a dependency between your application and the service.  The given
1628     * <var>conn</var> will receive the service object when it is created and be
1629     * told if it dies and restarts.  The service will be considered required
1630     * by the system only for as long as the calling context exists.  For
1631     * example, if this Context is an Activity that is stopped, the service will
1632     * not be required to continue running until the Activity is resumed.
1633     *
1634     * <p>This function will throw {@link SecurityException} if you do not
1635     * have permission to bind to the given service.
1636     *
1637     * <p class="note">Note: this method <em>can not be called from a
1638     * {@link BroadcastReceiver} component</em>.  A pattern you can use to
1639     * communicate from a BroadcastReceiver to a Service is to call
1640     * {@link #startService} with the arguments containing the command to be
1641     * sent, with the service calling its
1642     * {@link android.app.Service#stopSelf(int)} method when done executing
1643     * that command.  See the API demo App/Service/Service Start Arguments
1644     * Controller for an illustration of this.  It is okay, however, to use
1645     * this method from a BroadcastReceiver that has been registered with
1646     * {@link #registerReceiver}, since the lifetime of this BroadcastReceiver
1647     * is tied to another object (the one that registered it).</p>
1648     *
1649     * @param service Identifies the service to connect to.  The Intent may
1650     *      specify either an explicit component name, or a logical
1651     *      description (action, category, etc) to match an
1652     *      {@link IntentFilter} published by a service.
1653     * @param conn Receives information as the service is started and stopped.
1654     *      This must be a valid ServiceConnection object; it must not be null.
1655     * @param flags Operation options for the binding.  May be 0,
1656     *          {@link #BIND_AUTO_CREATE}, {@link #BIND_DEBUG_UNBIND},
1657     *          {@link #BIND_NOT_FOREGROUND}, {@link #BIND_ABOVE_CLIENT},
1658     *          {@link #BIND_ALLOW_OOM_MANAGEMENT}, or
1659     *          {@link #BIND_WAIVE_PRIORITY}.
1660     * @return If you have successfully bound to the service, true is returned;
1661     *         false is returned if the connection is not made so you will not
1662     *         receive the service object.
1663     *
1664     * @throws SecurityException
1665     *
1666     * @see #unbindService
1667     * @see #startService
1668     * @see #BIND_AUTO_CREATE
1669     * @see #BIND_DEBUG_UNBIND
1670     * @see #BIND_NOT_FOREGROUND
1671     */
1672    public abstract boolean bindService(Intent service, ServiceConnection conn,
1673            int flags);
1674
1675    /**
1676     * Same as {@link #bindService(Intent, ServiceConnection, int)}, but with an explicit userHandle
1677     * argument for use by system server and other multi-user aware code.
1678     * @hide
1679     */
1680    public boolean bindService(Intent service, ServiceConnection conn, int flags, int userHandle) {
1681        throw new RuntimeException("Not implemented. Must override in a subclass.");
1682    }
1683
1684    /**
1685     * Disconnect from an application service.  You will no longer receive
1686     * calls as the service is restarted, and the service is now allowed to
1687     * stop at any time.
1688     *
1689     * @param conn The connection interface previously supplied to
1690     *             bindService().  This parameter must not be null.
1691     *
1692     * @see #bindService
1693     */
1694    public abstract void unbindService(ServiceConnection conn);
1695
1696    /**
1697     * Start executing an {@link android.app.Instrumentation} class.  The given
1698     * Instrumentation component will be run by killing its target application
1699     * (if currently running), starting the target process, instantiating the
1700     * instrumentation component, and then letting it drive the application.
1701     *
1702     * <p>This function is not synchronous -- it returns as soon as the
1703     * instrumentation has started and while it is running.
1704     *
1705     * <p>Instrumentation is normally only allowed to run against a package
1706     * that is either unsigned or signed with a signature that the
1707     * the instrumentation package is also signed with (ensuring the target
1708     * trusts the instrumentation).
1709     *
1710     * @param className Name of the Instrumentation component to be run.
1711     * @param profileFile Optional path to write profiling data as the
1712     * instrumentation runs, or null for no profiling.
1713     * @param arguments Additional optional arguments to pass to the
1714     * instrumentation, or null.
1715     *
1716     * @return Returns true if the instrumentation was successfully started,
1717     * else false if it could not be found.
1718     */
1719    public abstract boolean startInstrumentation(ComponentName className,
1720            String profileFile, Bundle arguments);
1721
1722    /**
1723     * Return the handle to a system-level service by name. The class of the
1724     * returned object varies by the requested name. Currently available names
1725     * are:
1726     *
1727     * <dl>
1728     *  <dt> {@link #WINDOW_SERVICE} ("window")
1729     *  <dd> The top-level window manager in which you can place custom
1730     *  windows.  The returned object is a {@link android.view.WindowManager}.
1731     *  <dt> {@link #LAYOUT_INFLATER_SERVICE} ("layout_inflater")
1732     *  <dd> A {@link android.view.LayoutInflater} for inflating layout resources
1733     *  in this context.
1734     *  <dt> {@link #ACTIVITY_SERVICE} ("activity")
1735     *  <dd> A {@link android.app.ActivityManager} for interacting with the
1736     *  global activity state of the system.
1737     *  <dt> {@link #POWER_SERVICE} ("power")
1738     *  <dd> A {@link android.os.PowerManager} for controlling power
1739     *  management.
1740     *  <dt> {@link #ALARM_SERVICE} ("alarm")
1741     *  <dd> A {@link android.app.AlarmManager} for receiving intents at the
1742     *  time of your choosing.
1743     *  <dt> {@link #NOTIFICATION_SERVICE} ("notification")
1744     *  <dd> A {@link android.app.NotificationManager} for informing the user
1745     *   of background events.
1746     *  <dt> {@link #KEYGUARD_SERVICE} ("keyguard")
1747     *  <dd> A {@link android.app.KeyguardManager} for controlling keyguard.
1748     *  <dt> {@link #LOCATION_SERVICE} ("location")
1749     *  <dd> A {@link android.location.LocationManager} for controlling location
1750     *   (e.g., GPS) updates.
1751     *  <dt> {@link #SEARCH_SERVICE} ("search")
1752     *  <dd> A {@link android.app.SearchManager} for handling search.
1753     *  <dt> {@link #VIBRATOR_SERVICE} ("vibrator")
1754     *  <dd> A {@link android.os.Vibrator} for interacting with the vibrator
1755     *  hardware.
1756     *  <dt> {@link #CONNECTIVITY_SERVICE} ("connection")
1757     *  <dd> A {@link android.net.ConnectivityManager ConnectivityManager} for
1758     *  handling management of network connections.
1759     *  <dt> {@link #WIFI_SERVICE} ("wifi")
1760     *  <dd> A {@link android.net.wifi.WifiManager WifiManager} for management of
1761     * Wi-Fi connectivity.
1762     * <dt> {@link #INPUT_METHOD_SERVICE} ("input_method")
1763     * <dd> An {@link android.view.inputmethod.InputMethodManager InputMethodManager}
1764     * for management of input methods.
1765     * <dt> {@link #UI_MODE_SERVICE} ("uimode")
1766     * <dd> An {@link android.app.UiModeManager} for controlling UI modes.
1767     * <dt> {@link #DOWNLOAD_SERVICE} ("download")
1768     * <dd> A {@link android.app.DownloadManager} for requesting HTTP downloads
1769     * </dl>
1770     *
1771     * <p>Note:  System services obtained via this API may be closely associated with
1772     * the Context in which they are obtained from.  In general, do not share the
1773     * service objects between various different contexts (Activities, Applications,
1774     * Services, Providers, etc.)
1775     *
1776     * @param name The name of the desired service.
1777     *
1778     * @return The service or null if the name does not exist.
1779     *
1780     * @see #WINDOW_SERVICE
1781     * @see android.view.WindowManager
1782     * @see #LAYOUT_INFLATER_SERVICE
1783     * @see android.view.LayoutInflater
1784     * @see #ACTIVITY_SERVICE
1785     * @see android.app.ActivityManager
1786     * @see #POWER_SERVICE
1787     * @see android.os.PowerManager
1788     * @see #ALARM_SERVICE
1789     * @see android.app.AlarmManager
1790     * @see #NOTIFICATION_SERVICE
1791     * @see android.app.NotificationManager
1792     * @see #KEYGUARD_SERVICE
1793     * @see android.app.KeyguardManager
1794     * @see #LOCATION_SERVICE
1795     * @see android.location.LocationManager
1796     * @see #SEARCH_SERVICE
1797     * @see android.app.SearchManager
1798     * @see #SENSOR_SERVICE
1799     * @see android.hardware.SensorManager
1800     * @see #STORAGE_SERVICE
1801     * @see android.os.storage.StorageManager
1802     * @see #VIBRATOR_SERVICE
1803     * @see android.os.Vibrator
1804     * @see #CONNECTIVITY_SERVICE
1805     * @see android.net.ConnectivityManager
1806     * @see #WIFI_SERVICE
1807     * @see android.net.wifi.WifiManager
1808     * @see #AUDIO_SERVICE
1809     * @see android.media.AudioManager
1810     * @see #MEDIA_ROUTER_SERVICE
1811     * @see android.media.MediaRouter
1812     * @see #TELEPHONY_SERVICE
1813     * @see android.telephony.TelephonyManager
1814     * @see #INPUT_METHOD_SERVICE
1815     * @see android.view.inputmethod.InputMethodManager
1816     * @see #UI_MODE_SERVICE
1817     * @see android.app.UiModeManager
1818     * @see #DOWNLOAD_SERVICE
1819     * @see android.app.DownloadManager
1820     */
1821    public abstract Object getSystemService(String name);
1822
1823    /**
1824     * Use with {@link #getSystemService} to retrieve a
1825     * {@link android.os.PowerManager} for controlling power management,
1826     * including "wake locks," which let you keep the device on while
1827     * you're running long tasks.
1828     */
1829    public static final String POWER_SERVICE = "power";
1830
1831    /**
1832     * Use with {@link #getSystemService} to retrieve a
1833     * {@link android.view.WindowManager} for accessing the system's window
1834     * manager.
1835     *
1836     * @see #getSystemService
1837     * @see android.view.WindowManager
1838     */
1839    public static final String WINDOW_SERVICE = "window";
1840
1841    /**
1842     * Use with {@link #getSystemService} to retrieve a
1843     * {@link android.view.LayoutInflater} for inflating layout resources in this
1844     * context.
1845     *
1846     * @see #getSystemService
1847     * @see android.view.LayoutInflater
1848     */
1849    public static final String LAYOUT_INFLATER_SERVICE = "layout_inflater";
1850
1851    /**
1852     * Use with {@link #getSystemService} to retrieve a
1853     * {@link android.accounts.AccountManager} for receiving intents at a
1854     * time of your choosing.
1855     *
1856     * @see #getSystemService
1857     * @see android.accounts.AccountManager
1858     */
1859    public static final String ACCOUNT_SERVICE = "account";
1860
1861    /**
1862     * Use with {@link #getSystemService} to retrieve a
1863     * {@link android.app.ActivityManager} for interacting with the global
1864     * system state.
1865     *
1866     * @see #getSystemService
1867     * @see android.app.ActivityManager
1868     */
1869    public static final String ACTIVITY_SERVICE = "activity";
1870
1871    /**
1872     * Use with {@link #getSystemService} to retrieve a
1873     * {@link android.app.AlarmManager} for receiving intents at a
1874     * time of your choosing.
1875     *
1876     * @see #getSystemService
1877     * @see android.app.AlarmManager
1878     */
1879    public static final String ALARM_SERVICE = "alarm";
1880
1881    /**
1882     * Use with {@link #getSystemService} to retrieve a
1883     * {@link android.app.NotificationManager} for informing the user of
1884     * background events.
1885     *
1886     * @see #getSystemService
1887     * @see android.app.NotificationManager
1888     */
1889    public static final String NOTIFICATION_SERVICE = "notification";
1890
1891    /**
1892     * Use with {@link #getSystemService} to retrieve a
1893     * {@link android.view.accessibility.AccessibilityManager} for giving the user
1894     * feedback for UI events through the registered event listeners.
1895     *
1896     * @see #getSystemService
1897     * @see android.view.accessibility.AccessibilityManager
1898     */
1899    public static final String ACCESSIBILITY_SERVICE = "accessibility";
1900
1901    /**
1902     * Use with {@link #getSystemService} to retrieve a
1903     * {@link android.app.NotificationManager} for controlling keyguard.
1904     *
1905     * @see #getSystemService
1906     * @see android.app.KeyguardManager
1907     */
1908    public static final String KEYGUARD_SERVICE = "keyguard";
1909
1910    /**
1911     * Use with {@link #getSystemService} to retrieve a {@link
1912     * android.location.LocationManager} for controlling location
1913     * updates.
1914     *
1915     * @see #getSystemService
1916     * @see android.location.LocationManager
1917     */
1918    public static final String LOCATION_SERVICE = "location";
1919
1920    /**
1921     * Use with {@link #getSystemService} to retrieve a
1922     * {@link android.location.CountryDetector} for detecting the country that
1923     * the user is in.
1924     *
1925     * @hide
1926     */
1927    public static final String COUNTRY_DETECTOR = "country_detector";
1928
1929    /**
1930     * Use with {@link #getSystemService} to retrieve a {@link
1931     * android.app.SearchManager} for handling searches.
1932     *
1933     * @see #getSystemService
1934     * @see android.app.SearchManager
1935     */
1936    public static final String SEARCH_SERVICE = "search";
1937
1938    /**
1939     * Use with {@link #getSystemService} to retrieve a {@link
1940     * android.hardware.SensorManager} for accessing sensors.
1941     *
1942     * @see #getSystemService
1943     * @see android.hardware.SensorManager
1944     */
1945    public static final String SENSOR_SERVICE = "sensor";
1946
1947    /**
1948     * Use with {@link #getSystemService} to retrieve a {@link
1949     * android.os.storage.StorageManager} for accessing system storage
1950     * functions.
1951     *
1952     * @see #getSystemService
1953     * @see android.os.storage.StorageManager
1954     */
1955    public static final String STORAGE_SERVICE = "storage";
1956
1957    /**
1958     * Use with {@link #getSystemService} to retrieve a
1959     * com.android.server.WallpaperService for accessing wallpapers.
1960     *
1961     * @see #getSystemService
1962     */
1963    public static final String WALLPAPER_SERVICE = "wallpaper";
1964
1965    /**
1966     * Use with {@link #getSystemService} to retrieve a {@link
1967     * android.os.Vibrator} for interacting with the vibration hardware.
1968     *
1969     * @see #getSystemService
1970     * @see android.os.Vibrator
1971     */
1972    public static final String VIBRATOR_SERVICE = "vibrator";
1973
1974    /**
1975     * Use with {@link #getSystemService} to retrieve a {@link
1976     * android.app.StatusBarManager} for interacting with the status bar.
1977     *
1978     * @see #getSystemService
1979     * @see android.app.StatusBarManager
1980     * @hide
1981     */
1982    public static final String STATUS_BAR_SERVICE = "statusbar";
1983
1984    /**
1985     * Use with {@link #getSystemService} to retrieve a {@link
1986     * android.net.ConnectivityManager} for handling management of
1987     * network connections.
1988     *
1989     * @see #getSystemService
1990     * @see android.net.ConnectivityManager
1991     */
1992    public static final String CONNECTIVITY_SERVICE = "connectivity";
1993
1994    /**
1995     * Use with {@link #getSystemService} to retrieve a {@link
1996     * android.net.ThrottleManager} for handling management of
1997     * throttling.
1998     *
1999     * @hide
2000     * @see #getSystemService
2001     * @see android.net.ThrottleManager
2002     */
2003    public static final String THROTTLE_SERVICE = "throttle";
2004
2005    /**
2006     * Use with {@link #getSystemService} to retrieve a {@link
2007     * android.os.IUpdateLock} for managing runtime sequences that
2008     * must not be interrupted by headless OTA application or similar.
2009     *
2010     * @hide
2011     * @see #getSystemService
2012     * @see android.os.UpdateLock
2013     */
2014    public static final String UPDATE_LOCK_SERVICE = "updatelock";
2015
2016    /**
2017     * Use with {@link #getSystemService} to retrieve a {@link
2018     * android.net.NetworkManagementService} for handling management of
2019     * system network services
2020     *
2021     * @hide
2022     * @see #getSystemService
2023     * @see android.net.NetworkManagementService
2024     */
2025    public static final String NETWORKMANAGEMENT_SERVICE = "network_management";
2026
2027    /** {@hide} */
2028    public static final String NETWORK_STATS_SERVICE = "netstats";
2029    /** {@hide} */
2030    public static final String NETWORK_POLICY_SERVICE = "netpolicy";
2031
2032    /**
2033     * Use with {@link #getSystemService} to retrieve a {@link
2034     * android.net.wifi.WifiManager} for handling management of
2035     * Wi-Fi access.
2036     *
2037     * @see #getSystemService
2038     * @see android.net.wifi.WifiManager
2039     */
2040    public static final String WIFI_SERVICE = "wifi";
2041
2042    /**
2043     * Use with {@link #getSystemService} to retrieve a {@link
2044     * android.net.wifi.p2p.WifiP2pManager} for handling management of
2045     * Wi-Fi peer-to-peer connections.
2046     *
2047     * @see #getSystemService
2048     * @see android.net.wifi.p2p.WifiP2pManager
2049     */
2050    public static final String WIFI_P2P_SERVICE = "wifip2p";
2051
2052    /**
2053     * Use with {@link #getSystemService} to retrieve a {@link
2054     * android.net.nsd.NsdManager} for handling management of network service
2055     * discovery
2056     *
2057     * @see #getSystemService
2058     * @see android.net.nsd.NsdManager
2059     */
2060    public static final String NSD_SERVICE = "servicediscovery";
2061
2062    /**
2063     * Use with {@link #getSystemService} to retrieve a
2064     * {@link android.media.AudioManager} for handling management of volume,
2065     * ringer modes and audio routing.
2066     *
2067     * @see #getSystemService
2068     * @see android.media.AudioManager
2069     */
2070    public static final String AUDIO_SERVICE = "audio";
2071
2072    /**
2073     * Use with {@link #getSystemService} to retrieve a
2074     * {@link android.media.MediaRouter} for controlling and managing
2075     * routing of media.
2076     *
2077     * @see #getSystemService
2078     * @see android.media.MediaRouter
2079     */
2080    public static final String MEDIA_ROUTER_SERVICE = "media_router";
2081
2082    /**
2083     * Use with {@link #getSystemService} to retrieve a
2084     * {@link android.telephony.TelephonyManager} for handling management the
2085     * telephony features of the device.
2086     *
2087     * @see #getSystemService
2088     * @see android.telephony.TelephonyManager
2089     */
2090    public static final String TELEPHONY_SERVICE = "phone";
2091
2092    /**
2093     * Use with {@link #getSystemService} to retrieve a
2094     * {@link android.text.ClipboardManager} for accessing and modifying
2095     * the contents of the global clipboard.
2096     *
2097     * @see #getSystemService
2098     * @see android.text.ClipboardManager
2099     */
2100    public static final String CLIPBOARD_SERVICE = "clipboard";
2101
2102    /**
2103     * Use with {@link #getSystemService} to retrieve a
2104     * {@link android.view.inputmethod.InputMethodManager} for accessing input
2105     * methods.
2106     *
2107     * @see #getSystemService
2108     */
2109    public static final String INPUT_METHOD_SERVICE = "input_method";
2110
2111    /**
2112     * Use with {@link #getSystemService} to retrieve a
2113     * {@link android.view.textservice.TextServicesManager} for accessing
2114     * text services.
2115     *
2116     * @see #getSystemService
2117     */
2118    public static final String TEXT_SERVICES_MANAGER_SERVICE = "textservices";
2119
2120    /**
2121     * Use with {@link #getSystemService} to retrieve a
2122     * {@link android.appwidget.AppWidgetManager} for accessing AppWidgets.
2123     *
2124     * @hide
2125     * @see #getSystemService
2126     */
2127    public static final String APPWIDGET_SERVICE = "appwidget";
2128
2129    /**
2130     * Use with {@link #getSystemService} to retrieve an
2131     * {@link android.app.backup.IBackupManager IBackupManager} for communicating
2132     * with the backup mechanism.
2133     * @hide
2134     *
2135     * @see #getSystemService
2136     */
2137    public static final String BACKUP_SERVICE = "backup";
2138
2139    /**
2140     * Use with {@link #getSystemService} to retrieve a
2141     * {@link android.os.DropBoxManager} instance for recording
2142     * diagnostic logs.
2143     * @see #getSystemService
2144     */
2145    public static final String DROPBOX_SERVICE = "dropbox";
2146
2147    /**
2148     * Use with {@link #getSystemService} to retrieve a
2149     * {@link android.app.admin.DevicePolicyManager} for working with global
2150     * device policy management.
2151     *
2152     * @see #getSystemService
2153     */
2154    public static final String DEVICE_POLICY_SERVICE = "device_policy";
2155
2156    /**
2157     * Use with {@link #getSystemService} to retrieve a
2158     * {@link android.app.UiModeManager} for controlling UI modes.
2159     *
2160     * @see #getSystemService
2161     */
2162    public static final String UI_MODE_SERVICE = "uimode";
2163
2164    /**
2165     * Use with {@link #getSystemService} to retrieve a
2166     * {@link android.app.DownloadManager} for requesting HTTP downloads.
2167     *
2168     * @see #getSystemService
2169     */
2170    public static final String DOWNLOAD_SERVICE = "download";
2171
2172    /**
2173     * Use with {@link #getSystemService} to retrieve a
2174     * {@link android.nfc.NfcManager} for using NFC.
2175     *
2176     * @see #getSystemService
2177     */
2178    public static final String NFC_SERVICE = "nfc";
2179
2180    /**
2181     * Use with {@link #getSystemService} to retrieve a
2182     * {@link android.bluetooth.BluetoothAdapter} for using Bluetooth.
2183     *
2184     * @see #getSystemService
2185     * @hide
2186     */
2187    public static final String BLUETOOTH_SERVICE = "bluetooth";
2188
2189    /**
2190     * Use with {@link #getSystemService} to retrieve a
2191     * {@link android.net.sip.SipManager} for accessing the SIP related service.
2192     *
2193     * @see #getSystemService
2194     */
2195    /** @hide */
2196    public static final String SIP_SERVICE = "sip";
2197
2198    /**
2199     * Use with {@link #getSystemService} to retrieve a {@link
2200     * android.hardware.usb.UsbManager} for access to USB devices (as a USB host)
2201     * and for controlling this device's behavior as a USB device.
2202     *
2203     * @see #getSystemService
2204     * @see android.harware.usb.UsbManager
2205     */
2206    public static final String USB_SERVICE = "usb";
2207
2208    /**
2209     * Use with {@link #getSystemService} to retrieve a {@link
2210     * android.hardware.SerialManager} for access to serial ports.
2211     *
2212     * @see #getSystemService
2213     * @see android.harware.SerialManager
2214     *
2215     * @hide
2216     */
2217    public static final String SERIAL_SERVICE = "serial";
2218
2219    /**
2220     * Use with {@link #getSystemService} to retrieve a
2221     * {@link android.hardware.input.InputManager} for interacting with input devices.
2222     *
2223     * @see #getSystemService
2224     * @see android.hardware.input.InputManager
2225     */
2226    public static final String INPUT_SERVICE = "input";
2227
2228    /**
2229     * Use with {@link #getSystemService} to retrieve a
2230     * {@link android.hardware.display.DisplayManager} for interacting with display devices.
2231     *
2232     * @see #getSystemService
2233     * @see android.hardware.display.DisplayManager
2234     */
2235    public static final String DISPLAY_SERVICE = "display";
2236
2237    /**
2238     * Use with {@link #getSystemService} to retrieve a
2239     * {@link android.os.SchedulingPolicyService} for managing scheduling policy.
2240     *
2241     * @see #getSystemService
2242     * @see android.os.SchedulingPolicyService
2243     *
2244     * @hide
2245     */
2246    public static final String SCHEDULING_POLICY_SERVICE = "scheduling_policy";
2247
2248    /**
2249     * Use with {@link #getSystemService} to retrieve a
2250     * {@link android.os.UserManager} for managing users on devices that support multiple users.
2251     *
2252     * @see #getSystemService
2253     * @see android.os.UserManager
2254     */
2255    public static final String USER_SERVICE = "user";
2256
2257    /**
2258     * Use with {@link #getSystemService} to retrieve a
2259     * {@link android.app.AppOpsManager} for tracking application operations
2260     * on the device.
2261     *
2262     * @see #getSystemService
2263     * @see android.app.AppOpsManager
2264     *
2265     * @hide
2266     */
2267    public static final String APP_OPS_SERVICE = "appops";
2268
2269    /**
2270     * Determine whether the given permission is allowed for a particular
2271     * process and user ID running in the system.
2272     *
2273     * @param permission The name of the permission being checked.
2274     * @param pid The process ID being checked against.  Must be > 0.
2275     * @param uid The user ID being checked against.  A uid of 0 is the root
2276     * user, which will pass every permission check.
2277     *
2278     * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the given
2279     * pid/uid is allowed that permission, or
2280     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2281     *
2282     * @see PackageManager#checkPermission(String, String)
2283     * @see #checkCallingPermission
2284     */
2285    public abstract int checkPermission(String permission, int pid, int uid);
2286
2287    /**
2288     * Determine whether the calling process of an IPC you are handling has been
2289     * granted a particular permission.  This is basically the same as calling
2290     * {@link #checkPermission(String, int, int)} with the pid and uid returned
2291     * by {@link android.os.Binder#getCallingPid} and
2292     * {@link android.os.Binder#getCallingUid}.  One important difference
2293     * is that if you are not currently processing an IPC, this function
2294     * will always fail.  This is done to protect against accidentally
2295     * leaking permissions; you can use {@link #checkCallingOrSelfPermission}
2296     * to avoid this protection.
2297     *
2298     * @param permission The name of the permission being checked.
2299     *
2300     * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the calling
2301     * pid/uid is allowed that permission, or
2302     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2303     *
2304     * @see PackageManager#checkPermission(String, String)
2305     * @see #checkPermission
2306     * @see #checkCallingOrSelfPermission
2307     */
2308    public abstract int checkCallingPermission(String permission);
2309
2310    /**
2311     * Determine whether the calling process of an IPC <em>or you</em> have been
2312     * granted a particular permission.  This is the same as
2313     * {@link #checkCallingPermission}, except it grants your own permissions
2314     * if you are not currently processing an IPC.  Use with care!
2315     *
2316     * @param permission The name of the permission being checked.
2317     *
2318     * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the calling
2319     * pid/uid is allowed that permission, or
2320     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2321     *
2322     * @see PackageManager#checkPermission(String, String)
2323     * @see #checkPermission
2324     * @see #checkCallingPermission
2325     */
2326    public abstract int checkCallingOrSelfPermission(String permission);
2327
2328    /**
2329     * If the given permission is not allowed for a particular process
2330     * and user ID running in the system, throw a {@link SecurityException}.
2331     *
2332     * @param permission The name of the permission being checked.
2333     * @param pid The process ID being checked against.  Must be &gt; 0.
2334     * @param uid The user ID being checked against.  A uid of 0 is the root
2335     * user, which will pass every permission check.
2336     * @param message A message to include in the exception if it is thrown.
2337     *
2338     * @see #checkPermission(String, int, int)
2339     */
2340    public abstract void enforcePermission(
2341            String permission, int pid, int uid, String message);
2342
2343    /**
2344     * If the calling process of an IPC you are handling has not been
2345     * granted a particular permission, throw a {@link
2346     * SecurityException}.  This is basically the same as calling
2347     * {@link #enforcePermission(String, int, int, String)} with the
2348     * pid and uid returned by {@link android.os.Binder#getCallingPid}
2349     * and {@link android.os.Binder#getCallingUid}.  One important
2350     * difference is that if you are not currently processing an IPC,
2351     * this function will always throw the SecurityException.  This is
2352     * done to protect against accidentally leaking permissions; you
2353     * can use {@link #enforceCallingOrSelfPermission} to avoid this
2354     * protection.
2355     *
2356     * @param permission The name of the permission being checked.
2357     * @param message A message to include in the exception if it is thrown.
2358     *
2359     * @see #checkCallingPermission(String)
2360     */
2361    public abstract void enforceCallingPermission(
2362            String permission, String message);
2363
2364    /**
2365     * If neither you nor the calling process of an IPC you are
2366     * handling has been granted a particular permission, throw a
2367     * {@link SecurityException}.  This is the same as {@link
2368     * #enforceCallingPermission}, except it grants your own
2369     * permissions if you are not currently processing an IPC.  Use
2370     * with care!
2371     *
2372     * @param permission The name of the permission being checked.
2373     * @param message A message to include in the exception if it is thrown.
2374     *
2375     * @see #checkCallingOrSelfPermission(String)
2376     */
2377    public abstract void enforceCallingOrSelfPermission(
2378            String permission, String message);
2379
2380    /**
2381     * Grant permission to access a specific Uri to another package, regardless
2382     * of whether that package has general permission to access the Uri's
2383     * content provider.  This can be used to grant specific, temporary
2384     * permissions, typically in response to user interaction (such as the
2385     * user opening an attachment that you would like someone else to
2386     * display).
2387     *
2388     * <p>Normally you should use {@link Intent#FLAG_GRANT_READ_URI_PERMISSION
2389     * Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2390     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION
2391     * Intent.FLAG_GRANT_WRITE_URI_PERMISSION} with the Intent being used to
2392     * start an activity instead of this function directly.  If you use this
2393     * function directly, you should be sure to call
2394     * {@link #revokeUriPermission} when the target should no longer be allowed
2395     * to access it.
2396     *
2397     * <p>To succeed, the content provider owning the Uri must have set the
2398     * {@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
2399     * grantUriPermissions} attribute in its manifest or included the
2400     * {@link android.R.styleable#AndroidManifestGrantUriPermission
2401     * &lt;grant-uri-permissions&gt;} tag.
2402     *
2403     * @param toPackage The package you would like to allow to access the Uri.
2404     * @param uri The Uri you would like to grant access to.
2405     * @param modeFlags The desired access modes.  Any combination of
2406     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION
2407     * Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2408     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION
2409     * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2410     *
2411     * @see #revokeUriPermission
2412     */
2413    public abstract void grantUriPermission(String toPackage, Uri uri,
2414            int modeFlags);
2415
2416    /**
2417     * Remove all permissions to access a particular content provider Uri
2418     * that were previously added with {@link #grantUriPermission}.  The given
2419     * Uri will match all previously granted Uris that are the same or a
2420     * sub-path of the given Uri.  That is, revoking "content://foo/one" will
2421     * revoke both "content://foo/target" and "content://foo/target/sub", but not
2422     * "content://foo".
2423     *
2424     * @param uri The Uri you would like to revoke access to.
2425     * @param modeFlags The desired access modes.  Any combination of
2426     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION
2427     * Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2428     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION
2429     * Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2430     *
2431     * @see #grantUriPermission
2432     */
2433    public abstract void revokeUriPermission(Uri uri, int modeFlags);
2434
2435    /**
2436     * Determine whether a particular process and user ID has been granted
2437     * permission to access a specific URI.  This only checks for permissions
2438     * that have been explicitly granted -- if the given process/uid has
2439     * more general access to the URI's content provider then this check will
2440     * always fail.
2441     *
2442     * @param uri The uri that is being checked.
2443     * @param pid The process ID being checked against.  Must be &gt; 0.
2444     * @param uid The user ID being checked against.  A uid of 0 is the root
2445     * user, which will pass every permission check.
2446     * @param modeFlags The type of access to grant.  May be one or both of
2447     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2448     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2449     *
2450     * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the given
2451     * pid/uid is allowed to access that uri, or
2452     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2453     *
2454     * @see #checkCallingUriPermission
2455     */
2456    public abstract int checkUriPermission(Uri uri, int pid, int uid, int modeFlags);
2457
2458    /**
2459     * Determine whether the calling process and user ID has been
2460     * granted permission to access a specific URI.  This is basically
2461     * the same as calling {@link #checkUriPermission(Uri, int, int,
2462     * int)} with the pid and uid returned by {@link
2463     * android.os.Binder#getCallingPid} and {@link
2464     * android.os.Binder#getCallingUid}.  One important difference is
2465     * that if you are not currently processing an IPC, this function
2466     * will always fail.
2467     *
2468     * @param uri The uri that is being checked.
2469     * @param modeFlags The type of access to grant.  May be one or both of
2470     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2471     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2472     *
2473     * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the caller
2474     * is allowed to access that uri, or
2475     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2476     *
2477     * @see #checkUriPermission(Uri, int, int, int)
2478     */
2479    public abstract int checkCallingUriPermission(Uri uri, int modeFlags);
2480
2481    /**
2482     * Determine whether the calling process of an IPC <em>or you</em> has been granted
2483     * permission to access a specific URI.  This is the same as
2484     * {@link #checkCallingUriPermission}, except it grants your own permissions
2485     * if you are not currently processing an IPC.  Use with care!
2486     *
2487     * @param uri The uri that is being checked.
2488     * @param modeFlags The type of access to grant.  May be one or both of
2489     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2490     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2491     *
2492     * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the caller
2493     * is allowed to access that uri, or
2494     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2495     *
2496     * @see #checkCallingUriPermission
2497     */
2498    public abstract int checkCallingOrSelfUriPermission(Uri uri, int modeFlags);
2499
2500    /**
2501     * Check both a Uri and normal permission.  This allows you to perform
2502     * both {@link #checkPermission} and {@link #checkUriPermission} in one
2503     * call.
2504     *
2505     * @param uri The Uri whose permission is to be checked, or null to not
2506     * do this check.
2507     * @param readPermission The permission that provides overall read access,
2508     * or null to not do this check.
2509     * @param writePermission The permission that provides overall write
2510     * acess, or null to not do this check.
2511     * @param pid The process ID being checked against.  Must be &gt; 0.
2512     * @param uid The user ID being checked against.  A uid of 0 is the root
2513     * user, which will pass every permission check.
2514     * @param modeFlags The type of access to grant.  May be one or both of
2515     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2516     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2517     *
2518     * @return Returns {@link PackageManager#PERMISSION_GRANTED} if the caller
2519     * is allowed to access that uri or holds one of the given permissions, or
2520     * {@link PackageManager#PERMISSION_DENIED} if it is not.
2521     */
2522    public abstract int checkUriPermission(Uri uri, String readPermission,
2523            String writePermission, int pid, int uid, int modeFlags);
2524
2525    /**
2526     * If a particular process and user ID has not been granted
2527     * permission to access a specific URI, throw {@link
2528     * SecurityException}.  This only checks for permissions that have
2529     * been explicitly granted -- if the given process/uid has more
2530     * general access to the URI's content provider then this check
2531     * will always fail.
2532     *
2533     * @param uri The uri that is being checked.
2534     * @param pid The process ID being checked against.  Must be &gt; 0.
2535     * @param uid The user ID being checked against.  A uid of 0 is the root
2536     * user, which will pass every permission check.
2537     * @param modeFlags The type of access to grant.  May be one or both of
2538     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2539     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2540     * @param message A message to include in the exception if it is thrown.
2541     *
2542     * @see #checkUriPermission(Uri, int, int, int)
2543     */
2544    public abstract void enforceUriPermission(
2545            Uri uri, int pid, int uid, int modeFlags, String message);
2546
2547    /**
2548     * If the calling process and user ID has not been granted
2549     * permission to access a specific URI, throw {@link
2550     * SecurityException}.  This is basically the same as calling
2551     * {@link #enforceUriPermission(Uri, int, int, int, String)} with
2552     * the pid and uid returned by {@link
2553     * android.os.Binder#getCallingPid} and {@link
2554     * android.os.Binder#getCallingUid}.  One important difference is
2555     * that if you are not currently processing an IPC, this function
2556     * will always throw a SecurityException.
2557     *
2558     * @param uri The uri that is being checked.
2559     * @param modeFlags The type of access to grant.  May be one or both of
2560     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2561     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2562     * @param message A message to include in the exception if it is thrown.
2563     *
2564     * @see #checkCallingUriPermission(Uri, int)
2565     */
2566    public abstract void enforceCallingUriPermission(
2567            Uri uri, int modeFlags, String message);
2568
2569    /**
2570     * If the calling process of an IPC <em>or you</em> has not been
2571     * granted permission to access a specific URI, throw {@link
2572     * SecurityException}.  This is the same as {@link
2573     * #enforceCallingUriPermission}, except it grants your own
2574     * permissions if you are not currently processing an IPC.  Use
2575     * with care!
2576     *
2577     * @param uri The uri that is being checked.
2578     * @param modeFlags The type of access to grant.  May be one or both of
2579     * {@link Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION} or
2580     * {@link Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION}.
2581     * @param message A message to include in the exception if it is thrown.
2582     *
2583     * @see #checkCallingOrSelfUriPermission(Uri, int)
2584     */
2585    public abstract void enforceCallingOrSelfUriPermission(
2586            Uri uri, int modeFlags, String message);
2587
2588    /**
2589     * Enforce both a Uri and normal permission.  This allows you to perform
2590     * both {@link #enforcePermission} and {@link #enforceUriPermission} in one
2591     * call.
2592     *
2593     * @param uri The Uri whose permission is to be checked, or null to not
2594     * do this check.
2595     * @param readPermission The permission that provides overall read access,
2596     * or null to not do this check.
2597     * @param writePermission The permission that provides overall write
2598     * acess, or null to not do this check.
2599     * @param pid The process ID being checked against.  Must be &gt; 0.
2600     * @param uid The user ID being checked against.  A uid of 0 is the root
2601     * user, which will pass every permission check.
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 #checkUriPermission(Uri, String, String, int, int, int)
2608     */
2609    public abstract void enforceUriPermission(
2610            Uri uri, String readPermission, String writePermission,
2611            int pid, int uid, int modeFlags, String message);
2612
2613    /**
2614     * Flag for use with {@link #createPackageContext}: include the application
2615     * code with the context.  This means loading code into the caller's
2616     * process, so that {@link #getClassLoader()} can be used to instantiate
2617     * the application's classes.  Setting this flags imposes security
2618     * restrictions on what application context you can access; if the
2619     * requested application can not be safely loaded into your process,
2620     * java.lang.SecurityException will be thrown.  If this flag is not set,
2621     * there will be no restrictions on the packages that can be loaded,
2622     * but {@link #getClassLoader} will always return the default system
2623     * class loader.
2624     */
2625    public static final int CONTEXT_INCLUDE_CODE = 0x00000001;
2626
2627    /**
2628     * Flag for use with {@link #createPackageContext}: ignore any security
2629     * restrictions on the Context being requested, allowing it to always
2630     * be loaded.  For use with {@link #CONTEXT_INCLUDE_CODE} to allow code
2631     * to be loaded into a process even when it isn't safe to do so.  Use
2632     * with extreme care!
2633     */
2634    public static final int CONTEXT_IGNORE_SECURITY = 0x00000002;
2635
2636    /**
2637     * Flag for use with {@link #createPackageContext}: a restricted context may
2638     * disable specific features. For instance, a View associated with a restricted
2639     * context would ignore particular XML attributes.
2640     */
2641    public static final int CONTEXT_RESTRICTED = 0x00000004;
2642
2643    /**
2644     * Return a new Context object for the given application name.  This
2645     * Context is the same as what the named application gets when it is
2646     * launched, containing the same resources and class loader.  Each call to
2647     * this method returns a new instance of a Context object; Context objects
2648     * are not shared, however they share common state (Resources, ClassLoader,
2649     * etc) so the Context instance itself is fairly lightweight.
2650     *
2651     * <p>Throws {@link PackageManager.NameNotFoundException} if there is no
2652     * application with the given package name.
2653     *
2654     * <p>Throws {@link java.lang.SecurityException} if the Context requested
2655     * can not be loaded into the caller's process for security reasons (see
2656     * {@link #CONTEXT_INCLUDE_CODE} for more information}.
2657     *
2658     * @param packageName Name of the application's package.
2659     * @param flags Option flags, one of {@link #CONTEXT_INCLUDE_CODE}
2660     *              or {@link #CONTEXT_IGNORE_SECURITY}.
2661     *
2662     * @return A Context for the application.
2663     *
2664     * @throws java.lang.SecurityException
2665     * @throws PackageManager.NameNotFoundException if there is no application with
2666     * the given package name
2667     */
2668    public abstract Context createPackageContext(String packageName,
2669            int flags) throws PackageManager.NameNotFoundException;
2670
2671    /**
2672     * Similar to {@link #createPackageContext(String, int)}, but with a
2673     * different {@link UserHandle}. For example, {@link #getContentResolver()}
2674     * will open any {@link Uri} as the given user.
2675     *
2676     * @hide
2677     */
2678    public abstract Context createPackageContextAsUser(
2679            String packageName, int flags, UserHandle user)
2680            throws PackageManager.NameNotFoundException;
2681
2682    /**
2683     * Return a new Context object for the current Context but whose resources
2684     * are adjusted to match the given Configuration.  Each call to this method
2685     * returns a new instance of a Context object; Context objects are not
2686     * shared, however common state (ClassLoader, other Resources for the
2687     * same configuration) may be so the Context itself can be fairly lightweight.
2688     *
2689     * @param overrideConfiguration A {@link Configuration} specifying what
2690     * values to modify in the base Configuration of the original Context's
2691     * resources.  If the base configuration changes (such as due to an
2692     * orientation change), the resources of this context will also change except
2693     * for those that have been explicitly overridden with a value here.
2694     *
2695     * @return A Context with the given configuration override.
2696     */
2697    public abstract Context createConfigurationContext(Configuration overrideConfiguration);
2698
2699    /**
2700     * Return a new Context object for the current Context but whose resources
2701     * are adjusted to match the metrics of the given Display.  Each call to this method
2702     * returns a new instance of a Context object; Context objects are not
2703     * shared, however common state (ClassLoader, other Resources for the
2704     * same configuration) may be so the Context itself can be fairly lightweight.
2705     *
2706     * The returned display Context provides a {@link WindowManager}
2707     * (see {@link #getSystemService(String)}) that is configured to show windows
2708     * on the given display.  The WindowManager's {@link WindowManager#getDefaultDisplay}
2709     * method can be used to retrieve the Display from the returned Context.
2710     *
2711     * @param display A {@link Display} object specifying the display
2712     * for whose metrics the Context's resources should be tailored and upon which
2713     * new windows should be shown.
2714     *
2715     * @return A Context for the display.
2716     */
2717    public abstract Context createDisplayContext(Display display);
2718
2719    /**
2720     * Gets the compatibility info holder for this context.  This information
2721     * is provided on a per-application basis and is used to simulate lower density
2722     * display metrics for legacy applications.
2723     *
2724     * @param displayId The display id for which to get compatibility info.
2725     * @return The compatibility info holder, or null if not required by the application.
2726     * @hide
2727     */
2728    public abstract CompatibilityInfoHolder getCompatibilityInfo(int displayId);
2729
2730    /**
2731     * Indicates whether this Context is restricted.
2732     *
2733     * @return True if this Context is restricted, false otherwise.
2734     *
2735     * @see #CONTEXT_RESTRICTED
2736     */
2737    public boolean isRestricted() {
2738        return false;
2739    }
2740}
2741