@Deprecated public class IsolatedContext extends ContextWrapper
Context.BindServiceFlags, Context.CreatePackageOptions, Context.ServiceName
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BATTERY_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_ALLOW_WHITELIST_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_EXTERNAL_SERVICE, BIND_FOREGROUND_SERVICE, BIND_FOREGROUND_SERVICE_WHILE_AWAKE, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_SHOWING_UI, BIND_TREAT_LIKE_ACTIVITY, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CARRIER_CONFIG_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_CREDENTIAL_PROTECTED_STORAGE, CONTEXT_DEVICE_PROTECTED_STORAGE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_REGISTER_PACKAGE, CONTEXT_RESTRICTED, CONTEXTHUB_SERVICE, COUNTRY_DETECTOR, DEVICE_IDLE_CONTROLLER, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, ETHERNET_SERVICE, FINGERPRINT_SERVICE, GATEKEEPER_SERVICE, HARDWARE_PROPERTIES_SERVICE, HDMI_CONTROL_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, JOB_SCHEDULER_SERVICE, KEYGUARD_SERVICE, LAUNCHER_APPS_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_PROJECTION_SERVICE, MEDIA_ROUTER_SERVICE, MEDIA_SESSION_SERVICE, MIDI_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_NO_LOCALIZED_COLLATORS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_SCORE_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, PERSISTENT_DATA_BLOCK_SERVICE, POWER_SERVICE, PRINT_SERVICE, RADIO_SERVICE, RECOVERY_SERVICE, RESTRICTIONS_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SHORTCUT_SERVICE, SIP_SERVICE, SOUND_TRIGGER_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, SYSTEM_HEALTH_SERVICE, TELECOM_SERVICE, TELEPHONY_SERVICE, TELEPHONY_SUBSCRIPTION_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, TRUST_SERVICE, TV_INPUT_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USAGE_STATS_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, VOICE_INTERACTION_MANAGER_SERVICE, WALLPAPER_SERVICE, WIFI_NAN_SERVICE, WIFI_P2P_SERVICE, WIFI_RTT_SERVICE, WIFI_SCANNING_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Constructor and Description |
---|
IsolatedContext(ContentResolver resolver,
Context targetContext)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
boolean |
bindService(Intent service,
ServiceConnection conn,
int flags)
Deprecated.
Connect to an application service, creating it if needed.
|
int |
checkUriPermission(Uri uri,
int pid,
int uid,
int modeFlags)
Deprecated.
Determine whether a particular process and user ID has been granted
permission to access a specific URI.
|
int |
checkUriPermission(Uri uri,
String readPermission,
String writePermission,
int pid,
int uid,
int modeFlags)
Deprecated.
Check both a Uri and normal permission.
|
List<Intent> |
getAndClearBroadcastIntents()
Deprecated.
Returns the list of intents that were broadcast since the last call to this method.
|
ContentResolver |
getContentResolver()
Deprecated.
Return a ContentResolver instance for your application's package.
|
File |
getFilesDir()
Deprecated.
Returns the absolute path to the directory on the filesystem where files
created with
Context.openFileOutput(java.lang.String, int) are stored. |
Object |
getSystemService(String name)
Deprecated.
Return the handle to a system-level service by name.
|
Intent |
registerReceiver(BroadcastReceiver receiver,
IntentFilter filter)
Deprecated.
Register a BroadcastReceiver to be run in the main activity thread.
|
void |
sendBroadcast(Intent intent)
Deprecated.
Broadcast the given intent to all interested BroadcastReceivers.
|
void |
sendOrderedBroadcast(Intent intent,
String receiverPermission)
Deprecated.
Broadcast the given intent to all interested BroadcastReceivers, delivering
them one at a time to allow more preferred receivers to consume the
broadcast before it is delivered to less preferred receivers.
|
void |
unregisterReceiver(BroadcastReceiver receiver)
Deprecated.
Unregister a previously registered BroadcastReceiver.
|
attachBaseContext, bindServiceAsUser, canStartActivityForResult, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkPermission, checkSelfPermission, checkUriPermission, clearWallpaper, createApplicationContext, createConfigurationContext, createCredentialProtectedStorageContext, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createPackageContextAsUser, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getBasePackageName, getCacheDir, getClassLoader, getCodeCacheDir, getDatabasePath, getDataDir, getDir, getDisplay, getDisplayAdjustments, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFileStreamPath, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSharedPreferences, getSharedPreferencesPath, getSystemServiceName, getTheme, getThemeResId, getUserId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isCredentialProtectedStorage, isDeviceProtectedStorage, isRestricted, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiverAsUser, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastAsUser, sendBroadcastMultiplePermissions, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setTheme, setWallpaper, setWallpaper, startActivities, startActivities, startActivitiesAsUser, startActivity, startActivity, startActivityAsUser, startActivityAsUser, startActivityForResult, startInstrumentation, startIntentSender, startIntentSender, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService
bindServiceAsUser, createCredentialEncryptedStorageContext, createDeviceEncryptedStorageContext, getColor, getColorStateList, getDrawable, getSharedPrefsFile, getString, getString, getSystemService, getText, isCredentialEncryptedStorage, isDeviceEncryptedStorage, migrateDatabaseFrom, migrateSharedPreferencesFrom, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks
public IsolatedContext(ContentResolver resolver, Context targetContext)
public List<Intent> getAndClearBroadcastIntents()
public ContentResolver getContentResolver()
Context
getContentResolver
in class ContextWrapper
public boolean bindService(Intent service, ServiceConnection conn, int flags)
Context
This function will throw SecurityException
if you do not
have permission to bind to the given service.
Note: this method can not be called from a
BroadcastReceiver
component. A pattern you can use to
communicate from a BroadcastReceiver to a Service is to call
Context.startService(android.content.Intent)
with the arguments containing the command to be
sent, with the service calling its
Service.stopSelf(int)
method when done executing
that command. See the API demo App/Service/Service Start Arguments
Controller for an illustration of this. It is okay, however, to use
this method from a BroadcastReceiver that has been registered with
Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
, since the lifetime of this BroadcastReceiver
is tied to another object (the one that registered it).
bindService
in class ContextWrapper
service
- Identifies the service to connect to. The Intent may
specify either an explicit component name, or a logical
description (action, category, etc) to match an
IntentFilter
published by a service.conn
- Receives information as the service is started and stopped.
This must be a valid ServiceConnection object; it must not be null.flags
- Operation options for the binding. May be 0,
Context.BIND_AUTO_CREATE
, Context.BIND_DEBUG_UNBIND
,
Context.BIND_NOT_FOREGROUND
, Context.BIND_ABOVE_CLIENT
,
Context.BIND_ALLOW_OOM_MANAGEMENT
, or
Context.BIND_WAIVE_PRIORITY
.true
is returned;
false
is returned if the connection is not made so you will not
receive the service object.Context.unbindService(android.content.ServiceConnection)
,
Context.startService(android.content.Intent)
,
Context.BIND_AUTO_CREATE
,
Context.BIND_DEBUG_UNBIND
,
Context.BIND_NOT_FOREGROUND
public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
Context
The system may broadcast Intents that are "sticky" -- these stay around after the broadcast as finished, to be sent to any later registrations. If your IntentFilter matches one of these sticky Intents, that Intent will be returned by this function and sent to your receiver as if it had just been broadcast.
There may be multiple sticky Intents that match filter, in which case each of these will be sent to receiver. In this case, only one of these can be returned directly by the function; which of these that is returned is arbitrarily decided by the system.
If you know the Intent your are registering for is sticky, you can supply null for your receiver. In this case, no receiver is registered -- the function simply returns the sticky Intent that matches filter. In the case of multiple matches, the same rules as described above apply.
See BroadcastReceiver
for more information on Intent broadcasts.
As of Build.VERSION_CODES.ICE_CREAM_SANDWICH
, receivers
registered with this method will correctly respect the
Intent.setPackage(String)
specified for an Intent being broadcast.
Prior to that, it would be ignored and delivered to all matching registered
receivers. Be careful if using this for security.
Note: this method cannot be called from a
BroadcastReceiver
component; that is, from a BroadcastReceiver
that is declared in an application's manifest. It is okay, however, to call
this method from another BroadcastReceiver that has itself been registered
at run time with Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
, since the lifetime of such a
registered BroadcastReceiver is tied to the object that registered it.
registerReceiver
in class ContextWrapper
receiver
- The BroadcastReceiver to handle the broadcast.filter
- Selects the Intent broadcasts to be received.Context.registerReceiver(BroadcastReceiver, IntentFilter, String, Handler)
,
Context.sendBroadcast(android.content.Intent)
,
Context.unregisterReceiver(android.content.BroadcastReceiver)
public void unregisterReceiver(BroadcastReceiver receiver)
Context
unregisterReceiver
in class ContextWrapper
receiver
- The BroadcastReceiver to unregister.Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
public void sendBroadcast(Intent intent)
Context
Context.sendOrderedBroadcast(Intent, String)
.
See BroadcastReceiver
for more information on Intent broadcasts.
sendBroadcast
in class ContextWrapper
intent
- The Intent to broadcast; all receivers matching this
Intent will receive the broadcast.BroadcastReceiver
,
Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
,
Context.sendBroadcast(Intent, String)
,
Context.sendOrderedBroadcast(Intent, String)
,
Context.sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
public void sendOrderedBroadcast(Intent intent, String receiverPermission)
Context
See BroadcastReceiver
for more information on Intent broadcasts.
sendOrderedBroadcast
in class ContextWrapper
intent
- The Intent to broadcast; all receivers matching this
Intent will receive the broadcast.receiverPermission
- (optional) String naming a permissions that
a receiver must hold in order to receive your broadcast.
If null, no permission is required.BroadcastReceiver
,
Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
,
Context.sendBroadcast(Intent)
,
Context.sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)
public int checkUriPermission(Uri uri, String readPermission, String writePermission, int pid, int uid, int modeFlags)
Context
Context.checkPermission(java.lang.String, int, int)
and Context.checkUriPermission(android.net.Uri, int, int, int)
in one
call.checkUriPermission
in class ContextWrapper
uri
- The Uri whose permission is to be checked, or null to not
do this check.readPermission
- The permission that provides overall read access,
or null to not do this check.writePermission
- The permission that provides overall write
access, or null to not do this check.pid
- The process ID being checked against. Must be > 0.uid
- The user ID being checked against. A uid of 0 is the root
user, which will pass every permission check.modeFlags
- The type of access to grant. May be one or both of
Intent.FLAG_GRANT_READ_URI_PERMISSION
or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
.PackageManager.PERMISSION_GRANTED
if the caller
is allowed to access that uri or holds one of the given permissions, or
PackageManager.PERMISSION_DENIED
if it is not.public int checkUriPermission(Uri uri, int pid, int uid, int modeFlags)
Context
checkUriPermission
in class ContextWrapper
uri
- The uri that is being checked.pid
- The process ID being checked against. Must be > 0.uid
- The user ID being checked against. A uid of 0 is the root
user, which will pass every permission check.modeFlags
- The type of access to grant. May be one or both of
Intent.FLAG_GRANT_READ_URI_PERMISSION
or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
.PackageManager.PERMISSION_GRANTED
if the given
pid/uid is allowed to access that uri, or
PackageManager.PERMISSION_DENIED
if it is not.Context.checkCallingUriPermission(android.net.Uri, int)
public Object getSystemService(String name)
Context
Context.WINDOW_SERVICE
("window")
WindowManager
.
Context.LAYOUT_INFLATER_SERVICE
("layout_inflater")
LayoutInflater
for inflating layout resources
in this context.
Context.ACTIVITY_SERVICE
("activity")
ActivityManager
for interacting with the
global activity state of the system.
Context.POWER_SERVICE
("power")
PowerManager
for controlling power
management.
Context.ALARM_SERVICE
("alarm")
AlarmManager
for receiving intents at the
time of your choosing.
Context.NOTIFICATION_SERVICE
("notification")
NotificationManager
for informing the user
of background events.
Context.KEYGUARD_SERVICE
("keyguard")
KeyguardManager
for controlling keyguard.
Context.LOCATION_SERVICE
("location")
LocationManager
for controlling location
(e.g., GPS) updates.
Context.SEARCH_SERVICE
("search")
SearchManager
for handling search.
Context.VIBRATOR_SERVICE
("vibrator")
Vibrator
for interacting with the vibrator
hardware.
Context.CONNECTIVITY_SERVICE
("connection")
ConnectivityManager
for
handling management of network connections.
Context.WIFI_SERVICE
("wifi")
WifiManager
for management of Wi-Fi
connectivity. On releases before NYC, it should only be obtained from an application
context, and not from any other derived context to avoid memory leaks within the calling
process.
Context.WIFI_P2P_SERVICE
("wifip2p")
WifiP2pManager
for management of
Wi-Fi Direct connectivity.
Context.INPUT_METHOD_SERVICE
("input_method")
InputMethodManager
for management of input methods.
Context.UI_MODE_SERVICE
("uimode")
UiModeManager
for controlling UI modes.
Context.DOWNLOAD_SERVICE
("download")
DownloadManager
for requesting HTTP downloads
Context.BATTERY_SERVICE
("batterymanager")
BatteryManager
for managing battery state
Context.JOB_SCHEDULER_SERVICE
("taskmanager")
JobScheduler
for managing scheduled tasks
Context.NETWORK_STATS_SERVICE
("netstats")
NetworkStatsManager
for querying network
usage statistics.
Context.HARDWARE_PROPERTIES_SERVICE
("hardware_properties")
HardwarePropertiesManager
for accessing hardware properties.
Note: System services obtained via this API may be closely associated with the Context in which they are obtained from. In general, do not share the service objects between various different contexts (Activities, Applications, Services, Providers, etc.)
getSystemService
in class ContextWrapper
name
- The name of the desired service.Context.WINDOW_SERVICE
,
WindowManager
,
Context.LAYOUT_INFLATER_SERVICE
,
LayoutInflater
,
Context.ACTIVITY_SERVICE
,
ActivityManager
,
Context.POWER_SERVICE
,
PowerManager
,
Context.ALARM_SERVICE
,
AlarmManager
,
Context.NOTIFICATION_SERVICE
,
NotificationManager
,
Context.KEYGUARD_SERVICE
,
KeyguardManager
,
Context.LOCATION_SERVICE
,
LocationManager
,
Context.SEARCH_SERVICE
,
SearchManager
,
Context.SENSOR_SERVICE
,
SensorManager
,
Context.STORAGE_SERVICE
,
StorageManager
,
Context.VIBRATOR_SERVICE
,
Vibrator
,
Context.CONNECTIVITY_SERVICE
,
ConnectivityManager
,
Context.WIFI_SERVICE
,
WifiManager
,
Context.AUDIO_SERVICE
,
AudioManager
,
Context.MEDIA_ROUTER_SERVICE
,
MediaRouter
,
Context.TELEPHONY_SERVICE
,
TelephonyManager
,
Context.TELEPHONY_SUBSCRIPTION_SERVICE
,
SubscriptionManager
,
Context.CARRIER_CONFIG_SERVICE
,
CarrierConfigManager
,
Context.INPUT_METHOD_SERVICE
,
InputMethodManager
,
Context.UI_MODE_SERVICE
,
UiModeManager
,
Context.DOWNLOAD_SERVICE
,
DownloadManager
,
Context.BATTERY_SERVICE
,
BatteryManager
,
Context.JOB_SCHEDULER_SERVICE
,
JobScheduler
,
Context.NETWORK_STATS_SERVICE
,
NetworkStatsManager
,
HardwarePropertiesManager
,
Context.HARDWARE_PROPERTIES_SERVICE
public File getFilesDir()
Context
Context.openFileOutput(java.lang.String, int)
are stored.
The returned path may change over time if the calling app is moved to an adopted storage device, so only relative paths should be persisted.
No additional permissions are required for the calling app to read or write files under the returned path.
getFilesDir
in class ContextWrapper
Context.openFileOutput(java.lang.String, int)
,
Context.getFileStreamPath(java.lang.String)
,
Context.getDir(java.lang.String, int)