@Implements(className="android.app.ContextImpl") public class ShadowContextImpl extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ShadowContextImpl._ContextImpl_
Accessor interface for
ContextImpl ’s internals. |
Modifier and Type | Field and Description |
---|---|
static String |
CLASS_NAME |
Constructor and Description |
---|
ShadowContextImpl() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
bindService(Intent intent,
ServiceConnection serviceConnection,
int i) |
protected boolean |
bindServiceAsUser(Intent intent,
ServiceConnection serviceConnection,
int i,
UserHandle userHandle)
Binds to a service but ignores the given UserHandle.
|
protected int |
checkCallingOrSelfPermission(String permission) |
protected int |
checkCallingPermission(String permission) |
protected int |
checkPermission(String permission,
int pid,
int uid) |
protected ClassLoader |
getClassLoader() |
protected ContentResolver |
getContentResolver() |
File |
getDatabasePath(String name) |
protected File |
getExternalCacheDir() |
protected File |
getExternalFilesDir(String type) |
protected File[] |
getExternalFilesDirs(String type) |
protected Object |
getSystemService(String name)
Returns the handle to a system-level service by name.
|
protected int |
getUserId() |
protected Intent |
registerReceiver(BroadcastReceiver receiver,
IntentFilter filter) |
protected Intent |
registerReceiver(BroadcastReceiver receiver,
IntentFilter filter,
String broadcastPermission,
Handler scheduler) |
protected Intent |
registerReceiverAsUser(BroadcastReceiver receiver,
UserHandle user,
IntentFilter filter,
String broadcastPermission,
Handler scheduler) |
void |
removeSystemService(String name)
Makes
getSystemService(String) return null for the given system service name, mimicking a device that doesn’t have that system service. |
static void |
reset() |
protected void |
sendBroadcast(Intent intent) |
protected void |
sendBroadcast(Intent intent,
String receiverPermission) |
protected void |
sendBroadcastAsUser(Intent intent,
UserHandle user)
Forwards the call to
sendBroadcast(Intent) , disregarding user param. |
protected void |
sendBroadcastAsUser(Intent intent,
UserHandle user,
String receiverPermission)
Forwards the call to
sendBroadcast(Intent,String) , disregarding user param. |
protected void |
sendOrderedBroadcast(Intent intent,
String receiverPermission) |
protected void |
sendOrderedBroadcast(Intent intent,
String receiverPermission,
BroadcastReceiver resultReceiver,
Handler scheduler,
int initialCode,
String initialData,
Bundle initialExtras) |
protected void |
sendOrderedBroadcastAsUser(Intent intent,
UserHandle userHandle,
String receiverPermission,
BroadcastReceiver resultReceiver,
Handler scheduler,
int initialCode,
String initialData,
Bundle initialExtras)
Behaves as
sendOrderedBroadcast(android.content.Intent, java.lang.String) and currently ignores userHandle. |
protected void |
sendOrderedBroadcastAsUser(Intent intent,
UserHandle userHandle,
String receiverPermission,
int appOp,
Bundle options,
BroadcastReceiver resultReceiver,
Handler scheduler,
int initialCode,
String initialData,
Bundle initialExtras)
|
protected void |
sendStickyBroadcast(Intent intent) |
void |
setSystemService(String key,
Object service) |
protected ComponentName |
startForegroundService(Intent service) |
protected void |
startIntentSender(IntentSender intent,
Intent fillInIntent,
int flagsMask,
int flagsValues,
int extraFlags,
Bundle options) |
protected ComponentName |
startService(Intent service) |
protected boolean |
stopService(Intent name) |
protected void |
unbindService(ServiceConnection serviceConnection) |
protected void |
unregisterReceiver(BroadcastReceiver broadcastReceiver) |
public static final String CLASS_NAME
@Implementation protected Object getSystemService(String name)
Returns the handle to a system-level service by name. If the service is not available in Roboletric, or it is set to unavailable in ShadowServiceManager.setServiceAvailability(java.lang.String, boolean)
, null
will be returned.
public void removeSystemService(String name)
Makes getSystemService(String)
return null
for the given system service name, mimicking a device that doesn’t have that system service.
@Implementation protected void startIntentSender(IntentSender intent, Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) throws IntentSender.SendIntentException
IntentSender.SendIntentException
@Implementation protected ClassLoader getClassLoader()
@Implementation protected int checkCallingPermission(String permission)
@Implementation protected int checkCallingOrSelfPermission(String permission)
@Implementation protected ContentResolver getContentResolver()
@Implementation protected void sendBroadcast(Intent intent)
@Implementation protected void sendBroadcast(Intent intent, String receiverPermission)
@Implementation(minSdk=17) protected void sendBroadcastAsUser(Intent intent, UserHandle user)
Forwards the call to sendBroadcast(Intent)
, disregarding user
param.
@Implementation(minSdk=17) protected void sendBroadcastAsUser(Intent intent, UserHandle user, String receiverPermission)
Forwards the call to sendBroadcast(Intent,String)
, disregarding user
param.
@Implementation protected void sendOrderedBroadcast(Intent intent, String receiverPermission)
@Implementation protected void sendOrderedBroadcast(Intent intent, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
@Implementation(minSdk=19) protected void sendOrderedBroadcastAsUser(Intent intent, UserHandle userHandle, String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Behaves as sendOrderedBroadcast(android.content.Intent, java.lang.String)
and currently ignores userHandle.
@Implementation(minSdk=23) protected void sendOrderedBroadcastAsUser(Intent intent, UserHandle userHandle, String receiverPermission, int appOp, Bundle options, BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData, Bundle initialExtras)
Behaves as sendOrderedBroadcast(android.content.Intent, java.lang.String)
. Currently ignores userHandle, appOp, and options.
@Implementation protected void sendStickyBroadcast(Intent intent)
@Implementation protected int checkPermission(String permission, int pid, int uid)
@Implementation protected Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter)
@Implementation protected Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter, String broadcastPermission, Handler scheduler)
@Implementation(minSdk=17) protected Intent registerReceiverAsUser(BroadcastReceiver receiver, UserHandle user, IntentFilter filter, String broadcastPermission, Handler scheduler)
@Implementation protected void unregisterReceiver(BroadcastReceiver broadcastReceiver)
@Implementation protected ComponentName startService(Intent service)
@Implementation(minSdk=26) protected ComponentName startForegroundService(Intent service)
@Implementation protected boolean stopService(Intent name)
@Implementation protected boolean bindService(Intent intent, ServiceConnection serviceConnection, int i)
@Implementation(minSdk=21) protected boolean bindServiceAsUser(Intent intent, ServiceConnection serviceConnection, int i, UserHandle userHandle)
Binds to a service but ignores the given UserHandle.
@Implementation protected void unbindService(ServiceConnection serviceConnection)
@Implementation(minSdk=17) protected int getUserId()
@Implementation protected File getExternalCacheDir()
@Implementation(maxSdk=18) protected File getExternalFilesDir(String type)
@Implementation(minSdk=19) protected File[] getExternalFilesDirs(String type)
@Resetter public static void reset()
@Implementation public File getDatabasePath(String name)